@@ -17,6 +17,8 @@ limitations under the License.
1717package csi
1818
1919import (
20+ "fmt"
21+
2022 snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
2123 "github.com/pkg/errors"
2224 "github.com/sirupsen/logrus"
@@ -26,6 +28,7 @@ import (
2628
2729 velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
2830 "github.com/vmware-tanzu/velero/pkg/client"
31+ "github.com/vmware-tanzu/velero/pkg/kuberesource"
2932 plugincommon "github.com/vmware-tanzu/velero/pkg/plugin/framework/common"
3033 "github.com/vmware-tanzu/velero/pkg/plugin/velero"
3134 "github.com/vmware-tanzu/velero/pkg/util"
@@ -106,12 +109,23 @@ func (p *volumeSnapshotRestoreItemAction) Execute(
106109 return nil , errors .WithStack (err )
107110 }
108111
112+ if vsFromBackup .Status == nil ||
113+ vsFromBackup .Status .BoundVolumeSnapshotContentName == nil {
114+ p .log .Errorf ("VS %s doesn't have bound VSC" , vsFromBackup .Name )
115+ return nil , fmt .Errorf ("VS %s doesn't have bound VSC" , vsFromBackup .Name )
116+ }
117+
118+ vsc := velero.ResourceIdentifier {
119+ GroupResource : kuberesource .VolumeSnapshotContents ,
120+ Name : * vsFromBackup .Status .BoundVolumeSnapshotContentName ,
121+ }
122+
109123 p .log .Infof (`Returning from VolumeSnapshotRestoreItemAction with
110124 no additionalItems` )
111125
112126 return & velero.RestoreItemActionExecuteOutput {
113127 UpdatedItem : & unstructured.Unstructured {Object : vsMap },
114- AdditionalItems : []velero.ResourceIdentifier {},
128+ AdditionalItems : []velero.ResourceIdentifier {vsc },
115129 }, nil
116130}
117131
0 commit comments