Skip to content

[v18] Fix kube port-forward race with multiple ports#57736

Merged
rana merged 1 commit intobranch/v18from
bot/backport-57474-branch/v18
Aug 11, 2025
Merged

[v18] Fix kube port-forward race with multiple ports#57736
rana merged 1 commit intobranch/v18from
bot/backport-57474-branch/v18

Conversation

@rana
Copy link
Copy Markdown
Contributor

@rana rana commented Aug 9, 2025

Backport #57474 to branch/v18

changelog: Kubernetes Access: Fixed a bug when forwarding multiple ports to a single pod

Fixes a race condition when forwarding multiple ports to a single pod.

Root cause was concurrent access to an unguarded `auditSent` map in the forwarder `portForward()` function.

Changes:

`lib/kube/proxy/forwarder.go`
- Added mutex for `auditSent` map in `portForward()`

`lib/kube/proxy/portforward_test.go`
- Added mock test for Kubernetes forwarding multiple ports

`lib/kube/proxy/testing/kube_server/kube_mock.go`
- Revised mock server `portforward` function to process each stream in a goroutine

`lib/kube/proxy/utils_test.go`
- Updated test context `startKubeServices` function to allow and expect `net.ErrClosed`

Fixes #57242
@rana rana enabled auto-merge August 10, 2025 03:31
@rana rana added this pull request to the merge queue Aug 11, 2025
Merged via the queue into branch/v18 with commit ed7c23c Aug 11, 2025
42 checks passed
@rana rana deleted the bot/backport-57474-branch/v18 branch August 11, 2025 12:22
@doggydogworld doggydogworld mentioned this pull request Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants