Skip to content

Commit

Permalink
fix issue 6709 (#6741)
Browse files Browse the repository at this point in the history
Signed-off-by: Lyndon-Li <[email protected]>
  • Loading branch information
Lyndon-Li authored Sep 1, 2023
1 parent f26ec90 commit 1615cfd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ import (
"github.com/vmware-tanzu/velero/pkg/volume"
)

var resourceMustHave = []string{
"datauploads.velero.io",
}

type VolumeSnapshotterGetter interface {
GetVolumeSnapshotter(name string) (vsv1.VolumeSnapshotter, error)
}
Expand Down Expand Up @@ -276,6 +280,7 @@ func (kr *kubernetesRestorer) RestoreWithResolvers(
resourceIncludesExcludes: resourceIncludesExcludes,
resourceStatusIncludesExcludes: restoreStatusIncludesExcludes,
namespaceIncludesExcludes: namespaceIncludesExcludes,
resourceMustHave: sets.NewString(resourceMustHave...),
chosenGrpVersToRestore: make(map[string]ChosenGroupVersion),
selector: selector,
OrSelectors: OrSelectors,
Expand Down Expand Up @@ -320,6 +325,7 @@ type restoreContext struct {
resourceIncludesExcludes *collections.IncludesExcludes
resourceStatusIncludesExcludes *collections.IncludesExcludes
namespaceIncludesExcludes *collections.IncludesExcludes
resourceMustHave sets.String
chosenGrpVersToRestore map[string]ChosenGroupVersion
selector labels.Selector
OrSelectors []labels.Selector
Expand Down Expand Up @@ -989,7 +995,7 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
// via obj.GetNamespace()) instead of the namespace parameter, because we want
// to check the *original* namespace, not the remapped one if it's been remapped.
if namespace != "" {
if !ctx.namespaceIncludesExcludes.ShouldInclude(obj.GetNamespace()) {
if !ctx.namespaceIncludesExcludes.ShouldInclude(obj.GetNamespace()) && !ctx.resourceMustHave.Has(groupResource.String()) {
ctx.log.WithFields(logrus.Fields{
"namespace": obj.GetNamespace(),
"name": obj.GetName(),
Expand Down Expand Up @@ -2016,7 +2022,7 @@ func (ctx *restoreContext) getOrderedResourceCollection(
// Iterate through each namespace that contains instances of the
// resource and append to the list of to-be restored resources.
for namespace, items := range resourceList.ItemsByNamespace {
if namespace != "" && !ctx.namespaceIncludesExcludes.ShouldInclude(namespace) {
if namespace != "" && !ctx.namespaceIncludesExcludes.ShouldInclude(namespace) && !ctx.resourceMustHave.Has(groupResource.String()) {
ctx.log.Infof("Skipping namespace %s", namespace)
continue
}
Expand Down

0 comments on commit 1615cfd

Please sign in to comment.