Skip to content
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/8924-blackpiglet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add VolumeSnapshotContent into the RIA and the mustHave resource list.
16 changes: 15 additions & 1 deletion pkg/restore/actions/csi/volumesnapshot_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package csi

import (
"fmt"

snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand All @@ -26,6 +28,7 @@ import (

velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/client"
"github.com/vmware-tanzu/velero/pkg/kuberesource"
plugincommon "github.com/vmware-tanzu/velero/pkg/plugin/framework/common"
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
"github.com/vmware-tanzu/velero/pkg/util"
Expand Down Expand Up @@ -106,12 +109,23 @@ func (p *volumeSnapshotRestoreItemAction) Execute(
return nil, errors.WithStack(err)
}

if vsFromBackup.Status == nil ||
vsFromBackup.Status.BoundVolumeSnapshotContentName == nil {
p.log.Errorf("VS %s doesn't have bound VSC", vsFromBackup.Name)
return nil, fmt.Errorf("VS %s doesn't have bound VSC", vsFromBackup.Name)
}

vsc := velero.ResourceIdentifier{
GroupResource: kuberesource.VolumeSnapshotContents,
Name: *vsFromBackup.Status.BoundVolumeSnapshotContentName,
}

p.log.Infof(`Returning from VolumeSnapshotRestoreItemAction with
no additionalItems`)

return &velero.RestoreItemActionExecuteOutput{
UpdatedItem: &unstructured.Unstructured{Object: vsMap},
AdditionalItems: []velero.ResourceIdentifier{},
AdditionalItems: []velero.ResourceIdentifier{vsc},
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const ObjectStatusRestoreAnnotationKey = "velero.io/restore-status"

var resourceMustHave = []string{
"datauploads.velero.io",
"volumesnapshotcontents.snapshot.storage.k8s.io",
}

type VolumeSnapshotterGetter interface {
Expand Down
Loading