-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix namespace metadata not being restored with existing-resource-policy #8607
base: main
Are you sure you want to change the base?
Fix namespace metadata not being restored with existing-resource-policy #8607
Conversation
This change ensures that when restoring namespaces with existing-resource-policy set to 'update', the namespace metadata (labels and annotations) from the backup bundle is properly restored. Fixes vmware-tanzu#7519 Signed-off-by: Swanand Shende <sshende@catalogicsoftware.com>
Thanks. Accept this suggestion Co-authored-by: Tiger Kaovilai <passawit.kaovilai@gmail.com> Signed-off-by: sshende-catalogicsoftware <66183996+sshende-catalogicsoftware@users.noreply.github.com>
Thanks. Accept this suggestion as well. Co-authored-by: Tiger Kaovilai <passawit.kaovilai@gmail.com> Signed-off-by: sshende-catalogicsoftware <66183996+sshende-catalogicsoftware@users.noreply.github.com>
@kaovilai , Thanks for the suggestions! I've updated both comments to be clearer: Please let me know if you'd like to see any other improvements! |
resourceClient, | ||
) | ||
|
||
// Fall back to manual label/annotation update if the patch fails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fallback necessary? In what case the patch will fail but the update will succeed?
if groupResource == kuberesource.Namespaces { | ||
if existingNamespaces.Has(targetNS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make condition like
if existingNamespaces.Has(targetNS) && velerov1api.PolicyTypeUpdate == ctx.restore.Spec.ExistingResourcePolicy {...}
and ignore printing the "Skipping ...." log message.
@@ -2243,7 +2325,9 @@ func (ctx *restoreContext) getOrderedResourceCollection( | |||
continue | |||
} | |||
|
|||
if namespace == "" && !boolptr.IsSetToTrue(ctx.restore.Spec.IncludeClusterResources) && !ctx.namespaceIncludesExcludes.IncludeEverything() { | |||
if groupResource.Resource == "namespaces" { | |||
ctx.log.Infof("Including resource namespaces despite being cluster-scoped") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this log message needed?
It can also be confusing if ctx.restore.Spec.IncludeClusterResources
is set to true
@@ -0,0 +1,7 @@ | |||
kind: bug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is trivial but conventionally the changelog is a one-liner, otherwise the format of the combined changelogs may be inconsistent.
Description
This PR fixes #7519 where namespace metadata (labels and annotations) from backup bundles was not being restored even when
--existing-resource-policy
was set to "update".Fix Details
The fix adds logic to:
Testing Done
--existing-resource-policy=update
Related PRs or Issues
Reviewer Instructions
Please pay special attention to:
Please indicate you've done the following:
make new-changelog
) or comment/kind changelog-not-required
on this PR.site/content/docs/main
. ==> Not Applicable. No documentation updates needed.