Skip to content

Commit a6488a9

Browse files
authored
Merge pull request velero-io#9706 from shubham-pampattiwar/cherry-pick-vgs-v1beta2-release-1.18
[release-1.18] Bump external-snapshotter to v8.4.0 for VGS v1beta2 support
2 parents fd99ed4 + 3336861 commit a6488a9

12 files changed

Lines changed: 116 additions & 115 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump external-snapshotter to v8.4.0 and migrate VolumeGroupSnapshot API from v1beta1 to v1beta2 for Kubernetes 1.34+ compatibility

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/hashicorp/go-plugin v1.6.0
2727
github.com/joho/godotenv v1.3.0
2828
github.com/kopia/kopia v0.16.0
29-
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0
29+
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.4.0
3030
github.com/onsi/ginkgo/v2 v2.22.0
3131
github.com/onsi/gomega v1.36.1
3232
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
507507
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
508508
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
509509
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
510-
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0 h1:Q3jQ1NkFqv5o+F8dMmHd8SfEmlcwNeo1immFApntEwE=
511-
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0/go.mod h1:E3vdYxHj2C2q6qo8/Da4g7P+IcwqRZyy3gJBzYybV9Y=
510+
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.4.0 h1:bMqrb3UHgHbP+PW9VwiejfDJU1R0PpXVZNMdeH8WYKI=
511+
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.4.0/go.mod h1:E3vdYxHj2C2q6qo8/Da4g7P+IcwqRZyy3gJBzYybV9Y=
512512
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
513513
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
514514
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=

pkg/backup/actions/csi/pvc_action.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
"k8s.io/client-go/util/retry"
2626

27-
volumegroupsnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1"
27+
volumegroupsnapshotv1beta2 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta2"
2828
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
2929
"github.com/pkg/errors"
3030
"github.com/sirupsen/logrus"
@@ -765,7 +765,7 @@ func (p *pvcBackupItemAction) getVolumeSnapshotReference(
765765
}
766766

767767
// Re-fetch latest VGS to ensure status is populated after VGSC binding
768-
latestVGS := &volumegroupsnapshotv1beta1.VolumeGroupSnapshot{}
768+
latestVGS := &volumegroupsnapshotv1beta2.VolumeGroupSnapshot{}
769769
if err := p.crClient.Get(ctx, crclient.ObjectKeyFromObject(newVGS), latestVGS); err != nil {
770770
return nil, errors.Wrapf(err, "failed to re-fetch VolumeGroupSnapshot %s after VGSC binding wait", newVGS.Name)
771771
}
@@ -913,7 +913,7 @@ func (p *pvcBackupItemAction) determineVGSClass(
913913
}
914914

