BUG OCPBUGS-119955: Fix oc debug -T race condition with container attach - #2392
BUG OCPBUGS-119955: Fix oc debug -T race condition with container attach#2392davegord wants to merge 1 commit into
Conversation
When using `oc debug -T` (--no-tty), only TTY was disabled but Stdin remained true. This caused the command to take the attach code path (SPDY/WebSocket upgrade) instead of the log-streaming path. For fast-exiting commands, the container terminates before the connection upgrade completes, resulting in "unable to upgrade connection: container container-00 not found". The fix disables Stdin when -T is set, matching the behavior already used when a command is passed without -T (lines 302-304). This routes -T commands through the log-streaming path which doesn't require an attach and can't race with container completion. Fixes: OCPBUGS-119955 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe debug attachment command now disables STDIN forwarding when ChangesDebug attachment behavior
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The change makes non-TTY debug attachments avoid stdin forwarding, preventing the unnecessary interactive connection upgrade for fast-exiting containers. No current merge-readiness risk remains. 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. Full details: Stable And Deterministic Test NamesExplanation PASS. The pull request changes only Full details: Test Structure And QualityExplanation PASS: The pull request changes only one production line in Full details: Microshift Test CompatibilityExplanation PASS — The pull request changes only Full details: Single Node Openshift (Sno) Test CompatibilityExplanation PASS: The pull request changes only Full details: Topology-Aware Scheduling CompatibilityExplanation PASS: The pull request changes only Full details: Ote Binary Stdout ContractExplanation PASS: The pull request changes only Full details: Ipv6 And Disconnected Network Test CompatibilityExplanation PASS: The pull request changes only Full details: No-Weak-CryptoExplanation PASS. The pull request changes one line: Full details: Container-PrivilegesExplanation PASS: The pull request changes only Full details: No-Sensitive-Data-In-LogsExplanation PASS: The pull request adds only ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: davegord The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@davegord: This pull request references Jira Issue OCPBUGS-119955, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@davegord: This pull request references Jira Issue OCPBUGS-119955, which is invalid:
Comment DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@davegord: This pull request references Jira Issue OCPBUGS-119955, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@davegord: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
oc debug -T(--no-tty) fails with "unable to upgrade connection: container container-00 not found" on OCP 5.0 (OCPBUGS-119955)-Tis set,Stdinremainstrue, routing through the SPDY/WebSocket attach path instead of log-streaming. For fast-exiting commands, the container terminates before the upgrade completes.Stdinwhen-Tis set, matching the existing behavior for commands passed without-T(lines 302-304). This routes through the log-streaming path which can't race with container completion.Details
In
Complete(), thecase o.DisableTTY:branch (line 299) only seto.Attach.TTY = falsebut lefto.Attach.Stdin = true(the default). This causedRunDebug()to hit thedefault:case (line 665) which callso.Attach.Run()— an attach that requires a SPDY/WebSocket connection upgrade. When the container exits before the upgrade completes, the kubelet returns "container not found".The existing
case len(o.Command) > 0:branch (line 302) already correctly sets bothTTY=falseandStdin=false, but-Thas higher priority in the switch and was missing theStdin=false.The code even has a TODO acknowledging this race:
// TODO: attach can race with pod completion, allow attach to switch to logsTest plan
oc debug node/<node> -T -- cat /etc/os-releaseshould succeed consistently (was 100% failure rate before)oc debug node/<node> -- cat /etc/os-releaseshould continue to work (no behavior change)oc debug node/<node>(interactive) should continue to work with TTYoc debug -t node/<node>(explicit TTY) should continue to work🤖 Generated with Claude Code
Summary by CodeRabbit
--no-tty, standard input is now disabled as expected.