Skip to content

restore filters via resource policy#9946

Open
adam-jian-zhang wants to merge 4 commits into
velero-io:mainfrom
adam-jian-zhang:restore_filters_via_resource_policy
Open

restore filters via resource policy#9946
adam-jian-zhang wants to merge 4 commits into
velero-io:mainfrom
adam-jian-zhang:restore_filters_via_resource_policy

Conversation

@adam-jian-zhang

@adam-jian-zhang adam-jian-zhang commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

restore filters via resource policy, support ClusterScopedFilterPolicy and NamespaceFilterPolicies.

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #(issue)
#9936

Please indicate you've done the following:

@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

👷 Deploy request for velero pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f3beea8

restore filters via resource policy, support ClusterScopedFilterPolicy
and NamespaceFilterPolicies.

Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
@adam-jian-zhang adam-jian-zhang force-pushed the restore_filters_via_resource_policy branch from a014da0 to b41e5df Compare June 25, 2026 09:10
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.23810% with 75 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/restore/restore.go 67.41% 53 Missing and 20 partials ⚠️
pkg/controller/restore_controller.go 92.85% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@adam-jian-zhang adam-jian-zhang added this to the v1.19 milestone Jun 26, 2026
Comment thread pkg/restore/restore.go
@adam-jian-zhang adam-jian-zhang requested a review from Lyndon-Li July 6, 2026 07:57
Lyndon-Li
Lyndon-Li previously approved these changes Jul 6, 2026
Comment thread pkg/restore/restore.go Outdated
Comment thread pkg/restore/restore.go Outdated
When a user specifies a Custom Resource Kind in a restore filter
policy (e.g., kinds: [MyCustomKind]), the discovery helper fails
to resolve it if the CRD hasn't been restored yet.

This adds a peek-and-map fallback: if a resource type in the
backup tarball doesn't match the resolved filters, Velero peeks
at the actual Kind of the first item in the tarball and matches
it against the user's original policy strings.

Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
Comment thread pkg/restore/restore.go
Comment thread pkg/restore/restore.go
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
@adam-jian-zhang adam-jian-zhang requested a review from kaovilai July 8, 2026 03:53
kaovilai
kaovilai previously approved these changes Jul 8, 2026

@kaovilai kaovilai left a comment

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.

LGTM!

Comment thread pkg/restore/restore.go
Comment thread pkg/restore/restore.go
Comment thread pkg/restore/restore_test.go Outdated
Comment thread pkg/restore/restore_test.go Outdated
Comment thread pkg/controller/restore_controller_test.go Outdated
Comment thread pkg/restore/restore.go
Comment thread pkg/restore/restore.go
- normalized the input to lower case for consistency
- added validations for kind collision
- add flag for unresolved kinds, and defer skip decision base on that
- move peek-and-map test cases to restore_policies_test.go

Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
@adam-jian-zhang

adam-jian-zhang commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @shubham-pampattiwar and @kaovilai for the detailed review, I have addressed all review comments, please take a look again, very appreciated.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants