cluster-autoscaler: pass context down RunOnce loop #9887
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 209 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.320
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9887"
general
weight: 0.35
yashrajshuklaaa
What type of PR is this?
/kind cleanup
What this PR does
Autoscaler.RunOnce did not accept a context.Context so a graceful termination signal could not interrupt a long-running autoscaling iteration. In large clusters, a single RunOnce call can take longer than the graceful termination period leading to the process being killed without cleaning up properly
This PR threads context.Context through RunOnce and loop.RunAutoscalerOnce and adds cancellation checks in
StaticAutoscaler.RunOnce - one at the start of the iteration and one right before the scale-up/scale-down section ( the most expensive part of the loop ).
When the context is cancelled RunOnce returns early and cleanly without registering an error since this isn't a failure
it's intentional , graceful stop
See https://github.com/kubernetes/autoscaler/issues/9855
Special notes for your reviewer :
this change means the context is now also honored during an in-progress iteration not just between iterations.
Updated the stale TODO comments there accordingly
``
release-note
``Pass context.Context down to Autoscaler.RunOnce to allow graceful shutdown to interrupt long-running autoscaling iterations.