Skip to content

Avoid returning error when annotation patch for InPlaceOrResize fails - #9115

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
adrianmoisey:add-retry-to-patch-annotation
Jan 24, 2026
Merged

k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
adrianmoisey:add-retry-to-patch-annotation

Conversation

@adrianmoisey

@adrianmoisey adrianmoisey commented Jan 23, 2026 •

Copy link
Copy Markdown
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

This should help mitigate the issue here: #9080
(but it's still possible that this annotation patch fails 3 times, and causes the pod to be recreated)

Which issue(s) this PR fixes:

Fixes #9080

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Avoid returning error when annotation patch for InPlaceOrResize fails, that would cause Pods to get unnecessarily evicted after resize

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


/cc @omerap12 @maxcao13 @jkyros

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 23, 2026
@k8s-ci-robot
k8s-ci-robot requested a review from omerap12 January 23, 2026 05:58
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 23, 2026
@k8s-ci-robot
k8s-ci-robot requested a review from maxcao13 January 23, 2026 05:58
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

@adrianmoisey: GitHub didn't allow me to request PR reviews from the following users: jkyros.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

What type of PR is this?

/kind bug

What this PR does / why we need it:

This should help mitigate the issue here: #9080
(but it's still possible that this annotation patch fails 3 times, and causes the pod to be recreated)

Which issue(s) this PR fixes:

Fixes #9080

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Add retry logic with exponential backoff to in-place pod resize annotation patching for improved resilience to transient errors 

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


/cc @omerap12 @maxcao13 @jkyros

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 kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area Indicates that a PR should not merge because it lacks an area label. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler Issues or PRs related to the Vertical Pod Autoscaler component size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-area Indicates that a PR should not merge because it lacks an area label. labels Jan 23, 2026
@adrianmoisey
adrianmoisey force-pushed the add-retry-to-patch-annotation branch 3 times, most recently from 4c797d6 to 3677e1b Compare January 23, 2026 12:24
Comment on lines 167 to 169
if err != nil {
return err
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the retry idea, but I generally think that even if the annotation patch doesn't go through, it shouldn't block whether the overall operation was a failure or not. I think maybe we should think about not returning an error, but just logging it. The annotation isn't really a big deal, I don't think it's used other than for cosmetic reasons.

But also now thinking about it, what happens if all pods for resize in one loop have to retry? That's around 300ms per pod, and I don't think that we're doing concurrent updates here right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All valid points, thanks Max.

But also now thinking about it, what happens if all pods for resize in one loop have to retry? That's around 300ms per pod, and I don't think that we're doing concurrent updates here right?

I had thought about this, and originally came to the conclusion that a scenario where all annotation patcher were to fail, then all the resizes would fail first, causing the patch to not be executed. But it turns out that this situation is actually possibly, if someone reduces the RBAC to only pods/resize only, see:

resources:
- pods/resize
- pods # required for patching vpaInPlaceUpdated annotations onto the pod

I think maybe we should think about not returning an error, but just logging it.

Agree, I'll remove the retry and add a log entry

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. thanks Max!

So that it doesn't create an error and cause the pod to get evicted
@adrianmoisey
adrianmoisey force-pushed the add-retry-to-patch-annotation branch from 3677e1b to d03a10b Compare January 24, 2026 10:50
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 24, 2026
@adrianmoisey adrianmoisey changed the title Add a retry to the annotation patch for InPlaceOrResize Avoid returning error when annotation patch for InPlaceOrResize fails Jan 24, 2026

@omerap12 omerap12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
/lgtm

should we also backport this?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 24, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianmoisey, omerap12

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
k8s-ci-robot merged commit b17ea13 into kubernetes:master Jan 24, 2026
6 checks passed
@adrianmoisey

Copy link
Copy Markdown
Member Author

should we also backport this?

Good idea!

/cherry-pick vpa-release-1.5

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@adrianmoisey: new pull request created: #9124

Details

In response to this:

should we also backport this?

Good idea!

/cherry-pick vpa-release-1.5

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 kubernetes-sigs/prow repository.

@vitanovs vitanovs mentioned this pull request Mar 27, 2026
2 tasks done
@adrianmoisey
adrianmoisey deleted the add-retry-to-patch-annotation branch September 9, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler Issues or PRs related to the Vertical Pod Autoscaler component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-place update falled back to eviction when it actually succeeded

5 participants