← Back to Pull requests

fix(cli): avoid send on closed channel panic in status watch. Fixes #4372 #5056

Closed
unknown closed this pull request without merging on Sep 24, 2026 11:29 UTC
View on GitHub
unknown unknown commented on Sep 24, 2026 08:39 UTC
Author

kubectl argo rollouts status (watch is the default) intermittently panics with send on closed channel at status.go:76, the send inside the registered callback.

The callback pushes every changed RolloutInfo into an unbuffered channel that WatchStatus reads. As soon as WatchStatus sees Healthy or Degraded it returns and nobody receives any more, but the view controller keeps processing until the command returns and cancel() runs. If the rollout (or one of its ReplicaSets, pods, AnalysisRuns) changes in that window, the callback blocks in the send. When RunE returns, deferred calls run in reverse order, so defer close(rolloutUpdates) runs before the deferred cancel(), and the blocked send panics. Watching rollouts while a deploy is still changing pods, as in the issue, is what hits that window.

#1796 (for #1747) changed close(rolloutUpdates) into defer close(rolloutUpdates), which narrowed the window but didn't close it. The close isn't needed: WatchStatus has already returned and nothing ranges over the channel or waits for it to close. So this removes it. A callback that is still blocked stays blocked until the process exits, which is harmless for a CLI command.

The new test updates the rollout from inside the first status write, i.e. right before WatchStatus returns, so the late update is always in flight when the command exits. Without the fix it panics every time.

Fixes #4372

Testing

go test ./pkg/kubectl-argo-rollouts/...
go test -race ./pkg/kubectl-argo-rollouts/cmd/status/ -count=3
go vet ./pkg/kubectl-argo-rollouts/..., golangci-lint run ./pkg/kubectl-argo-rollouts/cmd/status/...
TestWatchStatusUpdateAfterDone: 5/5 runs panic with send on closed channel on master, pass with this change

Not changed here: get experiment --watch closes its channel after Run returns in the same way, which can only race on Ctrl-C.

Checklist:

[x] Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
[x] The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
[x] I've signed my commits with DCO
[x] My builds are green. Try syncing with master if they are not.
[x] I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
[ ] I have run all tests locally (including the flaky ones) and they pass on my workstation
[x] I have used LLM/AI/Agent tools for this PR but I am responsible for all code of this PR
[x] I understand what the code does and WHY/HOW it works in several scenarios
[x] I know if my code is just adding new functionality or changing old functionality for existing users
[ ] My organization is added to USERS.md.

Diff: 408 lines (+306 / -102) across 5 files Reviewer: kostis-codefresh Review duration: 169m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 408 lines diff across 5 files
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.360
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5056"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 44.8% (MEDIUM) · Higher = larger blast radius
44.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.7% · Safe to merge
17.7%