pytogo / portforward

Kubernetes Port-Forward Go-Edition For Python

Home Page:https://portforward.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stopping the portforwarding using `__exit__()` doesn't seem to work

nidabdella opened this issue · comments

  • portforward version: 0.4.5
  • Python version: 3.10
  • Operating System: Ubunti 22.4LTS

Description

In minikube, using the the following command:
kubectl create -k "github.com/ray-project/kuberay/manifests/cluster-scope-resources?ref=v0.4.0&timeout=90s"

then run
kubectl create -f <file_below_change_extension_to_yaml>
ray-cluster.mini.txt

This installs the dependencies of Ray in minikube then spins up a Ray cluster using the configuration file above.
portforwarding the port 8265 of a ray cluster allows us to have a dashboard though the local port.

Ray dashboard:
Screenshot from 2023-05-09 17-55-21

What I Did

import portforward
pf = portforward.forward(namespace="default", pod_or_service="raycluster-mini-head-svc",
                                              from_port=8266, to_port=8265)
pf.__enter__() # this exposes the 8265 through the local 8266

## HERE IS THE PROBLEM
pf.__exit__(None, None, None) # doesn't stop the pf
# False  

Hi @nidabdella . Thx for the detailed issue. I was able to reproduce it based on your description. The __exit__ works flawless for portforwards that targets one pod but it does not work with services.

The new version with the fix will be released within the next days. There is also a test now in place that test the expected behavior.