Skip to content

Commit

Permalink
Merge pull request #7586 from Lyndon-Li/release-1.13
Browse files Browse the repository at this point in the history
[1.13] Issue 7535: add the MustHave resource check during item collection and item filter for restore
  • Loading branch information
qiuming-best authored Mar 29, 2024
2 parents 4142722 + 6bcd5be commit 9f9464c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/7586-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
4 changes: 2 additions & 2 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,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 @@ -2198,7 +2198,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

0 comments on commit 9f9464c

Please sign in to comment.