← Back to Pull requests

Add safe-to-evict=on-completion #9355

Closed
unknown closed this pull request without merging on Apr 01, 2026 08:40 UTC
View on GitHub
unknown unknown commented on Mar 13, 2026 09:54 UTC
Author

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

This PR introduces the cluster-autoscaler.kubernetes.io/safe-to-evict: "on-completion" annotation value. It allows users to specify that a pod should not be actively evicted by the Cluster Autoscaler during a scale-down event, but rather should be allowed to run to completion.

When scaling down, the Cluster Autoscaler will wait for pods with this annotation to complete successfully rather than forcefully evicting them. Nodes containing only daemonset pods and "on-completion" pods are prioritized for scale-down after completely empty nodes, but before nodes requiring active pod eviction.

This is particularly useful for AI/ML workloads or batch jobs that cannot be easily interrupted or checkpointed, ensuring they finish their computation naturally before the underlying node is scaled down.

Special notes for your reviewer:

PR adds a new drainability rule oncompletion which skips pods annotated with cluster-autoscaler.kubernetes.io/safe-to-evict=on-completion. To surface this state cleanly to the rest of the CA logic, the simulator.GetPodsToMove function was refactored to return a PodMoveInfo struct rather than multiple slice return values. This cleans up the signature and allows better handling of special pod categories like OnCompletionPods.

The ScaleDownNodeProcessor sorting logic is also updated to prioritize nodes with only on-completion pods right after completely empty nodes.

Does this PR introduce a user-facing change?


<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->
``release-note
Introduced
cluster-autoscaler.kubernetes.io/safe-to-evict: "on-completion" annotation value. Pods with this annotation will not be forcefully evicted during node scale-down; instead, the Cluster Autoscaler will wait for them to natively run to completion before scaling down the node. Nodes with only these pods are prioritized for scale-down over nodes with standard pods requiring eviction.
``

Diff: 301 lines (+225 / -76) across 3 files Reviewer: x13n Review duration: 27285m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 301 lines diff across 3 files
0.40
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.342
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9355"
general weight: 0.35
Reviewers
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: 40.1% (MEDIUM) · Higher = larger blast radius
40.1%
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: 15.8% · Safe to merge
15.8%