pytogo / portforward

Kubernetes Port-Forward Go-Edition For Python
https://portforward.readthedocs.io
MIT License
17 stars 6 forks source link

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

Closed nidabdella closed 1 year ago

nidabdella commented 1 year ago

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  
corka149 commented 1 year ago

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.

corka149 commented 1 year ago

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.