Skip to content

Commit faf832b

Browse files
committed
Use v1beta2 VolumeGroupSnapshot API instead of v1beta1
This commit has just the minimal changes to make the code use the new API. The new fields are not yet set.
1 parent 67d2939 commit faf832b

File tree

15 files changed

+212
-212
lines changed

15 files changed

+212
-212
lines changed

cmd/csi-snapshotter/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ func main() {
296296
*extraCreateMetadata,
297297
workqueue.NewTypedItemExponentialFailureRateLimiter[string](*retryIntervalStart, *retryIntervalMax),
298298
utilfeature.DefaultFeatureGate.Enabled(features.VolumeGroupSnapshot),
299-
snapshotContentfactory.Groupsnapshot().V1beta1().VolumeGroupSnapshotContents(),
300-
snapshotContentfactory.Groupsnapshot().V1beta1().VolumeGroupSnapshotClasses(),
299+
snapshotContentfactory.Groupsnapshot().V1beta2().VolumeGroupSnapshotContents(),
300+
snapshotContentfactory.Groupsnapshot().V1beta2().VolumeGroupSnapshotClasses(),
301301
workqueue.NewTypedItemExponentialFailureRateLimiter[string](*retryIntervalStart, *retryIntervalMax),
302302
)
303303

cmd/snapshot-controller/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,20 @@ func ensureCustomResourceDefinitionsExist(client *clientset.Clientset, enableVol
115115
return false, nil
116116
}
117117
if enableVolumeGroupSnapshots {
118-
_, err = client.GroupsnapshotV1beta1().VolumeGroupSnapshots("").List(ctx, listOptions)
118+
_, err = client.GroupsnapshotV1beta2().VolumeGroupSnapshots("").List(ctx, listOptions)
119119
if err != nil {
120-
klog.Errorf("Failed to list v1beta1 volumegroupsnapshots with error=%+v", err)
120+
klog.Errorf("Failed to list v1beta2 volumegroupsnapshots with error=%+v", err)
121121
return false, nil
122122
}
123123

124-
_, err = client.GroupsnapshotV1beta1().VolumeGroupSnapshotClasses().List(ctx, listOptions)
124+
_, err = client.GroupsnapshotV1beta2().VolumeGroupSnapshotClasses().List(ctx, listOptions)
125125
if err != nil {
126-
klog.Errorf("Failed to list v1beta1 volumegroupsnapshotclasses with error=%+v", err)
126+
klog.Errorf("Failed to list v1beta2 volumegroupsnapshotclasses with error=%+v", err)
127127
return false, nil
128128
}
129-
_, err = client.GroupsnapshotV1beta1().VolumeGroupSnapshotContents().List(ctx, listOptions)
129+
_, err = client.GroupsnapshotV1beta2().VolumeGroupSnapshotContents().List(ctx, listOptions)
130130
if err != nil {
131-
klog.Errorf("Failed to list v1beta1 volumegroupsnapshotcontents with error=%+v", err)
131+
klog.Errorf("Failed to list v1beta2 volumegroupsnapshotcontents with error=%+v", err)
132132
return false, nil
133133
}
134134
}
@@ -237,9 +237,9 @@ func main() {
237237
factory.Snapshot().V1().VolumeSnapshots(),
238238
factory.Snapshot().V1().VolumeSnapshotContents(),
239239
factory.Snapshot().V1().VolumeSnapshotClasses(),
240-
factory.Groupsnapshot().V1beta1().VolumeGroupSnapshots(),
241-
factory.Groupsnapshot().V1beta1().VolumeGroupSnapshotContents(),
242-
factory.Groupsnapshot().V1beta1().VolumeGroupSnapshotClasses(),
240+
factory.Groupsnapshot().V1beta2().VolumeGroupSnapshots(),
241+
factory.Groupsnapshot().V1beta2().VolumeGroupSnapshotContents(),
242+
factory.Groupsnapshot().V1beta2().VolumeGroupSnapshotClasses(),
243243
coreFactory.Core().V1().PersistentVolumeClaims(),
244244
coreFactory.Core().V1().PersistentVolumes(),
245245
nodeInformer,

pkg/common-controller/framework_test.go

Lines changed: 47 additions & 47 deletions
Large diffs are not rendered by default.

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 61 additions & 61 deletions
Large diffs are not rendered by default.

pkg/common-controller/groupsnapshot_create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ package common_controller
1919
import (
2020
"testing"
2121

22-
crdv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1"
22+
crdv1beta2 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta2"
2323
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
2424
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/utils"
2525
v1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
)
2828

29-
var groupSnapshotClasses = []*crdv1beta1.VolumeGroupSnapshotClass{
29+
var groupSnapshotClasses = []*crdv1beta2.VolumeGroupSnapshotClass{
3030
{
3131
TypeMeta: metav1.TypeMeta{
3232
Kind: "VolumeGroupSnapshotClass",

pkg/common-controller/snapshot_controller_base.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"fmt"
2222
"time"
2323

24-
crdv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1"
24+
crdv1beta2 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta2"
2525
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
2626
clientset "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
27-
groupsnapshotinformers "github.com/kubernetes-csi/external-snapshotter/client/v8/informers/externalversions/volumegroupsnapshot/v1beta1"
27+
groupsnapshotinformers "github.com/kubernetes-csi/external-snapshotter/client/v8/informers/externalversions/volumegroupsnapshot/v1beta2"
2828
snapshotinformers "github.com/kubernetes-csi/external-snapshotter/client/v8/informers/externalversions/volumesnapshot/v1"
29-
groupsnapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v8/listers/volumegroupsnapshot/v1beta1"
29+
groupsnapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v8/listers/volumegroupsnapshot/v1beta2"
3030
snapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v8/listers/volumesnapshot/v1"
3131
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/metrics"
3232
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/utils"
@@ -658,7 +658,7 @@ func (ctrl *csiSnapshotCommonController) enqueueGroupSnapshotWork(obj interface{
658658
if unknown, ok := obj.(cache.DeletedFinalStateUnknown); ok && unknown.Obj != nil {
659659
obj = unknown.Obj
660660
}
661-
if groupSnapshot, ok := obj.(*crdv1beta1.VolumeGroupSnapshot); ok {
661+
if groupSnapshot, ok := obj.(*crdv1beta2.VolumeGroupSnapshot); ok {
662662
objName, err := cache.DeletionHandlingMetaNamespaceKeyFunc(groupSnapshot)
663663
if err != nil {
664664
klog.Errorf("failed to get key from object: %v, %v", err, groupSnapshot)
@@ -675,7 +675,7 @@ func (ctrl *csiSnapshotCommonController) enqueueGroupSnapshotContentWork(obj int
675675
if unknown, ok := obj.(cache.DeletedFinalStateUnknown); ok && unknown.Obj != nil {
676676
obj = unknown.Obj
677677
}
678-
if content, ok := obj.(*crdv1beta1.VolumeGroupSnapshotContent); ok {
678+
if content, ok := obj.(*crdv1beta2.VolumeGroupSnapshotContent); ok {
679679
objName, err := cache.DeletionHandlingMetaNamespaceKeyFunc(content)
680680
if err != nil {
681681
klog.Errorf("failed to get key from object: %v, %v", err, content)
@@ -769,7 +769,7 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshotByKey(ctx context.Cont
769769
klog.V(2).Infof("deletion of group snapshot %q was already processed", key)
770770
return nil
771771
}
772-
groupSnapshot, ok := vgsObj.(*crdv1beta1.VolumeGroupSnapshot)
772+
groupSnapshot, ok := vgsObj.(*crdv1beta2.VolumeGroupSnapshot)
773773
if !ok {
774774
klog.Errorf("expected vgs, got %+v", vgsObj)
775775
return nil
@@ -785,9 +785,9 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshotByKey(ctx context.Cont
785785
// If it is not set, gets it from default VolumeGroupSnapshotClass and sets it.
786786
// On error, it must return the original group snapshot, not nil, because the caller
787787
// syncGroupSnapshotByKey needs to check group snapshot's timestamp.
788-
func (ctrl *csiSnapshotCommonController) checkAndUpdateGroupSnapshotClass(groupSnapshot *crdv1beta1.VolumeGroupSnapshot) (*crdv1beta1.VolumeGroupSnapshot, error) {
788+
func (ctrl *csiSnapshotCommonController) checkAndUpdateGroupSnapshotClass(groupSnapshot *crdv1beta2.VolumeGroupSnapshot) (*crdv1beta2.VolumeGroupSnapshot, error) {
789789
className := groupSnapshot.Spec.VolumeGroupSnapshotClassName
790-
var class *crdv1beta1.VolumeGroupSnapshotClass
790+
var class *crdv1beta2.VolumeGroupSnapshotClass
791791
var err error
792792
newGroupSnapshot := groupSnapshot
793793
if className != nil {
@@ -849,7 +849,7 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshotContentByKey(key strin
849849
klog.V(2).Infof("deletion of group snapshot content %q was already processed", key)
850850
return nil
851851
}
852-
content, ok := contentObj.(*crdv1beta1.VolumeGroupSnapshotContent)
852+
content, ok := contentObj.(*crdv1beta2.VolumeGroupSnapshotContent)
853853
if !ok {
854854
klog.Errorf("expected group snapshot content, got %+v", content)
855855
return nil
@@ -860,7 +860,7 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshotContentByKey(key strin
860860

861861
// updateGroupSnapshotContent runs in worker thread and handles "groupsnapshotcontent added",
862862
// "groupsnapshotcontent updated" and "periodic sync" events.
863-
func (ctrl *csiSnapshotCommonController) updateGroupSnapshotContent(content *crdv1beta1.VolumeGroupSnapshotContent) error {
863+
func (ctrl *csiSnapshotCommonController) updateGroupSnapshotContent(content *crdv1beta2.VolumeGroupSnapshotContent) error {
864864
// Store the new group snapshot content version in the cache and do not process
865865
// it if this is an old version.
866866
new, err := ctrl.storeGroupSnapshotContentUpdate(content)
@@ -885,7 +885,7 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotContent(content *crd
885885
}
886886

887887
// deleteGroupSnapshotContent runs in worker thread and handles "groupsnapshotcontent deleted" event.
888-
func (ctrl *csiSnapshotCommonController) deleteGroupSnapshotContent(content *crdv1beta1.VolumeGroupSnapshotContent) {
888+
func (ctrl *csiSnapshotCommonController) deleteGroupSnapshotContent(content *crdv1beta2.VolumeGroupSnapshotContent) {
889889
_ = ctrl.groupSnapshotContentStore.Delete(content)
890890
klog.V(4).Infof("group snapshot content %q deleted", content.Name)
891891

pkg/sidecar-controller/csi_handler.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"time"
2424

2525
"github.com/container-storage-interface/spec/lib/go/csi"
26-
crdv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1"
26+
crdv1beta2 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta2"
2727
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/group_snapshotter"
2828

2929
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
@@ -35,9 +35,9 @@ type Handler interface {
3535
CreateSnapshot(content *crdv1.VolumeSnapshotContent, parameters map[string]string, snapshotterCredentials map[string]string) (string, string, time.Time, int64, bool, error)
3636
DeleteSnapshot(content *crdv1.VolumeSnapshotContent, snapshotterCredentials map[string]string) error
3737
GetSnapshotStatus(content *crdv1.VolumeSnapshotContent, snapshotterListCredentials map[string]string) (bool, time.Time, int64, string, error)
38-
CreateGroupSnapshot(content *crdv1beta1.VolumeGroupSnapshotContent, parameters map[string]string, snapshotterCredentials map[string]string) (string, string, []*csi.Snapshot, time.Time, bool, error)
39-
GetGroupSnapshotStatus(groupSnapshotContent *crdv1beta1.VolumeGroupSnapshotContent, snapshotIDs []string, snapshotterCredentials map[string]string) (bool, time.Time, error)
40-
DeleteGroupSnapshot(content *crdv1beta1.VolumeGroupSnapshotContent, SnapshotID []string, snapshotterCredentials map[string]string) error
38+
CreateGroupSnapshot(content *crdv1beta2.VolumeGroupSnapshotContent, parameters map[string]string, snapshotterCredentials map[string]string) (string, string, []*csi.Snapshot, time.Time, bool, error)
39+
GetGroupSnapshotStatus(groupSnapshotContent *crdv1beta2.VolumeGroupSnapshotContent, snapshotIDs []string, snapshotterCredentials map[string]string) (bool, time.Time, error)
40+
DeleteGroupSnapshot(content *crdv1beta2.VolumeGroupSnapshotContent, SnapshotID []string, snapshotterCredentials map[string]string) error
4141
}
4242

4343
// csiHandler is a handler that calls CSI to create/delete volume snapshot.
@@ -148,7 +148,7 @@ func makeSnapshotName(prefix, snapshotUID string, snapshotNameUUIDLength int) (s
148148
return fmt.Sprintf("%s-%s", prefix, strings.Replace(snapshotUID, "-", "", -1)[0:snapshotNameUUIDLength]), nil
149149
}
150150

151-
func (handler *csiHandler) CreateGroupSnapshot(content *crdv1beta1.VolumeGroupSnapshotContent, parameters map[string]string, snapshotterCredentials map[string]string) (string, string, []*csi.Snapshot, time.Time, bool, error) {
151+
func (handler *csiHandler) CreateGroupSnapshot(content *crdv1beta2.VolumeGroupSnapshotContent, parameters map[string]string, snapshotterCredentials map[string]string) (string, string, []*csi.Snapshot, time.Time, bool, error) {
152152
ctx, cancel := context.WithTimeout(context.Background(), handler.timeout)
153153
defer cancel()
154154

@@ -167,7 +167,7 @@ func (handler *csiHandler) CreateGroupSnapshot(content *crdv1beta1.VolumeGroupSn
167167
return handler.groupSnapshotter.CreateGroupSnapshot(ctx, groupSnapshotName, content.Spec.Source.VolumeHandles, parameters, snapshotterCredentials)
168168
}
169169

170-
func (handler *csiHandler) DeleteGroupSnapshot(content *crdv1beta1.VolumeGroupSnapshotContent, snapshotIDs []string, snapshotterCredentials map[string]string) error {
170+
func (handler *csiHandler) DeleteGroupSnapshot(content *crdv1beta2.VolumeGroupSnapshotContent, snapshotIDs []string, snapshotterCredentials map[string]string) error {
171171
ctx, cancel := context.WithTimeout(context.Background(), handler.timeout)
172172
defer cancel()
173173

@@ -188,7 +188,7 @@ func (handler *csiHandler) DeleteGroupSnapshot(content *crdv1beta1.VolumeGroupSn
188188
return handler.groupSnapshotter.DeleteGroupSnapshot(ctx, groupSnapshotHandle, snapshotIDs, snapshotterCredentials)
189189
}
190190

191-
func (handler *csiHandler) GetGroupSnapshotStatus(content *crdv1beta1.VolumeGroupSnapshotContent, snapshotIDs []string, snapshotterCredentials map[string]string) (bool, time.Time, error) {
191+
func (handler *csiHandler) GetGroupSnapshotStatus(content *crdv1beta2.VolumeGroupSnapshotContent, snapshotIDs []string, snapshotterCredentials map[string]string) (bool, time.Time, error) {
192192
ctx, cancel := context.WithTimeout(context.Background(), handler.timeout)
193193
defer cancel()
194194

pkg/sidecar-controller/framework_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ func newTestController(kubeClient kubernetes.Interface, clientset clientset.Inte
577577
true,
578578
workqueue.NewTypedItemExponentialFailureRateLimiter[string](1*time.Millisecond, 1*time.Minute),
579579
false,
580-
informerFactory.Groupsnapshot().V1beta1().VolumeGroupSnapshotContents(),
581-
informerFactory.Groupsnapshot().V1beta1().VolumeGroupSnapshotClasses(),
580+
informerFactory.Groupsnapshot().V1beta2().VolumeGroupSnapshotContents(),
581+
informerFactory.Groupsnapshot().V1beta2().VolumeGroupSnapshotClasses(),
582582
workqueue.NewTypedItemExponentialFailureRateLimiter[string](1*time.Millisecond, 1*time.Minute),
583583
)
584584

0 commit comments

Comments
 (0)