← Back to Pull requests

VPA: add new TargetHigherThanRequestsAndOOM eviction requirement #10678

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 12, 2026 09:08 UTC
Author

What type of PR is this?

/kind feature
/kind api-change

<!--
Add one of the following kinds:
/kind bug
/kind dependency
/kind cleanup
/kind documentation
/kind feature

Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

What this PR does / why we need it:

This PR adds a new eviction requirement, TargetHigherThanRequestsAndOOM that users can set to only allow updater to evict Pods that have a container that has been OOM killed recently or is currently in terminated state due to OOM kill and has a recommendation for resource upscale.

 updatePolicy:
   evictionRequirements:
     - resources: ["memory"]
       changeRequirement: TargetHigherThanRequestsAndOOM

Our use case: we run customer workloads that are very sensitive to disruptions, so normally are only restarted within a set maintenance window. We still want to use VPA and are going to attempt to avoid need for restarts by adding a larger margin to the VPA recommendation. However, in cases where the workload does get OOM killed, we want to apply the recommendation immediately without waiting for the maintenance window.
Currently we have built our own evictions controller to achieve similar behaviour, however co-ordinating the behaviour of the controller with VPA updater, especially once we start using in-place updates will be difficult.
See #10174 for more context.

The new eviction requirement is gated behind a EvictionRequirementOOMScaleUp alpha feature gate that needs to be set for admissions webhook and updater in order to use it.

Which issue(s) this PR fixes:


<!--
Automatically closes linked issue when PR is merged.
Usage: Fixes #<issue number>, or Fixes (paste link of issue).
_If PR is about failing-tests or flakes, please post the related issues/tests in a comment and do not use Fixes_

-->

Fixes #10174

Special notes for your reviewer:

A few notes on implementation:

  • the eviction requirement only looks at how recent the OOM kill is and not at the duration of the container run.

  • This differs from quick OOM logic in updater. Thinking about our specific use case it seemed to make sense to allow eviction if there has been an OOM kill and is an upscale + other requirements pass without also checking for duration, but checking for duration would also work for us, so not opinionated on changing this.

  • this requirement probably only makes sense for memory resource. I could have added an admission validation and reject it for cpu, but it seemed that doing that would not add much user value.
  • there is currently a bug that applies eviction requirements to in-place resize requests that need to be fixed separately https://github.com/kubernetes/autoscaler/issues/10181
  • I have picked the existing --evict-after-oom-threshold flag/evictAfterOOMThreshold VPA field value with the 10 minute default for what counts as 'recent' OOM kill. This seemed to make sense because the updater also uses that value when calculating 'recent' for quick OOM here and I can't think of why someone would want different values for 'recent' in different places in updater.
  • 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
    Adds a new eviction requirement,
    TargetHigherThanRequestsAndOOM, that restricts the updater to only evict Pods that have a container that has been recently OOM killed and has a resource upscale recommendation. This is an alpha feature, disabled by default. To enable it, set --feature-gates=EvictionRequirementOOMScaleUp=true on both the admission-controller and the updater.

    
    #### Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
    
    <!--
    This section can be blank if this pull request does not require a release note.
    
    When adding links which point to resources within git repositories, like
    KEPs or supporting documentation, please reference a specific commit and avoid
    linking directly to the master branch. This ensures that links reference a
    specific point in time, rather than a document that may change over time.
    
    See here for guidance on getting permanent links to files: https://help.github.com/en/articles/getting-permanent-links-to-files
    
    Please use the following format for linking documentation:
    - [KEP]: <link>
    - [Usage]: <link>
    - [Other doc]: <link>
    -->
    
    docs
  • [Usage]: <https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/docs/examples.md#controlling-eviction-behavior-based-on-scaling-direction-and-resource>
  • ``

    /area vertical-pod-autoscaler

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Summary

    New Features
    Added an alpha eviction requirement for scaling up a container’s memory when its recommendation exceeds its request and it has recently been OOMKilled, subject to other eviction requirements.
    The feature is disabled by default and requires enabling its feature gate. The recent-OOM window can use a per-VPA setting or the default 10-minute threshold.
    Documentation
    * Added configuration guidance and examples, including feature-gate and recent-OOM requirements.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: adrianmoisey Review duration: 28726m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #10678"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 27.7% · Safe to merge
    27.7%