915915
// 3. Fallback to label-based default
916-
vgsClassList := &volumegroupsnapshotv1beta1.VolumeGroupSnapshotClassList{}
916+
vgsClassList := &volumegroupsnapshotv1beta2.VolumeGroupSnapshotClassList{}
917917
if err := p.crClient.List(ctx, vgsClassList); err != nil {
918918
return "", errors.Wrap(err, "failed to list VolumeGroupSnapshotClasses")
919919
}
@@ -942,22 +942,22 @@ func (p *pvcBackupItemAction) createVolumeGroupSnapshot(
942942
backup *velerov1api.Backup,
943943
pvc corev1api.PersistentVolumeClaim,
944944
vgsLabelKey, vgsLabelValue, vgsClassName string,
945-
) (*volumegroupsnapshotv1beta1.VolumeGroupSnapshot, error) {
945+
) (*volumegroupsnapshotv1beta2.VolumeGroupSnapshot, error) {
946946
vgsLabels := map[string]string{
947947
velerov1api.BackupNameLabel: label.GetValidName(backup.Name),
948948
velerov1api.BackupUIDLabel: string(backup.UID),
949949
vgsLabelKey: vgsLabelValue,
950950
}
951951

952-
vgs := &volumegroupsnapshotv1beta1.VolumeGroupSnapshot{
952+
vgs := &volumegroupsnapshotv1beta2.VolumeGroupSnapshot{
953953
ObjectMeta: metav1.ObjectMeta{
954954
GenerateName: fmt.Sprintf("velero-%s-", vgsLabelValue),
955955
Namespace: pvc.Namespace,
956956
Labels: vgsLabels,
957957
},
958-
Spec: volumegroupsnapshotv1beta1.VolumeGroupSnapshotSpec{
958+
Spec: volumegroupsnapshotv1beta2.VolumeGroupSnapshotSpec{
959959
VolumeGroupSnapshotClassName: &vgsClassName,
960-
Source: volumegroupsnapshotv1beta1.VolumeGroupSnapshotSource{
960+
Source: volumegroupsnapshotv1beta2.VolumeGroupSnapshotSource{
961961
Selector: &metav1.LabelSelector{
962962
MatchLabels: map[string]string{
963963
vgsLabelKey: vgsLabelValue,
@@ -985,7 +985,7 @@ func (p *pvcBackupItemAction) createVolumeGroupSnapshot(
985985
func (p *pvcBackupItemAction) waitForVGSAssociatedVS(
986986
ctx context.Context,
987987
groupedPVCs []corev1api.PersistentVolumeClaim,
988-
vgs *volumegroupsnapshotv1beta1.VolumeGroupSnapshot,
988+
vgs *volumegroupsnapshotv1beta2.VolumeGroupSnapshot,
989989
timeout time.Duration,
990990
) (map[string]*snapshotv1api.VolumeSnapshot, error) {
991991
expected := len(groupedPVCs)
@@ -1028,10 +1028,10 @@ func (p *pvcBackupItemAction) waitForVGSAssociatedVS(
10281028
return vsMap, nil
10291029
}
10301030

1031-
func hasOwnerReference(obj metav1.Object, vgs *volumegroupsnapshotv1beta1.VolumeGroupSnapshot) bool {
1031+
func hasOwnerReference(obj metav1.Object, vgs *volumegroupsnapshotv1beta2.VolumeGroupSnapshot) bool {
10321032
for _, ref := range obj.GetOwnerReferences() {
10331033
if ref.Kind == kuberesource.VGSKind &&
1034-
ref.APIVersion == volumegroupsnapshotv1beta1.GroupName+"/"+volumegroupsnapshotv1beta1.SchemeGroupVersion.Version &&
1034+
ref.APIVersion == volumegroupsnapshotv1beta2.GroupName+"/"+volumegroupsnapshotv1beta2.SchemeGroupVersion.Version &&
10351035
ref.UID == vgs.UID {
10361036
return true
10371037
}
@@ -1042,7 +1042,7 @@ func hasOwnerReference(obj metav1.Object, vgs *volumegroupsnapshotv1beta1.Volume
10421042
func (p *pvcBackupItemAction) updateVGSCreatedVS(
10431043
ctx context.Context,
10441044
vsMap map[string]*snapshotv1api.VolumeSnapshot,
1045-
vgs *volumegroupsnapshotv1beta1.VolumeGroupSnapshot,
1045+
vgs *volumegroupsnapshotv1beta2.VolumeGroupSnapshot,
10461046
backup *velerov1api.Backup,
10471047
) error {
10481048
for pvcName, vs := range vsMap {
@@ -1085,15 +1085,15 @@ func (p *pvcBackupItemAction) updateVGSCreatedVS(
10851085
return nil
10861086
}
10871087

1088-
func (p *pvcBackupItemAction) patchVGSCDeletionPolicy(ctx context.Context, vgs *volumegroupsnapshotv1beta1.VolumeGroupSnapshot) error {
1088+
func (p *pvcBackupItemAction) patchVGSCDeletionPolicy(ctx context.Context, vgs *volumegroupsnapshotv1beta2.VolumeGroupSnapshot) error {
10891089
if vgs == nil || vgs.Status == nil || vgs.Status.BoundVolumeGroupSnapshotContentName == nil {
10901090
return errors.New("VolumeGroupSnapshotContent name not found in VGS status")
10911091
}
10921092

10931093
vgscName := vgs.Status.BoundVolumeGroupSnapshotContentName
10941094

10951095
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
1096-
vgsc := &volumegroupsnapshotv1beta1.VolumeGroupSnapshotContent{}
1096+
vgsc := &volumegroupsnapshotv1beta2.VolumeGroupSnapshotContent{}
10971097
if err := p.crClient.Get(ctx, crclient.ObjectKey{Name: *vgscName}, vgsc); err != nil {
10981098
return errors.Wrapf(err, "failed to get VolumeGroupSnapshotContent %s for VolumeGroupSnapshot %s/%s", *vgscName, vgs.Namespace, vgs.Name)
10991099
}
@@ -1112,9 +1112,9 @@ func (p *pvcBackupItemAction) patchVGSCDeletionPolicy(ctx context.Context, vgs *
11121112
})
11131113
}
11141114

1115-
func (p *pvcBackupItemAction) deleteVGSAndVGSC(ctx context.Context, vgs *volumegroupsnapshotv1beta1.VolumeGroupSnapshot) error {
1115+
func (p *pvcBackupItemAction) deleteVGSAndVGSC(ctx context.Context, vgs *volumegroupsnapshotv1beta2.VolumeGroupSnapshot) error {
11161116
if vgs.Status != nil && vgs.Status.BoundVolumeGroupSnapshotContentName != nil {
1117-
vgsc := &volumegroupsnapshotv1beta1.VolumeGroupSnapshotContent{
1117+
vgsc := &volumegroupsnapshotv1beta2.VolumeGroupSnapshotContent{
11181118
ObjectMeta: metav1.ObjectMeta{
11191119
Name: *vgs.Status.BoundVolumeGroupSnapshotContentName,
11201120
},
@@ -1139,11 +1139,11 @@ func (p *pvcBackupItemAction) deleteVGSAndVGSC(ctx context.Context, vgs *volumeg
11391139

11401140
func (p *pvcBackupItemAction) waitForVGSCBinding(
11411141
ctx context.Context,
1142-
vgs *volumegroupsnapshotv1beta1.VolumeGroupSnapshot,
1142+
vgs *volumegroupsnapshotv1beta2.VolumeGroupSnapshot,
11431143
timeout time.Duration,
11441144
) error {
11451145
return wait.PollUntilContextTimeout(ctx, time.Second, timeout, true, func(ctx context.Context) (bool, error) {
1146-
vgsRef := &volumegroupsnapshotv1beta1.VolumeGroupSnapshot{}
1146+
vgsRef := &volumegroupsnapshotv1beta2.VolumeGroupSnapshot{}
11471147
if err := p.crClient.Get(ctx, crclient.ObjectKeyFromObject(vgs), vgsRef); err != nil {
11481148
return false, err
11491149
}
@@ -1156,8 +1156,8 @@ func (p *pvcBackupItemAction) waitForVGSCBinding(
11561156
})
11571157
}
11581158

1159-
func (p *pvcBackupItemAction) getVGSByLabels(ctx context.Context, namespace string, labels map[string]string) (*volumegroupsnapshotv1beta1.VolumeGroupSnapshot, error) {
1160-
vgsList := &volumegroupsnapshotv1beta1.VolumeGroupSnapshotList{}
1159+
func (p *pvcBackupItemAction) getVGSByLabels(ctx context.Context, namespace string, labels map[string]string) (*volumegroupsnapshotv1beta2.VolumeGroupSnapshot, error) {
1160+
vgsList := &volumegroupsnapshotv1beta2.VolumeGroupSnapshotList{}
11611161
if err := p.crClient.List(ctx, vgsList,
11621162
crclient.InNamespace(namespace),
11631163
crclient.MatchingLabels(labels),

0 commit comments

Comments
 (0)