@@ -22,7 +22,7 @@ import (
22
22
"github.com/pkg/errors"
23
23
"github.com/sirupsen/logrus"
24
24
25
- snapshotv1beta1api "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1beta1 "
25
+ snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1 "
26
26
core_v1 "k8s.io/api/core/v1"
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
28
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -47,7 +47,7 @@ func (p *VolumeSnapshotRestoreItemAction) AppliesTo() (velero.ResourceSelector,
47
47
}, nil
48
48
}
49
49
50
- func resetVolumeSnapshotSpecForRestore (vs * snapshotv1beta1api .VolumeSnapshot , vscName * string ) {
50
+ func resetVolumeSnapshotSpecForRestore (vs * snapshotv1api .VolumeSnapshot , vscName * string ) {
51
51
// Spec of the backed-up object used the PVC as the source of the volumeSnapshot.
52
52
// Restore operation will however, restore the volumesnapshot from the volumesnapshotcontent
53
53
vs .Spec .Source .PersistentVolumeClaimName = nil
@@ -58,7 +58,7 @@ func resetVolumeSnapshotSpecForRestore(vs *snapshotv1beta1api.VolumeSnapshot, vs
58
58
// to recreate a volumesnapshotcontent object and statically bind the Volumesnapshot object being restored.
59
59
func (p * VolumeSnapshotRestoreItemAction ) Execute (input * velero.RestoreItemActionExecuteInput ) (* velero.RestoreItemActionExecuteOutput , error ) {
60
60
p .Log .Info ("Starting VolumeSnapshotRestoreItemAction" )
61
- var vs snapshotv1beta1api .VolumeSnapshot
61
+ var vs snapshotv1api .VolumeSnapshot
62
62
63
63
if err := runtime .DefaultUnstructuredConverter .FromUnstructured (input .Item .UnstructuredContent (), & vs ); err != nil {
64
64
return & velero.RestoreItemActionExecuteOutput {}, errors .Wrapf (err , "failed to convert input.Item from unstructured" )
@@ -75,7 +75,7 @@ func (p *VolumeSnapshotRestoreItemAction) Execute(input *velero.RestoreItemActio
75
75
return nil , errors .WithStack (err )
76
76
}
77
77
78
- if ! util .IsVolumeSnapshotExists (& vs , snapClient .SnapshotV1beta1 ()) {
78
+ if ! util .IsVolumeSnapshotExists (& vs , snapClient .SnapshotV1 ()) {
79
79
snapHandle , exists := vs .Annotations [util .VolumeSnapshotHandleAnnotation ]
80
80
if ! exists {
81
81
return nil , errors .Errorf ("Volumesnapshot %s/%s does not have a %s annotation" , vs .Namespace , vs .Name , util .VolumeSnapshotHandleAnnotation )
@@ -90,26 +90,26 @@ func (p *VolumeSnapshotRestoreItemAction) Execute(input *velero.RestoreItemActio
90
90
if ! exists {
91
91
p .Log .Infof ("Volumesnapshot %s/%s does not have a %s annotation using DeletionPolicy Retain for volumesnapshotcontent" ,
92
92
vs .Namespace , vs .Name , util .CSIVSCDeletionPolicy )
93
- deletionPolicy = string (snapshotv1beta1api .VolumeSnapshotContentRetain )
93
+ deletionPolicy = string (snapshotv1api .VolumeSnapshotContentRetain )
94
94
}
95
95
96
96
// TODO: generated name will be like velero-velero-something. Fix that.
97
- vsc := snapshotv1beta1api .VolumeSnapshotContent {
97
+ vsc := snapshotv1api .VolumeSnapshotContent {
98
98
ObjectMeta : metav1.ObjectMeta {
99
99
GenerateName : "velero-" + vs .Name + "-" ,
100
100
Labels : map [string ]string {
101
101
velerov1api .RestoreNameLabel : label .GetValidName (input .Restore .Name ),
102
102
},
103
103
},
104
- Spec : snapshotv1beta1api .VolumeSnapshotContentSpec {
105
- DeletionPolicy : snapshotv1beta1api .DeletionPolicy (deletionPolicy ),
104
+ Spec : snapshotv1api .VolumeSnapshotContentSpec {
105
+ DeletionPolicy : snapshotv1api .DeletionPolicy (deletionPolicy ),
106
106
Driver : csiDriverName ,
107
107
VolumeSnapshotRef : core_v1.ObjectReference {
108
108
Kind : "VolumeSnapshot" ,
109
109
Namespace : vs .Namespace ,
110
110
Name : vs .Name ,
111
111
},
112
- Source : snapshotv1beta1api .VolumeSnapshotContentSource {
112
+ Source : snapshotv1api .VolumeSnapshotContentSource {
113
113
SnapshotHandle : & snapHandle ,
114
114
},
115
115
},
@@ -121,7 +121,7 @@ func (p *VolumeSnapshotRestoreItemAction) Execute(input *velero.RestoreItemActio
121
121
// between the volumesnapshotcontent and volumesnapshot objects have to be setup.
122
122
// Further, it is disallowed to convert a dynamically created volumesnapshotcontent for static binding.
123
123
// See: https://github.com/kubernetes-csi/external-snapshotter/issues/274
124
- vscupd , err := snapClient .SnapshotV1beta1 ().VolumeSnapshotContents ().Create (context .TODO (), & vsc , metav1.CreateOptions {})
124
+ vscupd , err := snapClient .SnapshotV1 ().VolumeSnapshotContents ().Create (context .TODO (), & vsc , metav1.CreateOptions {})
125
125
if err != nil {
126
126
return nil , errors .Wrapf (err , "failed to create volumesnapshotcontents %s" , vsc .GenerateName )
127
127
}
0 commit comments