containers / podman-desktop

Podman Desktop is the best free and open source tool to work with Containers and Kubernetes for developers. Get an intuitive and user-friendly interface to effortlessly build, manage, and deploy containers and Kubernetes — all from your desktop.
https://podman-desktop.io
Apache License 2.0
4.78k stars 300 forks source link

`KubernetesClient#deletePortForward` do not dispose the server #9561

Open axel7083 opened 3 hours ago

axel7083 commented 3 hours ago

Bug description

I was working on https://github.com/containers/podman-desktop/issues/9273 and https://github.com/containers/podman-desktop/issues/9275 and I found a problem with the way we delete port foward added in https://github.com/containers/podman-desktop/pull/7379

When we delete a port forward we get the KubernetesPortForwardService

https://github.com/containers/podman-desktop/blob/2600ef0449b96d916cf282437d1320fbb5e1bbf1/packages/main/src/plugin/kubernetes/kubernetes-client.ts#L1772-L1774

The service itself ask the configuration to delete it

https://github.com/containers/podman-desktop/blob/2600ef0449b96d916cf282437d1320fbb5e1bbf1/packages/main/src/plugin/kubernetes/kubernetes-port-forward-service.ts#L105-L108

And the configuration remove it from its configuration: but do not dispose the server!!

https://github.com/containers/podman-desktop/blob/2600ef0449b96d916cf282437d1320fbb5e1bbf1/packages/main/src/plugin/kubernetes/kubernetes-port-forward-storage.ts#L324-L332

Why ?

When we start the port forward, we do not store the disposable, meaning, we are never able to remove it.

https://github.com/containers/podman-desktop/blob/2600ef0449b96d916cf282437d1320fbb5e1bbf1/packages/main/src/plugin/kubernetes/kubernetes-client.ts#L1768

The only places where the disposables are stored are in the KubernetesPortForwardService, but they are an unusable Array

https://github.com/containers/podman-desktop/blob/ec3ee08dbe4ff0343f5cb12f70756d286c4f1e8a/packages/main/src/plugin/kubernetes/kubernetes-port-forward-service.ts#L68

Operating system

Fedora 40

Installation Method

Other

Version

next (development version)

Steps to reproduce

  1. start a port foward using code from https://github.com/containers/podman-desktop/pull/7379
  2. call delete
  3. assert server still running

Relevant log output

No response

Additional context

We would need to have somewhere, probably the KubernetesPortForwardService a Map linking a resources to the disposable, or something similar

axel7083 commented 3 hours ago

cc @jeffmaury