@@ -31,7 +31,7 @@ import (
3131 ref "k8s.io/client-go/tools/reference"
3232 klog "k8s.io/klog/v2"
3333
34- crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v3/apis/volumesnapshot/v1beta1 "
34+ crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v3/apis/volumesnapshot/v1 "
3535 "github.com/kubernetes-csi/external-snapshotter/v3/pkg/metrics"
3636 "github.com/kubernetes-csi/external-snapshotter/v3/pkg/utils"
3737)
@@ -321,7 +321,7 @@ func (ctrl *csiSnapshotCommonController) checkandRemoveSnapshotFinalizersAndChec
321321 // content won't be deleted immediately due to the VolumeSnapshotContentFinalizer
322322 if content != nil && deleteContent {
323323 klog .V (5 ).Infof ("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: set DeletionTimeStamp on content [%s]." , content .Name )
324- err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Delete (context .TODO (), content .Name , metav1.DeleteOptions {})
324+ err := ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Delete (context .TODO (), content .Name , metav1.DeleteOptions {})
325325 if err != nil {
326326 ctrl .eventRecorder .Event (snapshot , v1 .EventTypeWarning , "SnapshotContentObjectDeleteError" , "Failed to delete snapshot content API object" )
327327 return fmt .Errorf ("failed to delete VolumeSnapshotContent %s from API server: %q" , content .Name , err )
@@ -682,7 +682,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotContent(snapshot *crdv1.V
682682 klog .V (5 ).Infof ("volume snapshot content %#v" , snapshotContent )
683683 // Try to create the VolumeSnapshotContent object
684684 klog .V (5 ).Infof ("createSnapshotContent [%s]: trying to save volume snapshot content %s" , utils .SnapshotKey (snapshot ), snapshotContent .Name )
685- if updateContent , err = ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Create (context .TODO (), snapshotContent , metav1.CreateOptions {}); err == nil || apierrs .IsAlreadyExists (err ) {
685+ if updateContent , err = ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Create (context .TODO (), snapshotContent , metav1.CreateOptions {}); err == nil || apierrs .IsAlreadyExists (err ) {
686686 // Save succeeded.
687687 if err != nil {
688688 klog .V (3 ).Infof ("volume snapshot content %q for snapshot %q already exists, reusing" , snapshotContent .Name , utils .SnapshotKey (snapshot ))
@@ -780,7 +780,7 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snap
780780 snapshotClone .Status .Error = statusError
781781 ready := false
782782 snapshotClone .Status .ReadyToUse = & ready
783- newSnapshot , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshotClone .Namespace ).UpdateStatus (context .TODO (), snapshotClone , metav1.UpdateOptions {})
783+ newSnapshot , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshotClone .Namespace ).UpdateStatus (context .TODO (), snapshotClone , metav1.UpdateOptions {})
784784
785785 // Emit the event even if the status update fails so that user can see the error
786786 ctrl .eventRecorder .Event (newSnapshot , eventtype , reason , message )
@@ -804,7 +804,7 @@ func (ctrl *csiSnapshotCommonController) addContentFinalizer(content *crdv1.Volu
804804 contentClone := content .DeepCopy ()
805805 contentClone .ObjectMeta .Finalizers = append (contentClone .ObjectMeta .Finalizers , utils .VolumeSnapshotContentFinalizer )
806806
807- _ , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Update (context .TODO (), contentClone , metav1.UpdateOptions {})
807+ _ , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Update (context .TODO (), contentClone , metav1.UpdateOptions {})
808808 if err != nil {
809809 return newControllerUpdateError (content .Name , err .Error ())
810810 }
@@ -981,7 +981,7 @@ func (ctrl *csiSnapshotCommonController) checkandBindSnapshotContent(snapshot *c
981981 className := * (snapshot .Spec .VolumeSnapshotClassName )
982982 contentClone .Spec .VolumeSnapshotClassName = & className
983983 }
984- newContent , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Update (context .TODO (), contentClone , metav1.UpdateOptions {})
984+ newContent , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Update (context .TODO (), contentClone , metav1.UpdateOptions {})
985985 if err != nil {
986986 klog .V (4 ).Infof ("updating VolumeSnapshotContent[%s] error status failed %v" , contentClone .Name , err )
987987 return nil , err
@@ -998,7 +998,7 @@ func (ctrl *csiSnapshotCommonController) checkandBindSnapshotContent(snapshot *c
998998// This routine sets snapshot.Spec.Source.VolumeSnapshotContentName
999999func (ctrl * csiSnapshotCommonController ) bindandUpdateVolumeSnapshot (snapshotContent * crdv1.VolumeSnapshotContent , snapshot * crdv1.VolumeSnapshot ) (* crdv1.VolumeSnapshot , error ) {
10001000 klog .V (5 ).Infof ("bindandUpdateVolumeSnapshot for snapshot [%s]: snapshotContent [%s]" , snapshot .Name , snapshotContent .Name )
1001- snapshotObj , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshot .Namespace ).Get (context .TODO (), snapshot .Name , metav1.GetOptions {})
1001+ snapshotObj , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshot .Namespace ).Get (context .TODO (), snapshot .Name , metav1.GetOptions {})
10021002 if err != nil {
10031003 return nil , fmt .Errorf ("error get snapshot %s from api server: %v" , utils .SnapshotKey (snapshot ), err )
10041004 }
@@ -1086,7 +1086,7 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotStatus(snapshot *crdv1.Vo
10861086
10871087 klog .V (5 ).Infof ("updateSnapshotStatus: updating VolumeSnapshot [%+v] based on VolumeSnapshotContentStatus [%+v]" , snapshot , content .Status )
10881088
1089- snapshotObj , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshot .Namespace ).Get (context .TODO (), snapshot .Name , metav1.GetOptions {})
1089+ snapshotObj , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshot .Namespace ).Get (context .TODO (), snapshot .Name , metav1.GetOptions {})
10901090 if err != nil {
10911091 return nil , fmt .Errorf ("error get snapshot %s from api server: %v" , utils .SnapshotKey (snapshot ), err )
10921092 }
@@ -1157,7 +1157,7 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotStatus(snapshot *crdv1.Vo
11571157 ctrl .metricsManager .RecordMetrics (createAndReadyOperation , metrics .NewSnapshotOperationStatus (metrics .SnapshotStatusTypeSuccess ), driverName )
11581158 }
11591159
1160- newSnapshotObj , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshotClone .Namespace ).UpdateStatus (context .TODO (), snapshotClone , metav1.UpdateOptions {})
1160+ newSnapshotObj , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshotClone .Namespace ).UpdateStatus (context .TODO (), snapshotClone , metav1.UpdateOptions {})
11611161 if err != nil {
11621162 return nil , newControllerUpdateError (utils .SnapshotKey (snapshot ), err .Error ())
11631163 }
@@ -1322,7 +1322,7 @@ func (ctrl *csiSnapshotCommonController) SetDefaultSnapshotClass(snapshot *crdv1
13221322 klog .V (5 ).Infof ("setDefaultSnapshotClass [%s]: default VolumeSnapshotClassName [%s]" , snapshot .Name , defaultClasses [0 ].Name )
13231323 snapshotClone := snapshot .DeepCopy ()
13241324 snapshotClone .Spec .VolumeSnapshotClassName = & (defaultClasses [0 ].Name )
1325- newSnapshot , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshotClone .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
1325+ newSnapshot , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshotClone .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
13261326 if err != nil {
13271327 klog .V (4 ).Infof ("updating VolumeSnapshot[%s] default class failed %v" , utils .SnapshotKey (snapshot ), err )
13281328 }
@@ -1387,7 +1387,7 @@ func (ctrl *csiSnapshotCommonController) addSnapshotFinalizer(snapshot *crdv1.Vo
13871387 if addBoundFinalizer {
13881388 snapshotClone .ObjectMeta .Finalizers = append (snapshotClone .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer )
13891389 }
1390- _ , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshotClone .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
1390+ _ , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshotClone .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
13911391 if err != nil {
13921392 return newControllerUpdateError (utils .SnapshotKey (snapshot ), err .Error ())
13931393 }
@@ -1431,7 +1431,7 @@ func (ctrl *csiSnapshotCommonController) removeSnapshotFinalizer(snapshot *crdv1
14311431 if removeBoundFinalizer {
14321432 snapshotClone .ObjectMeta .Finalizers = utils .RemoveString (snapshotClone .ObjectMeta .Finalizers , utils .VolumeSnapshotBoundFinalizer )
14331433 }
1434- _ , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshotClone .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
1434+ _ , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshotClone .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
14351435 if err != nil {
14361436 return newControllerUpdateError (snapshot .Name , err .Error ())
14371437 }
@@ -1479,7 +1479,7 @@ func (ctrl *csiSnapshotCommonController) setAnnVolumeSnapshotBeingDeleted(conten
14791479 klog .V (5 ).Infof ("setAnnVolumeSnapshotBeingDeleted: set annotation [%s] on content [%s]." , utils .AnnVolumeSnapshotBeingDeleted , content .Name )
14801480 metav1 .SetMetaDataAnnotation (& content .ObjectMeta , utils .AnnVolumeSnapshotBeingDeleted , "yes" )
14811481
1482- updateContent , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Update (context .TODO (), content , metav1.UpdateOptions {})
1482+ updateContent , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Update (context .TODO (), content , metav1.UpdateOptions {})
14831483 if err != nil {
14841484 return newControllerUpdateError (content .Name , err .Error ())
14851485 }
@@ -1499,7 +1499,7 @@ func (ctrl *csiSnapshotCommonController) setAnnVolumeSnapshotBeingDeleted(conten
14991499// checkAndSetInvalidContentLabel adds a label to unlabeled invalid content objects and removes the label from valid ones.
15001500func (ctrl * csiSnapshotCommonController ) checkAndSetInvalidContentLabel (content * crdv1.VolumeSnapshotContent ) (* crdv1.VolumeSnapshotContent , error ) {
15011501 hasLabel := utils .MapContainsKey (content .ObjectMeta .Labels , utils .VolumeSnapshotContentInvalidLabel )
1502- err := utils .ValidateSnapshotContent (content )
1502+ err := utils .ValidateV1SnapshotContent (content )
15031503 if err != nil {
15041504 klog .Errorf ("syncContent[%s]: Invalid content detected, %s" , content .Name , err .Error ())
15051505 }
@@ -1519,7 +1519,7 @@ func (ctrl *csiSnapshotCommonController) checkAndSetInvalidContentLabel(content
15191519 }
15201520 contentClone .ObjectMeta .Labels [utils .VolumeSnapshotContentInvalidLabel ] = ""
15211521 }
1522- updatedContent , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Update (context .TODO (), contentClone , metav1.UpdateOptions {})
1522+ updatedContent , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Update (context .TODO (), contentClone , metav1.UpdateOptions {})
15231523 if err != nil {
15241524 return content , newControllerUpdateError (content .Name , err .Error ())
15251525 }
@@ -1540,7 +1540,7 @@ func (ctrl *csiSnapshotCommonController) checkAndSetInvalidContentLabel(content
15401540// checkAndSetInvalidSnapshotLabel adds a label to unlabeled invalid snapshot objects and removes the label from valid ones.
15411541func (ctrl * csiSnapshotCommonController ) checkAndSetInvalidSnapshotLabel (snapshot * crdv1.VolumeSnapshot ) (* crdv1.VolumeSnapshot , error ) {
15421542 hasLabel := utils .MapContainsKey (snapshot .ObjectMeta .Labels , utils .VolumeSnapshotInvalidLabel )
1543- err := utils .ValidateSnapshot (snapshot )
1543+ err := utils .ValidateV1Snapshot (snapshot )
15441544 if err != nil {
15451545 klog .Errorf ("syncSnapshot[%s]: Invalid snapshot detected, %s" , utils .SnapshotKey (snapshot ), err .Error ())
15461546 }
@@ -1561,7 +1561,7 @@ func (ctrl *csiSnapshotCommonController) checkAndSetInvalidSnapshotLabel(snapsho
15611561 snapshotClone .ObjectMeta .Labels [utils .VolumeSnapshotInvalidLabel ] = ""
15621562 }
15631563
1564- updatedSnapshot , err := ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshots (snapshot .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
1564+ updatedSnapshot , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (snapshot .Namespace ).Update (context .TODO (), snapshotClone , metav1.UpdateOptions {})
15651565 if err != nil {
15661566 return snapshot , newControllerUpdateError (utils .SnapshotKey (snapshot ), err .Error ())
15671567 }
0 commit comments