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

resource label selector not work for cluster scope resources. #5787

Closed
blackpiglet opened this issue Jan 19, 2023 · 4 comments
Closed

resource label selector not work for cluster scope resources. #5787

blackpiglet opened this issue Jan 19, 2023 · 4 comments
Assignees

Comments

@blackpiglet
Copy link
Contributor

Describe the problem/challenge you have
[A description of the current limitation/problem/challenge that you are experiencing.]
When creating a backup, the user can useLabelSelector/OrLabelSelectors to filter resources that should be included, but that rule only works for the namespace scope resource, and not for the cluster scope resource, for example, k8s Deployment resource can be selected by the label selector, but StorageClass cannot.

Describe the solution you'd like
[A clear and concise description of what you want to happen.]
LabelSelector/OrLabelSelectors should also work for cluster scope resources.

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

  • Velero version (use velero version):
  • 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 "The project would be better with this feature added"
  • 👎 for "This feature will not enhance the project in a meaningful way"
@nunojusto
Copy link

This problem happens also for restores when filtering resources with LabelSelector/OrLabelSelectors.
Should I create a new issue or we can use this?

@sseago
Copy link
Collaborator

sseago commented Feb 1, 2023

@nunojusto I think we can probably use this issue to track the fix for both backup and restore. If the fix ends up getting split into two PRs, then it might make sense to create a second issue for restore, but I suspect that it may be easier to fix both together.

@blackpiglet
Copy link
Contributor Author

blackpiglet commented Jul 20, 2023

https://github.com/vmware-tanzu/velero/blob/main/pkg/backup/item_collector.go#L297-L313
https://github.com/vmware-tanzu/velero/blob/main/pkg/restore/restore.go#L937-L953

@nunojusto
I think I made some misunderstanding of how Velero uses the label selector with cluster-scoped resources.
According to the code posted up here, I think the cluster-scoped resources can be filtered by the --selector parameter. My previous misunderstanding was caused by the cluster-scoped resources being filtered out by other filter settings.

Could you also check again whether the --selector and orLabelSelector can work with cluster-scoped resources in your environment?

@reasonerjt
Copy link
Contributor

Moving this out of v1.12 since this seems a non-issue.

@reasonerjt reasonerjt removed this from the v1.12 milestone Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants