exec/attach: let the client close the connection so no output is lost #142461
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 357 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.352
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #142461"
general
weight: 0.35
semx
Draft. The client-go part is now #142712 and the translator part #143324; this PR will be cut down to the cri-streaming change on top of them, which waits for the KEP discussed in #142376.
What type of PR is this?
/kind bug
What this PR does / why we need it:
kubectl execandattachlose the end of the output when the client reads more slowly than the command writes and is also sending input (#142376). The server writes the status and closes the connection at once; the client's next frame then makes the kernel reset the connection and drop what is still in the send buffer. Over SPDY, client-go then sees an empty status and reports success.The change:
k8s.io/cri-streaming) and the WebSocket translator no longer close first. They send the status, signal the end (SPDY: close the output streams; WebSocket: a close frame, newwsstream.Conn.CloseWrite), and wait for the client to close, bounded by the request context and 15 minutes.connection closed before the command's status was received) instead of success.Behaviour change: a client that neither closes nor answers the close frame now holds the session for up to 15 minutes after the command exits (the old code returned at once).
Tested with unit tests that reproduce the loss on the old code, and on a real multi-node cluster with containerd, CRI-O and Windows; results in https://github.com/kubernetes/kubernetes/pull/142461#issuecomment-5920263856.
Which issue(s) this PR is related to:
Part of #142376
Related: #60140, #124571
Special notes for your reviewer:
Reading order:
finishincri-streaming/pkg/streaming/remotecommand/httpstream.go,CloseWrite/CloseChaninstreaming/pkg/httpstream/wsstream/conn.go, the translator inapiserver/pkg/util/proxy, the client-go check intools/remotecommand. The runtimes vendor the server, so they need a bump or port after this merges (plan in #142376).Credits: the report and first reproduction are @knoppiks's; @herefindalex isolated the close sequence; @thc1006 reproduced it on four nodes and found the mixed-version case in review.
Does this PR introduce a user-facing change?
``
release-notekubectl execFixed
,kubectl attachandcrictl execlosing the end of the output when the client read more slowly than the command wrote; over SPDYkubectl execcould also exit 0 with truncated output. The CRI streaming server and the WebSocket translator now wait up to 15 minutes for the client to close the connection after the command exits, and client-go reports an error when the command's status is missing.
``AI usage disclosure:
YES. Used to check the diagnosis and fix against the source (a second pass after my own), and to help draft and format this description.