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

Issue 7535: add the MustHave resource check during item collection and item filter for restore #7585

Merged
merged 4 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/7585-Lyndon-Li
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue #7535, add the MustHave resource check during item collection and item filter for restore
2 changes: 1 addition & 1 deletion pkg/repository/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestDeleteOldMaintenanceJobs(t *testing.T) {
assert.NoError(t, err)

// We expect the number of jobs to be equal to 'keep'
assert.Equal(t, keep, len(jobList.Items))
assert.Len(t, jobList.Items, keep)

// We expect that the oldest jobs were deleted
// Job3 should not be present in the remaining list
Expand Down
4 changes: 2 additions & 2 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
// Check if group/resource should be restored. We need to do this here since
// this method may be getting called for an additional item which is a group/resource
// that's excluded.
if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) {
if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) && !ctx.resourceMustHave.Has(groupResource.String()) {
restoreLogger.Info("Not restoring item because resource is excluded")
return warnings, errs, itemExists
}
Expand Down Expand Up @@ -2202,7 +2202,7 @@ func (ctx *restoreContext) getOrderedResourceCollection(

// Check if the resource should be restored according to the resource
// includes/excludes.
if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) {
if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) && !ctx.resourceMustHave.Has(groupResource.String()) {
ctx.log.WithField("resource", groupResource.String()).Infof("Skipping restore of resource because the restore spec excludes it")
continue
}
Expand Down
Loading