Skip to content

[v18] Fix data race in Kubernetes StreamSession#61818

Merged
rosstimothy merged 1 commit intobranch/v18from
bot/backport-61807-branch/v18
Nov 28, 2025
Merged

[v18] Fix data race in Kubernetes StreamSession#61818
rosstimothy merged 1 commit intobranch/v18from
bot/backport-61807-branch/v18

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

Backport #61807 to branch/v18

changelog: Prevent data races when terminating interactive Kubernetes sessions

The websocket used to communicate with Kubernetes was proctected
by a mutex to prevent data races from concurrent writes. The mutex
was however not being acquired when closing the session which
could lead to data races since handling of various aspects of an
interactive session are done in multiple goroutines.

All existing direct calls to `WriteMessage` were replaced with
the new `(SessionStream) write` function which serializes all
writes as intended by acquiring the `writeSync` mutex.

`(SessionStream) Close` was also reorganized to reduce indentation
and return any errors that may be returned from closing the websocket.

`SessionStream.closed` has been updated to atomic.Bool instead of an
int32 that was accessed via the atomic.Int32 APIs.
@rosstimothy rosstimothy marked this pull request as ready for review November 26, 2025 20:42
@github-actions github-actions bot requested review from greedy52 and zmb3 November 26, 2025 20:43
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from greedy52 November 26, 2025 21:12
@rosstimothy rosstimothy added this pull request to the merge queue Nov 28, 2025
Merged via the queue into branch/v18 with commit 27d16b0 Nov 28, 2025
44 checks passed
@rosstimothy rosstimothy deleted the bot/backport-61807-branch/v18 branch November 28, 2025 19:02
@aadc-dev aadc-dev mentioned this pull request Dec 1, 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