Skip to content

[v3 backport] Fix rollback for missing resources (31412)#31982

Open
fmuyassarov wants to merge 1 commit intohelm:dev-v3from
Nordix:devel/backport-31412
Open

[v3 backport] Fix rollback for missing resources (31412)#31982
fmuyassarov wants to merge 1 commit intohelm:dev-v3from
Nordix:devel/backport-31412

Conversation

@fmuyassarov
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Backport of #31412 as discussed over the slack

Special notes for your reviewer:
Two minor/cosmetic differences compared to the original PR that landed on the main:

  • Used c.Log() instead of slog.Warn() (dev-v3 doesn't use slog)
  • called updateResource(c, info, currentObj, force, threeWayMerge) directly instead of going through the
    updateApplyFunc() callback pattern

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 30, 2026
@fmuyassarov
Copy link
Copy Markdown
Contributor Author

/cc @banjoh

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backports Helm upstream fix to allow rollbacks to succeed when a resource exists in the cluster but is missing from the “original” release manifest (e.g., failed upgrade removed it from release state).

Changes:

  • Adjust Client.update() to use live cluster state as the baseline when the resource is missing from original.
  • Add a unit test covering the rollback-with-missing-original scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pkg/kube/client.go Implements cluster-state baseline behavior for rollback updates when original lacks the resource.
pkg/kube/client_test.go Adds a regression test for the rollback scenario where the original manifest is empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/kube/client.go Outdated
Comment thread pkg/kube/client.go Outdated
Comment thread pkg/kube/client_test.go
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@est.tech>
@fmuyassarov fmuyassarov force-pushed the devel/backport-31412 branch from e0e87bb to 0a47573 Compare March 30, 2026 14:43
@pull-request-size pull-request-size Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 30, 2026
@fmuyassarov fmuyassarov requested a review from Copilot March 30, 2026 14:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@banjoh banjoh left a comment

Choose a reason for hiding this comment

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

LGTM

@scottrigby scottrigby added the bug Categorizes issue or PR as related to a bug. label Mar 30, 2026
@scottrigby scottrigby added this to the 3.20.2 milestone Mar 30, 2026
Comment thread pkg/kube/client.go

helper := resource.NewHelper(info.Client, info.Mapping).WithFieldManager(getManagedFieldsManager())
if _, err := helper.Get(info.Namespace, info.Name); err != nil {
currentObj, err := helper.Get(info.Namespace, info.Name)
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.

@fmuyassarov curious about another difference from the v4 PR. Specifically why this code changed here, instead of currentObj being set inside of the if original == nil conditional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The v3 code was already calling helper.Get() unconditionally earlier in the function to check if the resource needs to be created. The current patch just captures that result instead of discarding it with _, so it's available later in the original == nil branch - so no extra API call needed. In main branch the code structure was different: there was no prior Get() call, so it was added inside original == nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants