fix: rollback to release containing resource with resource-policy=keep annotation #9068
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When rollback to a previous release revision that contains a resource
having the annotaion 'helm.sh/resource-policy=keep', while the current
release revision dosen't have this resource, rollback will fail with
an error message:
'Error: no < Kind > with the name "< Resource name >" found'
First of all the error message is misleading, since the resource
actually exists. But the resource is not part of the current manifest
(it is left there in a previous update due to the resource-policy=keep
annotation). So helm cannot create a patch to update the given resource
from the current to the target manifest, and fails with an error.
The logic is updated to in this scenario (resource is part of the target
manifest but NOT part of the current manifest) skip the upgrade IF the
resource-policy=keep annotation is set.
The error message is also updated and the the logic for checking the
resource-policy annotation is broken out into a separate function.
fix #8228
Signed-off-by: Ted Petersson ted.petersson@ericsson.com
closes #8228
I've tested upgrade/rollback between the following 2 simple charts:
chartA MANIFEST:
Note - my-service2 and my-service3 have helm.sh/resource-policy: "keep" annotation
chartB MANIFEST:
Note1 - my-service2 not part of this manifest
Note2 - my-service1/3 have updated config (new ports)
To reproduce / verify the issue:
Step 1 - Install
Step 2 - Upgrade
Note - my-service1/3 are updated (new port config) and my-service2 is kept (even though not part of the manifest)
Step 3A - Rollback without fix
Step 3B - Rollback with fix
Note - We're back to the original (chartA) config
I've also tested upgrading to "other way around" and it works fine:
Install chartB -> Upgrade chartA -> Rollback