Skip to content
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

Can not update a namespace even if ExistingResourcePolicy is set to "update" #7519

Open
27149chen opened this issue Mar 14, 2024 · 2 comments · May be fixed by #8607
Open

Can not update a namespace even if ExistingResourcePolicy is set to "update" #7519

27149chen opened this issue Mar 14, 2024 · 2 comments · May be fixed by #8607

Comments

@27149chen
Copy link
Contributor

What steps did you take and what happened:

  1. backup a namespace
  2. restore it to another cluster (namespace is already existing) while setting ExistingResourcePolicy to "update"
  3. namespace labels is not updated

What did you expect to happen:

namespace labels is updated

The following information will help us better understand what's going on:

If you are using velero v1.7.0+:
Please use velero debug --backup <backupname> --restore <restorename> to generate the support bundle, and attach to this issue, more options please refer to velero debug --help

If you are using earlier versions:
Please provide the output of the following commands (Pasting long output into a GitHub gist or other pastebin is fine.)

  • kubectl logs deployment/velero -n velero
  • velero backup describe <backupname> or kubectl get backup/<backupname> -n velero -o yaml
  • velero backup logs <backupname>
  • velero restore describe <restorename> or kubectl get restore/<restorename> -n velero -o yaml
  • velero restore logs <restorename>

Anything else you would like to add:

Environment:

  • Velero version (use velero version):
  • Velero features (use velero client config get features):
  • Kubernetes version (use kubectl version):
  • Kubernetes installer & version:
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

  • 👍 for "I would like to see this bug fixed as soon as possible"
  • 👎 for "There are more important bugs to focus on right now"
@sshende-catalogicsoftware
Copy link

sshende-catalogicsoftware commented Jan 13, 2025

Root Cause Analysis

I've identified the root cause of this issue in the processSelectedResource function in pkg/restore/restore.go. Currently, when processing namespace resources, the code simply continues without checking the backup bundle:

velero/pkg/restore/restore.go:

if groupResource == kuberesource.Namespaces {
    continue
}

@sshende-catalogicsoftware

This means that even when --existing-resource-policy=update is specified, namespace metadata (labels/annotations) from the backup bundle is not restored.

Proposed Fix
I've implemented a fix that:

  • Checks if the namespace exists and if existingResourcePolicy is "update"
  • Retrieves the namespace definition from the backup bundle
  • Attempts to patch the existing namespace with backup metadata
  • Includes a fallback mechanism for manual label/annotation updates if patching fails

The fix ensures namespace metadata is properly restored while maintaining backward compatibility.

I'll be submitting a PR with these changes shortly.

sshende-catalogicsoftware added a commit to catalogicsoftware/velero that referenced this issue Jan 13, 2025
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
sshende-catalogicsoftware added a commit to catalogicsoftware/velero that referenced this issue Jan 13, 2025
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants