Skip to content

Commit

Permalink
Merge pull request #7772 from Lyndon-Li/issue-fix-7535
Browse files Browse the repository at this point in the history
Issue fix 7535: don't skip must have resources for label selector
  • Loading branch information
ywk253100 authored May 8, 2024
2 parents 43d1568 + 55f47c8 commit 0d85a64
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2303,29 +2303,31 @@ func (ctx *restoreContext) getSelectedRestoreableItems(resource string, original
continue
}

if !ctx.selector.Matches(labels.Set(obj.GetLabels())) {
continue
}

// Processing OrLabelSelectors when specified in the restore request. LabelSelectors as well as OrLabelSelectors
// cannot co-exist, only one of them can be specified
var skipItem = false
var skip = 0
ctx.log.Debugf("orSelectors specified: %s for item: %s", ctx.OrSelectors, item)
for _, s := range ctx.OrSelectors {
if !s.Matches(labels.Set(obj.GetLabels())) {
skip++
if !ctx.resourceMustHave.Has(resource) {
if !ctx.selector.Matches(labels.Set(obj.GetLabels())) {
continue
}

if len(ctx.OrSelectors) == skip && skip > 0 {
ctx.log.Infof("setting skip flag to true for item: %s", item)
skipItem = true
// Processing OrLabelSelectors when specified in the restore request. LabelSelectors as well as OrLabelSelectors
// cannot co-exist, only one of them can be specified
var skipItem = false
var skip = 0
ctx.log.Debugf("orSelectors specified: %s for item: %s", ctx.OrSelectors, item)
for _, s := range ctx.OrSelectors {
if !s.Matches(labels.Set(obj.GetLabels())) {
skip++
}

if len(ctx.OrSelectors) == skip && skip > 0 {
ctx.log.Infof("setting skip flag to true for item: %s", item)
skipItem = true
}
}
}

if skipItem {
ctx.log.Infof("restore orSelector labels did not match, skipping restore of item: %s", skipItem, item)
continue
if skipItem {
ctx.log.Infof("restore orSelector labels did not match, skipping restore of item: %s", skipItem, item)
continue
}
}

selectedItem := restoreableItem{
Expand Down

0 comments on commit 0d85a64

Please sign in to comment.