Skip to content

Fix incorrect Kubernetes event watcher chunking#34981

Merged
tigrato merged 1 commit intomasterfrom
tigrato/fix-watch-stream
Nov 30, 2023
Merged

Fix incorrect Kubernetes event watcher chunking#34981
tigrato merged 1 commit intomasterfrom
tigrato/fix-watch-stream

Conversation

@tigrato
Copy link
Copy Markdown
Contributor

@tigrato tigrato commented Nov 27, 2023

Improve handling of streaming events in response to non-chunked content-type from the Kubernetes API.

Previously, when dealing with streaming events, the code streamed the response into the target connection. However, the Kubernetes API did not provide the content-type as chunked. This lack of information caused the forwarder to be unaware that the connection was chunked. Consequently, the forwarder delayed response writing by buffering it, intending to minimize the number of writes.

In scenarios where the connection stream was busy with events, users might not receive individual events as chunks, leading to incomplete data. This could result in users receiving malformed JSON, triggering an abort of the process.

To address this issue, this commit introduces a modification. After each event, the response is now flushed to ensure that users receive the event as a complete and well-formed chunk. This adjustment improves the reliability and integrity of the data received by users during streaming events.

Fixes #34977

Changelog: Improved streaming event handling for Kubernetes API by flushing response after each event, ensuring complete, well-formed chunks.

Improve handling of streaming events in response to non-chunked content-type from the Kubernetes API.

Previously, when dealing with streaming events, the code streamed the response into the target connection.
However, the Kubernetes API did not provide the content-type as chunked.
This lack of information caused the forwarder to be unaware that the connection was chunked.
Consequently, the forwarder delayed response writing by buffering it, intending to minimize the number of writes.

In scenarios where the connection stream was busy with events, users might not receive individual events as chunks,
leading to incomplete data. This could result in users receiving malformed JSON, triggering an abort of the process.

To address this issue, this commit introduces a modification. After each event, the response is now flushed to ensure
that users receive the event as a complete and well-formed chunk.
This adjustment improves the reliability and integrity of the data received by users during streaming events.

Fixes #34977

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
@gunzy83
Copy link
Copy Markdown

gunzy83 commented Nov 29, 2023

I have tested this on my end using a build by @tigrato (via the community Slack) and it resolved the watch issues I reported in #34977. Thanks.

@tigrato tigrato added this pull request to the merge queue Nov 30, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 30, 2023
@tigrato tigrato added this pull request to the merge queue Nov 30, 2023
Merged via the queue into master with commit b083762 Nov 30, 2023
@tigrato tigrato deleted the tigrato/fix-watch-stream branch November 30, 2023 10:14
@public-teleport-github-review-bot
Copy link
Copy Markdown

@tigrato See the table below for backport results.

Branch Result
branch/v12 Create PR
branch/v13 Create PR
branch/v14 Create PR

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.

[Kubernetes] watch stream error: unable to decode an event from the watch stream

4 participants