diff --git a/build.env b/build.env index f451b68022d..fa48af57035 100644 --- a/build.env +++ b/build.env @@ -44,7 +44,7 @@ HELM_SCRIPT=https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 HELM_VERSION=v3.14.3 # minikube settings -MINIKUBE_VERSION=v1.33.0 +MINIKUBE_VERSION=v1.34.0 VM_DRIVER=none CHANGE_MINIKUBE_NONE_USER=true diff --git a/e2e/cephfs.go b/e2e/cephfs.go index 97f953b10e2..c6050441b93 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -22,7 +22,7 @@ import ( "strings" "sync" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" . "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -2478,6 +2478,19 @@ var _ = Describe(cephfsType, func() { } }) + By("test volumeGroupSnapshot", func() { + scName := "csi-cephfs-sc" + snapshotter, err := newCephFSVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 3) + if err != nil { + framework.Failf("failed to create volumeGroupSnapshot Base: %v", err) + } + + err = snapshotter.TestVolumeGroupSnapshot() + if err != nil { + framework.Failf("failed to test volumeGroupSnapshot: %v", err) + } + }) + // FIXME: in case NFS testing is done, prevent deletion // of the CephFS filesystem and related pool. This can // probably be addressed in a nicer way, making sure diff --git a/e2e/cephfs_helper.go b/e2e/cephfs_helper.go index 2eead88db2a..ae6fb9f3901 100644 --- a/e2e/cephfs_helper.go +++ b/e2e/cephfs_helper.go @@ -24,7 +24,7 @@ import ( "strings" "time" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" diff --git a/e2e/deployment.go b/e2e/deployment.go index 15e6ce885a4..12b86acdacc 100644 --- a/e2e/deployment.go +++ b/e2e/deployment.go @@ -250,6 +250,8 @@ func (yrn *yamlResourceNamespaced) Do(action kubectlAction) error { return fmt.Errorf("failed to read content from %q: %w", yrn.filename, err) } + data = replaceLogLevelInTemplate(data) + if yrn.oneReplica { data = oneReplicaDeployYaml(data) } diff --git a/e2e/nfs.go b/e2e/nfs.go index d185f8c987f..a85004b50a4 100644 --- a/e2e/nfs.go +++ b/e2e/nfs.go @@ -23,7 +23,7 @@ import ( "sync" "time" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" . "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" diff --git a/e2e/pvc.go b/e2e/pvc.go index ede131c569a..932d66b33a0 100644 --- a/e2e/pvc.go +++ b/e2e/pvc.go @@ -75,6 +75,19 @@ func createPVCAndvalidatePV(c kubernetes.Interface, pvc *v1.PersistentVolumeClai } if pvc.Spec.VolumeName == "" { + var events *v1.EventList + // Log the events for the PVC if its not bound yet + events, err = c.CoreV1().Events(namespace).List(ctx, metav1.ListOptions{ + FieldSelector: "involvedObject.kind=PersistentVolumeClaim,involvedObject.name=" + name, + }) + if err == nil { + for i := range events.Items { + framework.Logf("PVC %s Event: %s - %s", name, events.Items[i].Reason, events.Items[i].Message) + } + } else { + framework.Logf("error getting events for PVC %s: %v", name, err) + } + return false, nil } diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index dd247b8cb58..b35e38a432c 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -27,7 +27,7 @@ import ( "github.com/ceph/ceph-csi/internal/util" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" v1 "k8s.io/api/core/v1" scv1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/e2e/snapshot.go b/e2e/snapshot.go index cc0c665755c..b38562d5d3d 100644 --- a/e2e/snapshot.go +++ b/e2e/snapshot.go @@ -21,8 +21,8 @@ import ( "fmt" "time" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" - snapclient "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" + snapclient "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1" . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" diff --git a/e2e/utils.go b/e2e/utils.go index f2cbcfc3a91..0e29f53c168 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -30,7 +30,7 @@ import ( "sync" "time" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" appsv1 "k8s.io/api/apps/v1" batch "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" @@ -52,8 +52,9 @@ const ( rbdType = "rbd" cephfsType = "cephfs" - volumesType = "volumes" - snapsType = "snaps" + volumesType = "volumes" + snapsType = "snaps" + groupSnapsType = "groupsnaps" rookToolBoxPodLabel = "app=rook-ceph-tools" rbdMountOptions = "mountOptions" @@ -174,17 +175,20 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str volumeMode: volumesType, driverType: cephfsType, radosLsCmd: fmt.Sprintf("rados ls --pool=%s --namespace csi", pool), - radosLsCmdFilter: fmt.Sprintf("rados ls --pool=%s --namespace csi | grep -v default | grep -c ^csi.volume.", + radosLsCmdFilter: fmt.Sprintf( + "rados ls --pool=%s --namespace csi | grep -v default | grep -v csi.volume.group. | grep -c ^csi.volume.", pool), radosLsKeysCmd: fmt.Sprintf("rados listomapkeys csi.volumes.default --pool=%s --namespace csi", pool), - radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.volumes.default --pool=%s --namespace csi|wc -l", + radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.volumes.default --pool=%s --namespace csi | wc -l", pool), }, { - volumeMode: volumesType, - driverType: rbdType, - radosLsCmd: "rados ls " + rbdOptions(pool), - radosLsCmdFilter: fmt.Sprintf("rados ls %s | grep -v default | grep -c ^csi.volume.", rbdOptions(pool)), + volumeMode: volumesType, + driverType: rbdType, + radosLsCmd: "rados ls " + rbdOptions(pool), + radosLsCmdFilter: fmt.Sprintf( + "rados ls %s | grep -v default | grep -v csi.volume.group. | grep -c ^csi.volume.", + rbdOptions(pool)), radosLsKeysCmd: "rados listomapkeys csi.volumes.default " + rbdOptions(pool), radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.volumes.default %s | wc -l", rbdOptions(pool)), }, @@ -195,7 +199,7 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str radosLsCmdFilter: fmt.Sprintf("rados ls --pool=%s --namespace csi | grep -v default | grep -c ^csi.snap.", pool), radosLsKeysCmd: fmt.Sprintf("rados listomapkeys csi.snaps.default --pool=%s --namespace csi", pool), - radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.snaps.default --pool=%s --namespace csi|wc -l", + radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.snaps.default --pool=%s --namespace csi | wc -l", pool), }, { @@ -206,6 +210,16 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str radosLsKeysCmd: "rados listomapkeys csi.snaps.default " + rbdOptions(pool), radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.snaps.default %s | wc -l", rbdOptions(pool)), }, + { + volumeMode: groupSnapsType, + driverType: cephfsType, + radosLsCmd: fmt.Sprintf("rados ls --pool=%s --namespace csi", pool), + radosLsCmdFilter: fmt.Sprintf("rados ls --pool=%s --namespace csi | grep -v default | grep -c ^csi.volume.group.", + pool), + radosLsKeysCmd: fmt.Sprintf("rados listomapkeys csi.groups.default --pool=%s --namespace csi", pool), + radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.groups.default --pool=%s --namespace csi | wc -l", + pool), + }, } for _, cmds := range radosListCommands { @@ -228,7 +242,7 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str if err == nil { continue } - saveErr := err + saveErr := fmt.Errorf("failed to validate omap count for %s: %w", cmd, err) if strings.Contains(err.Error(), "expected omap object count") { stdOut, stdErr, err = execCommandInToolBoxPod(f, filterLessCmds[i], rookNamespace) if err == nil { @@ -823,6 +837,15 @@ func oneReplicaDeployYaml(template string) string { return re.ReplaceAllString(template, `$1 1`) } +// replaceLogLevelInTemplate replaces the log level in the template file to 5. +func replaceLogLevelInTemplate(template string) string { + // Regular expression to find --v= arguments + re := regexp.MustCompile(`--v=\d+`) + + // template can contain different log levels, replace it with --v=5 + return re.ReplaceAllString(template, "--v=5") +} + func enableReadAffinityInTemplate(template string) string { return strings.ReplaceAll(template, "# - \"--enable-read-affinity=true\"", "- \"--enable-read-affinity=true\"") } diff --git a/e2e/volumegroupsnapshot.go b/e2e/volumegroupsnapshot.go new file mode 100644 index 00000000000..a204bab9eff --- /dev/null +++ b/e2e/volumegroupsnapshot.go @@ -0,0 +1,119 @@ +/* +Copyright 2024 The Ceph-CSI Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "context" + "fmt" + + groupsnapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kubernetes/test/e2e/framework" +) + +type cephFSVolumeGroupSnapshot struct { + *volumeGroupSnapshotterBase +} + +var _ VolumeGroupSnapshotter = &cephFSVolumeGroupSnapshot{} + +func newCephFSVolumeGroupSnapshot(f *framework.Framework, namespace, + storageClass string, + blockPVC bool, + timeout, totalPVCCount int, +) (VolumeGroupSnapshotter, error) { + base, err := newVolumeGroupSnapshotBase(f, namespace, storageClass, blockPVC, timeout, totalPVCCount) + if err != nil { + return nil, fmt.Errorf("failed to create volumeGroupSnapshotterBase: %w", err) + } + + return &cephFSVolumeGroupSnapshot{ + volumeGroupSnapshotterBase: base, + }, nil +} + +func (c *cephFSVolumeGroupSnapshot) TestVolumeGroupSnapshot() error { + return c.volumeGroupSnapshotterBase.testVolumeGroupSnapshot(c) +} + +func (c *cephFSVolumeGroupSnapshot) GetVolumeGroupSnapshotClass() (*groupsnapapi.VolumeGroupSnapshotClass, error) { + vgscPath := fmt.Sprintf("%s/%s", cephFSExamplePath, "groupsnapshotclass.yaml") + vgsc := &groupsnapapi.VolumeGroupSnapshotClass{} + err := unmarshal(vgscPath, vgsc) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal VolumeGroupSnapshotClass: %w", err) + } + + vgsc.Parameters["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = cephCSINamespace + vgsc.Parameters["csi.storage.k8s.io/group-snapshotter-secret-name"] = cephFSProvisionerSecretName + vgsc.Parameters["fsName"] = fileSystemName + + fsID, err := getClusterID(c.framework) + if err != nil { + return nil, fmt.Errorf("failed to get clusterID: %w", err) + } + vgsc.Parameters["clusterID"] = fsID + + return vgsc, nil +} + +func (c *cephFSVolumeGroupSnapshot) ValidateResourcesForCreate(vgs *groupsnapapi.VolumeGroupSnapshot) error { + ctx := context.TODO() + metadataPool, err := getCephFSMetadataPoolName(c.framework, fileSystemName) + if err != nil { + return fmt.Errorf("failed getting cephFS metadata pool name: %w", err) + } + + sourcePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList) + // we are creating clones for each source PVC + clonePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList) + totalPVCCount := sourcePVCCount + clonePVCCount + validateSubvolumeCount(c.framework, totalPVCCount, fileSystemName, subvolumegroup) + + // we are creating 1 snapshot for each source PVC, validate the snapshot count + for _, pvcSnap := range vgs.Status.PVCVolumeSnapshotRefList { + pvc, err := c.framework.ClientSet.CoreV1().PersistentVolumeClaims(vgs.Namespace).Get(ctx, + pvcSnap.PersistentVolumeClaimRef.Name, + metav1.GetOptions{}) + if err != nil { + return fmt.Errorf("failed to get PVC: %w", err) + } + pv := pvc.Spec.VolumeName + pvObj, err := c.framework.ClientSet.CoreV1().PersistentVolumes().Get(ctx, pv, metav1.GetOptions{}) + if err != nil { + return fmt.Errorf("failed to get PV: %w", err) + } + validateCephFSSnapshotCount(c.framework, 1, subvolumegroup, pvObj) + } + validateOmapCount(c.framework, totalPVCCount, cephfsType, metadataPool, volumesType) + validateOmapCount(c.framework, sourcePVCCount, cephfsType, metadataPool, snapsType) + validateOmapCount(c.framework, 1, cephfsType, metadataPool, groupSnapsType) + + return nil +} + +func (c *cephFSVolumeGroupSnapshot) ValidateResourcesForDelete() error { + metadataPool, err := getCephFSMetadataPoolName(c.framework, fileSystemName) + if err != nil { + return fmt.Errorf("failed getting cephFS metadata pool name: %w", err) + } + validateOmapCount(c.framework, 0, cephfsType, metadataPool, volumesType) + validateOmapCount(c.framework, 0, cephfsType, metadataPool, snapsType) + validateOmapCount(c.framework, 0, cephfsType, metadataPool, groupSnapsType) + + return nil +} diff --git a/e2e/volumegroupsnapshot_base.go b/e2e/volumegroupsnapshot_base.go new file mode 100644 index 00000000000..a4b4bfe3de7 --- /dev/null +++ b/e2e/volumegroupsnapshot_base.go @@ -0,0 +1,432 @@ +/* +Copyright 2024 The Ceph-CSI Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "context" + "fmt" + "time" + + groupsnapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" + groupsnapclient "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1" + v1 "k8s.io/api/core/v1" + apierrs "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/kubernetes/test/e2e/framework" +) + +// volumeGroupSnapshotter defines the common operations for handling +// volume group snapshots. +type volumeGroupSnapshotter interface { + // CreateVolumeGroupSnapshotClass creates a volume group snapshot class. + CreateVolumeGroupSnapshotClass(vgsc *groupsnapapi.VolumeGroupSnapshotClass) error + // CreateVolumeGroupSnapshot creates a groupsnapshot with the specified name + // namespace and volume group snapshot class. + CreateVolumeGroupSnapshot(name, + volumeGroupSnapshotClassName string, + labels map[string]string) (*groupsnapapi.VolumeGroupSnapshot, error) + // DeleteVolumeGroupSnapshot deletes the specified volume + // group snapshot. + DeleteVolumeGroupSnapshot(volumeGroupSnapshotName string) error + // DeleteVolumeGroupSnapshotClass deletes the specified volume + // group snapshot class. + DeleteVolumeGroupSnapshotClass(snapshotClassName string) error + // CreatePVCs creates PVCs with the specified namespace and labels. + CreatePVCs(namespace string, + labels map[string]string) ([]*v1.PersistentVolumeClaim, error) + // DeletePVCs deletes the specified PVCs. + DeletePVCs(pvcs []*v1.PersistentVolumeClaim) error + // CreatePVCClones creates pvcs from all the snapshots in VolumeGroupSnapshot. + CreatePVCClones(vgs *groupsnapapi.VolumeGroupSnapshot, + ) ([]*v1.PersistentVolumeClaim, error) +} + +// VolumeGroupSnapshotter defines validation operations specific to each driver. +type VolumeGroupSnapshotter interface { + // TestVolumeGroupSnapshot tests the volume group snapshot operations. + TestVolumeGroupSnapshot() error + // GetVolumeGroupSnapshotClass returns the volume group snapshot class. + GetVolumeGroupSnapshotClass() (*groupsnapapi.VolumeGroupSnapshotClass, error) + // ValidateResourcesForCreate validates the resources in the backend after + // creating clones. + ValidateResourcesForCreate(vgs *groupsnapapi.VolumeGroupSnapshot) error + // ValidateSnapshotsDeleted checks if all resources are deleted in the + // backend after all the resources are deleted. + ValidateResourcesForDelete() error +} + +type volumeGroupSnapshotterBase struct { + timeout int + framework *framework.Framework + groupclient *groupsnapclient.GroupsnapshotV1alpha1Client + storageClassName string + blockPVC bool + totalPVCCount int + namespace string +} + +func newVolumeGroupSnapshotBase(f *framework.Framework, namespace, + storageClass string, + blockPVC bool, + timeout, totalPVCCount int, +) (*volumeGroupSnapshotterBase, error) { + config, err := framework.LoadConfig() + if err != nil { + return nil, fmt.Errorf("error creating group snapshot client: %w", err) + } + c, err := groupsnapclient.NewForConfig(config) + if err != nil { + return nil, fmt.Errorf("error creating group snapshot client: %w", err) + } + + return &volumeGroupSnapshotterBase{ + framework: f, + groupclient: c, + namespace: namespace, + storageClassName: storageClass, + blockPVC: blockPVC, + timeout: timeout, + totalPVCCount: totalPVCCount, + }, err +} + +var _ volumeGroupSnapshotter = &volumeGroupSnapshotterBase{} + +func (v *volumeGroupSnapshotterBase) CreatePVCs(namespace string, + labels map[string]string, +) ([]*v1.PersistentVolumeClaim, error) { + pvcs := make([]*v1.PersistentVolumeClaim, v.totalPVCCount) + for i := range v.totalPVCCount { + pvcs[i] = &v1.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("pvc-%d", i), + Namespace: namespace, + }, + Spec: v1.PersistentVolumeClaimSpec{ + Resources: v1.VolumeResourceRequirements{ + Requests: v1.ResourceList{ + v1.ResourceStorage: resource.MustParse("1Gi"), + }, + }, + AccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}, + StorageClassName: &v.storageClassName, + }, + } + if v.blockPVC { + volumeMode := v1.PersistentVolumeBlock + pvcs[i].Spec.VolumeMode = &volumeMode + } else { + volumeMode := v1.PersistentVolumeFilesystem + pvcs[i].Spec.VolumeMode = &volumeMode + } + pvcs[i].Labels = labels + err := createPVCAndvalidatePV(v.framework.ClientSet, pvcs[i], v.timeout) + if err != nil { + return nil, fmt.Errorf("failed to create PVC: %w", err) + } + } + + return pvcs, nil +} + +func (v *volumeGroupSnapshotterBase) DeletePVCs(pvcs []*v1.PersistentVolumeClaim) error { + for _, pvc := range pvcs { + err := deletePVCAndValidatePV(v.framework.ClientSet, pvc, v.timeout) + if err != nil { + return fmt.Errorf("failed to delete PVC: %w", err) + } + } + + return nil +} + +func (v *volumeGroupSnapshotterBase) CreatePVCClones( + vgs *groupsnapapi.VolumeGroupSnapshot, +) ([]*v1.PersistentVolumeClaim, error) { + pvcSnapRef := vgs.Status.PVCVolumeSnapshotRefList + namespace := vgs.Namespace + ctx := context.TODO() + pvcs := make([]*v1.PersistentVolumeClaim, len(pvcSnapRef)) + for i, pvcSnap := range pvcSnapRef { + pvc, err := v.framework.ClientSet.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, + pvcSnap.PersistentVolumeClaimRef.Name, + metav1.GetOptions{}) + if err != nil { + return nil, fmt.Errorf("failed to get PVC: %w", err) + } + pvcs[i] = &v1.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("%s-clone-%d", pvc.Name, i), + Namespace: pvc.Namespace, + }, + Spec: *pvc.Spec.DeepCopy(), + } + + snap := pvcSnap.VolumeSnapshotRef + apiGroup := snapapi.GroupName + pvcs[i].Spec.DataSource = &v1.TypedLocalObjectReference{ + APIGroup: &apiGroup, + Kind: "VolumeSnapshot", + Name: snap.Name, + } + pvcs[i].Spec.StorageClassName = &v.storageClassName + // cleanup the VolumeName as we are creating a new PVC + pvcs[i].Spec.VolumeName = "" + + err = createPVCAndvalidatePV(v.framework.ClientSet, pvcs[i], v.timeout) + if err != nil { + return nil, fmt.Errorf("failed to create PVC: %w", err) + } + } + + return pvcs, nil +} + +func (v volumeGroupSnapshotterBase) CreateVolumeGroupSnapshotClass( + groupSnapshotClass *groupsnapapi.VolumeGroupSnapshotClass, +) error { + return wait.PollUntilContextTimeout( + context.TODO(), + poll, + time.Duration(v.timeout)*time.Minute, + true, + func(ctx context.Context) (bool, error) { + _, err := v.groupclient.VolumeGroupSnapshotClasses().Create(ctx, groupSnapshotClass, metav1.CreateOptions{}) + if err != nil { + framework.Logf("error creating VolumeGroupSnapshotClass %q: %v", groupSnapshotClass.Name, err) + if isRetryableAPIError(err) { + return false, nil + } + + return false, fmt.Errorf("failed to create VolumeGroupSnapshotClass %q: %w", groupSnapshotClass.Name, err) + } + + return true, nil + }) +} + +func (v volumeGroupSnapshotterBase) CreateVolumeGroupSnapshot(name, + volumeGroupSnapshotClassName string, labels map[string]string, +) (*groupsnapapi.VolumeGroupSnapshot, error) { + namespace := v.namespace + groupSnapshot := &groupsnapapi.VolumeGroupSnapshot{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: groupsnapapi.VolumeGroupSnapshotSpec{ + Source: groupsnapapi.VolumeGroupSnapshotSource{ + Selector: &metav1.LabelSelector{ + MatchLabels: labels, + }, + }, + VolumeGroupSnapshotClassName: &volumeGroupSnapshotClassName, + }, + } + ctx := context.TODO() + _, err := v.groupclient.VolumeGroupSnapshots(namespace).Create(ctx, groupSnapshot, metav1.CreateOptions{}) + if err != nil { + return nil, fmt.Errorf("failed to create VolumeGroupSnapshot %q: %w", name, err) + } + + framework.Logf("VolumeGroupSnapshot with name %v created in %v namespace", name, namespace) + + timeout := time.Duration(v.timeout) * time.Minute + start := time.Now() + framework.Logf("waiting for %+v to be in ready state", groupSnapshot) + + err = wait.PollUntilContextTimeout(ctx, poll, timeout, true, func(ctx context.Context) (bool, error) { + framework.Logf("waiting for VolumeGroupSnapshot %s (%d seconds elapsed)", name, int(time.Since(start).Seconds())) + groupSnapshot, err = v.groupclient.VolumeGroupSnapshots(namespace). + Get(ctx, name, metav1.GetOptions{}) + if err != nil { + framework.Logf("Error getting VolumeGroupSnapshot in namespace: '%s': %v", namespace, err) + if isRetryableAPIError(err) { + return false, nil + } + if apierrs.IsNotFound(err) { + return false, nil + } + + return false, fmt.Errorf("failed to get volumesnapshot: %w", err) + } + if groupSnapshot.Status == nil || groupSnapshot.Status.ReadyToUse == nil { + return false, nil + } + + if *groupSnapshot.Status.ReadyToUse { + return true, nil + } + + readyToUse := groupSnapshot.Status.ReadyToUse + errMsg := "" + if groupSnapshot.Status.Error != nil { + errMsg = *groupSnapshot.Status.Error.Message + } + + framework.Logf("current state of VolumeGroupSnapshot %s. ReadyToUse: %v, Error: %s", name, *readyToUse, errMsg) + + return false, nil + }) + if err != nil { + return nil, fmt.Errorf("failed to get VolumeGroupSnapshot %s: %w", name, err) + } + + return groupSnapshot, nil +} + +func (v volumeGroupSnapshotterBase) DeleteVolumeGroupSnapshot(volumeGroupSnapshotName string) error { + namespace := v.namespace + ctx := context.TODO() + err := v.groupclient.VolumeGroupSnapshots(namespace).Delete( + ctx, + volumeGroupSnapshotName, + metav1.DeleteOptions{}) + if err != nil { + return fmt.Errorf("failed to delete VolumeGroupSnapshot: %w", err) + } + start := time.Now() + framework.Logf("Waiting for VolumeGroupSnapshot %v to be deleted", volumeGroupSnapshotName) + timeout := time.Duration(v.timeout) * time.Minute + + return wait.PollUntilContextTimeout( + ctx, + poll, + timeout, + true, + func(ctx context.Context) (bool, error) { + _, err := v.groupclient.VolumeGroupSnapshots(namespace).Get(ctx, volumeGroupSnapshotName, metav1.GetOptions{}) + if err != nil { + if isRetryableAPIError(err) { + return false, nil + } + if apierrs.IsNotFound(err) { + return true, nil + } + framework.Logf("%s VolumeGroupSnapshot to be deleted (%d seconds elapsed)", + volumeGroupSnapshotName, + int(time.Since(start).Seconds())) + + return false, fmt.Errorf("failed to get VolumeGroupSnapshot: %w", err) + } + + return false, nil + }) +} + +func (v volumeGroupSnapshotterBase) DeleteVolumeGroupSnapshotClass(groupSnapshotClassName string) error { + ctx := context.TODO() + err := v.groupclient.VolumeGroupSnapshotClasses().Delete( + ctx, groupSnapshotClassName, metav1.DeleteOptions{}) + if err != nil { + return fmt.Errorf("failed to delete VolumeGroupSnapshotClass: %w", err) + } + start := time.Now() + framework.Logf("Waiting for VolumeGroupSnapshotClass %v to be deleted", groupSnapshotClassName) + timeout := time.Duration(v.timeout) * time.Minute + + return wait.PollUntilContextTimeout( + ctx, + poll, + timeout, + true, + func(ctx context.Context) (bool, error) { + _, err := v.groupclient.VolumeGroupSnapshotClasses().Get(ctx, groupSnapshotClassName, metav1.GetOptions{}) + if err != nil { + if isRetryableAPIError(err) { + return false, nil + } + if apierrs.IsNotFound(err) { + return true, nil + } + framework.Logf("%s VolumeGroupSnapshotClass to be deleted (%d seconds elapsed)", + groupSnapshotClassName, + int(time.Since(start).Seconds())) + + return false, fmt.Errorf("failed to get VolumeGroupSnapshotClass: %w", err) + } + + return false, nil + }) +} + +func (v *volumeGroupSnapshotterBase) testVolumeGroupSnapshot(vol VolumeGroupSnapshotter) error { + pvcLabels := map[string]string{"pvc": "vgsc"} + pvcs, err := v.CreatePVCs(v.namespace, pvcLabels) + if err != nil { + return fmt.Errorf("failed to create PVCs: %w", err) + } + + vgsc, err := vol.GetVolumeGroupSnapshotClass() + if err != nil { + return fmt.Errorf("failed to get volume group snapshot class: %w", err) + } + // Create a volume group snapshot class + vgscName := v.framework.Namespace.Name + "-vgsc" + vgsc.Name = vgscName + err = v.CreateVolumeGroupSnapshotClass(vgsc) + if err != nil { + return fmt.Errorf("failed to create volume group snapshot: %w", err) + } + vgsName := v.framework.Namespace.Name + "-vgs" + // Create a volume group snapshot + volumeGroupSnapshot, err := v.CreateVolumeGroupSnapshot(vgsName, vgscName, pvcLabels) + if err != nil { + return fmt.Errorf("failed to create volume group snapshot: %w", err) + } + + clonePVCs, err := v.CreatePVCClones(volumeGroupSnapshot) + if err != nil { + return fmt.Errorf("failed to create clones: %w", err) + } + // validate the resources in the backend + err = vol.ValidateResourcesForCreate(volumeGroupSnapshot) + if err != nil { + return fmt.Errorf("failed to validate resources for create: %w", err) + } + + // Delete the clones + err = v.DeletePVCs(clonePVCs) + if err != nil { + return fmt.Errorf("failed to delete clones: %w", err) + } + // Delete the PVCs + err = v.DeletePVCs(pvcs) + if err != nil { + return fmt.Errorf("failed to delete PVCs: %w", err) + } + // Delete the volume group snapshot + err = v.DeleteVolumeGroupSnapshot(volumeGroupSnapshot.Name) + if err != nil { + return fmt.Errorf("failed to delete volume group snapshot: %w", err) + } + // validate the resources in the backend after deleting the resources + err = vol.ValidateResourcesForDelete() + if err != nil { + return fmt.Errorf("failed to validate resources for delete: %w", err) + } + // Delete the volume group snapshot class + err = v.DeleteVolumeGroupSnapshotClass(vgscName) + if err != nil { + return fmt.Errorf("failed to delete volume group snapshot class: %w", err) + } + + return nil +} diff --git a/go.mod b/go.mod index 572c2197b1b..db3fdb31315 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/hashicorp/vault/api v1.14.0 github.com/kubernetes-csi/csi-lib-utils v0.19.0 - github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0 + github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0 github.com/libopenstorage/secrets v0.0.0-20231011182615-5f4b25ceede1 github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/gomega v1.34.2 diff --git a/go.sum b/go.sum index a43c328ff11..31fee84bf77 100644 --- a/go.sum +++ b/go.sum @@ -1962,8 +1962,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kubernetes-csi/csi-lib-utils v0.19.0 h1:3sT8mL9+St2acyrEtuR7CQ5L78GR4lgsb+sfon9tGfA= github.com/kubernetes-csi/csi-lib-utils v0.19.0/go.mod h1:lBuMKvoyd8c3EG+itmnVWApLDHnLkU7ibxxZSPuOw0M= github.com/kubernetes-csi/external-snapshotter/client/v4 v4.0.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys= -github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0 h1:j3YK74myEQRxR/srciTpOrm221SAvz6J5OVWbyfeXFo= -github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0/go.mod h1:FlyYFe32mPxKEPaRXKNxfX576d1AoCzstYDoOOnyMA4= +github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0 h1:mjQG0Vakr2h246kEDR85U8y8ZhPgT3bguTCajRa/jaw= +github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0/go.mod h1:E3vdYxHj2C2q6qo8/Da4g7P+IcwqRZyy3gJBzYybV9Y= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index a69b0e63279..703809c953e 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -431,13 +431,11 @@ func createImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) er log.DebugLog(ctx, "rbd: create %s size %s (features: %s) using mon %s", pOpts, volSzMiB, pOpts.ImageFeatureSet.Names(), pOpts.Monitors) - options := librbd.NewRbdImageOptions() - defer options.Destroy() - - err := pOpts.setImageOptions(ctx, options) + options, err := pOpts.constructImageOptions(ctx) if err != nil { return err } + defer options.Destroy() err = pOpts.Connect(cr) if err != nil { @@ -1494,12 +1492,11 @@ func (rv *rbdVolume) cloneRbdImageFromSnapshot( parentVol.ioctx = nil }() - options := librbd.NewRbdImageOptions() - defer options.Destroy() - err = rv.setImageOptions(ctx, options) + options, err := rv.constructImageOptions(ctx) if err != nil { return err } + defer options.Destroy() err = options.SetUint64(librbd.ImageOptionCloneFormat, 2) if err != nil { @@ -1545,23 +1542,30 @@ func (rv *rbdVolume) cloneRbdImageFromSnapshot( return nil } -// setImageOptions sets the image options. -func (rv *rbdVolume) setImageOptions(ctx context.Context, options *librbd.ImageOptions) error { +// constructImageOptions constructs the ImageOptions that should get set on the +// RBD-image at the time of its creation/cloning. +func (rv *rbdVolume) constructImageOptions(ctx context.Context) (*librbd.ImageOptions, error) { var err error + options := librbd.NewRbdImageOptions() + defer func() { + if err != nil { + options.Destroy() + } + }() logMsg := fmt.Sprintf("setting image options on %s", rv) if rv.DataPool != "" { logMsg += ", data pool %s" + rv.DataPool err = options.SetString(librbd.RbdImageOptionDataPool, rv.DataPool) if err != nil { - return fmt.Errorf("failed to set data pool: %w", err) + return nil, fmt.Errorf("failed to set data pool: %w", err) } } if rv.ImageFeatureSet != 0 { err = options.SetUint64(librbd.RbdImageOptionFeatures, uint64(rv.ImageFeatureSet)) if err != nil { - return fmt.Errorf("failed to set image features: %w", err) + return nil, fmt.Errorf("failed to set image features: %w", err) } } @@ -1569,11 +1573,11 @@ func (rv *rbdVolume) setImageOptions(ctx context.Context, options *librbd.ImageO logMsg += fmt.Sprintf(", stripe count %d, stripe unit %d", rv.StripeCount, rv.StripeUnit) err = options.SetUint64(librbd.RbdImageOptionStripeCount, rv.StripeCount) if err != nil { - return fmt.Errorf("failed to set stripe count: %w", err) + return nil, fmt.Errorf("failed to set stripe count: %w", err) } err = options.SetUint64(librbd.RbdImageOptionStripeUnit, rv.StripeUnit) if err != nil { - return fmt.Errorf("failed to set stripe unit: %w", err) + return nil, fmt.Errorf("failed to set stripe unit: %w", err) } } @@ -1582,13 +1586,13 @@ func (rv *rbdVolume) setImageOptions(ctx context.Context, options *librbd.ImageO logMsg += fmt.Sprintf(", object size %d, order %d", rv.ObjectSize, order) err = options.SetUint64(librbd.RbdImageOptionOrder, order) if err != nil { - return fmt.Errorf("failed to set object size: %w", err) + return nil, fmt.Errorf("failed to set object size: %w", err) } } log.DebugLog(ctx, logMsg) - return nil + return options, nil } // GetCreationTime returns the creation time of the image. if the image diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/LICENSE b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/LICENSE similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/LICENSE rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/LICENSE diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/doc.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/doc.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/doc.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/doc.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/register.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/register.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/register.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/register.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go similarity index 84% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/types.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go index b8de6494888..445a2ee013a 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/types.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go @@ -20,7 +20,7 @@ import ( core_v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" ) // VolumeGroupSnapshotSpec defines the desired state of a volume group snapshot. @@ -36,6 +36,7 @@ type VolumeGroupSnapshotSpec struct { // class will be used. // Empty string is not allowed for this field. // +optional + // +kubebuilder:validation:XValidation:rule="size(self) > 0",message="volumeGroupSnapshotClassName must not be the empty string when set" VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotClassName"` } @@ -44,6 +45,9 @@ type VolumeGroupSnapshotSpec struct { // object should be used. // Exactly one of its members must be set. // Members in VolumeGroupSnapshotSource are immutable. +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.selector) || has(self.selector)", message="selector is required once set" +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeGroupSnapshotContentName) || has(self.volumeGroupSnapshotContentName)", message="volumeGroupSnapshotContentName is required once set" +// +kubebuilder:validation:XValidation:rule="(has(self.selector) && !has(self.volumeGroupSnapshotContentName)) || (!has(self.selector) && has(self.volumeGroupSnapshotContentName))", message="exactly one of selector and volumeGroupSnapshotContentName must be set" type VolumeGroupSnapshotSource struct { // Selector is a label query over persistent volume claims that are to be // grouped together for snapshotting. @@ -53,6 +57,7 @@ type VolumeGroupSnapshotSource struct { // Once a VolumeGroupSnapshotContent is created and the sidecar starts to process // it, the volume list will not change with retries. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="selector is immutable" Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"` // VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent @@ -61,6 +66,7 @@ type VolumeGroupSnapshotSource struct { // only needs a representation in Kubernetes. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupSnapshotContentName is immutable" VolumeGroupSnapshotContentName *string `json:"volumeGroupSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotContentName"` } @@ -103,11 +109,20 @@ type VolumeGroupSnapshotStatus struct { // +optional Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"` - // VolumeSnapshotRefList is the list of volume snapshot references for this - // group snapshot. + // VolumeSnapshotRefList is the list of PVC and VolumeSnapshot pairs that + // is part of this group snapshot. // The maximum number of allowed snapshots in the group is 100. // +optional - VolumeSnapshotRefList []core_v1.ObjectReference `json:"volumeSnapshotRefList,omitempty" protobuf:"bytes,5,opt,name=volumeSnapshotRefList"` + PVCVolumeSnapshotRefList []PVCVolumeSnapshotPair `json:"pvcVolumeSnapshotRefList,omitempty" protobuf:"bytes,5,opt,name=pvcVolumeSnapshotRefList"` +} + +// PVCVolumeSnapshotPair defines a pair of a PVC reference and a Volume Snapshot Reference +type PVCVolumeSnapshotPair struct { + // PersistentVolumeClaimRef is a reference to the PVC this pair is referring to + PersistentVolumeClaimRef core_v1.LocalObjectReference `json:"persistentVolumeClaimRef,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeClaimRef"` + + // VolumeSnapshotRef is a reference to the VolumeSnapshot this pair is referring to + VolumeSnapshotRef core_v1.LocalObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` } //+genclient @@ -265,6 +280,8 @@ type VolumeGroupSnapshotContentSpec struct { // VolumeGroupSnapshot object MUST be provided for binding to happen. // This field is immutable after creation. // Required. + // +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupSnapshotRef.name and volumeGroupSnapshotRef.namespace must be set" + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupSnapshotRef is immutable" VolumeGroupSnapshotRef core_v1.ObjectReference `json:"volumeGroupSnapshotRef" protobuf:"bytes,1,opt,name=volumeGroupSnapshotRef"` // DeletionPolicy determines whether this VolumeGroupSnapshotContent and the @@ -337,21 +354,35 @@ type VolumeGroupSnapshotContentStatus struct { // +optional Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"` - // VolumeSnapshotContentRefList is the list of volume snapshot content references - // for this group snapshot. + // PVVolumeSnapshotContentList is the list of pairs of PV and + // VolumeSnapshotContent for this group snapshot // The maximum number of allowed snapshots in the group is 100. // +optional - VolumeSnapshotContentRefList []core_v1.ObjectReference `json:"volumeSnapshotContentRefList,omitempty" protobuf:"bytes,5,opt,name=volumeSnapshotContentRefList"` + PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,5,opt,name=pvVolumeSnapshotContentRefList"` +} + +// PVVolumeSnapshotContentPair represent a pair of PV names and +// VolumeSnapshotContent names +type PVVolumeSnapshotContentPair struct { + // PersistentVolumeRef is a reference to the persistent volume resource + PersistentVolumeRef core_v1.LocalObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeRef"` + + // VolumeSnapshotContentRef is a reference to the volume snapshot content resource + VolumeSnapshotContentRef core_v1.LocalObjectReference `json:"volumeSnapshotContentRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentRef"` } // VolumeGroupSnapshotContentSource represents the CSI source of a group snapshot. // Exactly one of its members must be set. // Members in VolumeGroupSnapshotContentSource are immutable. +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeHandles) || has(self.volumeHandles)", message="volumeHandles is required once set" +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.groupSnapshotHandles) || has(self.groupSnapshotHandles)", message="groupSnapshotHandles is required once set" +// +kubebuilder:validation:XValidation:rule="(has(self.volumeHandles) && !has(self.groupSnapshotHandles)) || (!has(self.volumeHandles) && has(self.groupSnapshotHandles))", message="exactly one of volumeHandles and groupSnapshotHandles must be set" type VolumeGroupSnapshotContentSource struct { // VolumeHandles is a list of volume handles on the backend to be snapshotted // together. It is specified for dynamic provisioning of the VolumeGroupSnapshot. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeHandles is immutable" VolumeHandles []string `json:"volumeHandles,omitempty" protobuf:"bytes,1,opt,name=volumeHandles"` // GroupSnapshotHandles specifies the CSI "group_snapshot_id" of a pre-existing @@ -360,6 +391,7 @@ type VolumeGroupSnapshotContentSource struct { // representation was (or should be) created. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="groupSnapshotHandles is immutable" GroupSnapshotHandles *GroupSnapshotHandles `json:"groupSnapshotHandles,omitempty" protobuf:"bytes,2,opt,name=groupSnapshotHandles"` } diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go similarity index 88% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go index 820cbb91a1f..dd58419d93f 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go @@ -22,8 +22,7 @@ limitations under the License. package v1alpha1 import ( - v1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" - corev1 "k8s.io/api/core/v1" + v1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -49,6 +48,42 @@ func (in *GroupSnapshotHandles) DeepCopy() *GroupSnapshotHandles { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PVCVolumeSnapshotPair) DeepCopyInto(out *PVCVolumeSnapshotPair) { + *out = *in + out.PersistentVolumeClaimRef = in.PersistentVolumeClaimRef + out.VolumeSnapshotRef = in.VolumeSnapshotRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PVCVolumeSnapshotPair. +func (in *PVCVolumeSnapshotPair) DeepCopy() *PVCVolumeSnapshotPair { + if in == nil { + return nil + } + out := new(PVCVolumeSnapshotPair) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PVVolumeSnapshotContentPair) DeepCopyInto(out *PVVolumeSnapshotContentPair) { + *out = *in + out.PersistentVolumeRef = in.PersistentVolumeRef + out.VolumeSnapshotContentRef = in.VolumeSnapshotContentRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PVVolumeSnapshotContentPair. +func (in *PVVolumeSnapshotContentPair) DeepCopy() *PVVolumeSnapshotContentPair { + if in == nil { + return nil + } + out := new(PVVolumeSnapshotContentPair) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeGroupSnapshot) DeepCopyInto(out *VolumeGroupSnapshot) { *out = *in @@ -284,9 +319,9 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapsho *out = new(v1.VolumeSnapshotError) (*in).DeepCopyInto(*out) } - if in.VolumeSnapshotContentRefList != nil { - in, out := &in.VolumeSnapshotContentRefList, &out.VolumeSnapshotContentRefList - *out = make([]corev1.ObjectReference, len(*in)) + if in.PVVolumeSnapshotContentList != nil { + in, out := &in.PVVolumeSnapshotContentList, &out.PVVolumeSnapshotContentList + *out = make([]PVVolumeSnapshotContentPair, len(*in)) copy(*out, *in) } return @@ -405,9 +440,9 @@ func (in *VolumeGroupSnapshotStatus) DeepCopyInto(out *VolumeGroupSnapshotStatus *out = new(v1.VolumeSnapshotError) (*in).DeepCopyInto(*out) } - if in.VolumeSnapshotRefList != nil { - in, out := &in.VolumeSnapshotRefList, &out.VolumeSnapshotRefList - *out = make([]corev1.ObjectReference, len(*in)) + if in.PVCVolumeSnapshotRefList != nil { + in, out := &in.PVCVolumeSnapshotRefList, &out.PVCVolumeSnapshotRefList + *out = make([]PVCVolumeSnapshotPair, len(*in)) copy(*out, *in) } return diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/doc.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/doc.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/doc.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/doc.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/register.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/register.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/register.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/register.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/types.go similarity index 91% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/types.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/types.go index fdb867cdbc7..36f60dc9588 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/types.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/types.go @@ -91,6 +91,7 @@ type VolumeSnapshotSpec struct { // CreateSnapshot will fail and generate an event. // Empty string is not allowed for this field. // +optional + // +kubebuilder:validation:XValidation:rule="size(self) > 0",message="volumeSnapshotClassName must not be the empty string when set" VolumeSnapshotClassName *string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotClassName"` } @@ -99,6 +100,9 @@ type VolumeSnapshotSpec struct { // object should be used. // Exactly one of its members must be set. // Members in VolumeSnapshotSource are immutable. +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.persistentVolumeClaimName) || has(self.persistentVolumeClaimName)", message="persistentVolumeClaimName is required once set" +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeSnapshotContentName) || has(self.volumeSnapshotContentName)", message="volumeSnapshotContentName is required once set" +// +kubebuilder:validation:XValidation:rule="(has(self.volumeSnapshotContentName) && !has(self.persistentVolumeClaimName)) || (!has(self.volumeSnapshotContentName) && has(self.persistentVolumeClaimName))", message="exactly one of volumeSnapshotContentName and persistentVolumeClaimName must be set" type VolumeSnapshotSource struct { // persistentVolumeClaimName specifies the name of the PersistentVolumeClaim // object representing the volume from which a snapshot should be created. @@ -108,6 +112,7 @@ type VolumeSnapshotSource struct { // created. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="persistentVolumeClaimName is immutable" PersistentVolumeClaimName *string `json:"persistentVolumeClaimName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeClaimName"` // volumeSnapshotContentName specifies the name of a pre-existing VolumeSnapshotContent @@ -115,6 +120,7 @@ type VolumeSnapshotSource struct { // This field should be set if the snapshot already exists and only needs a representation in Kubernetes. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeSnapshotContentName is immutable" VolumeSnapshotContentName *string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"` } @@ -258,6 +264,7 @@ type VolumeSnapshotClassList struct { // +kubebuilder:printcolumn:name="Driver",type=string,JSONPath=`.spec.driver`,description="Name of the CSI driver used to create the physical snapshot on the underlying storage system." // +kubebuilder:printcolumn:name="VolumeSnapshotClass",type=string,JSONPath=`.spec.volumeSnapshotClassName`,description="Name of the VolumeSnapshotClass to which this snapshot belongs." // +kubebuilder:printcolumn:name="VolumeSnapshot",type=string,JSONPath=`.spec.volumeSnapshotRef.name`,description="Name of the VolumeSnapshot object to which this VolumeSnapshotContent object is bound." +// +kubebuilder:printcolumn:name="VolumeSnapshotNamespace",type=string,JSONPath=`.spec.volumeSnapshotRef.namespace`,description="Namespace of the VolumeSnapshot object to which this VolumeSnapshotContent object is bound." // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` type VolumeSnapshotContent struct { metav1.TypeMeta `json:",inline"` @@ -289,6 +296,7 @@ type VolumeSnapshotContentList struct { } // VolumeSnapshotContentSpec is the specification of a VolumeSnapshotContent +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.sourceVolumeMode) || has(self.sourceVolumeMode)", message="sourceVolumeMode is required once set" type VolumeSnapshotContentSpec struct { // volumeSnapshotRef specifies the VolumeSnapshot object to which this // VolumeSnapshotContent object is bound. @@ -298,6 +306,7 @@ type VolumeSnapshotContentSpec struct { // VolumeSnapshot object MUST be provided for binding to happen. // This field is immutable after creation. // Required. + // +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both spec.volumeSnapshotRef.name and spec.volumeSnapshotRef.namespace must be set" VolumeSnapshotRef core_v1.ObjectReference `json:"volumeSnapshotRef" protobuf:"bytes,1,opt,name=volumeSnapshotRef"` // deletionPolicy determines whether this VolumeSnapshotContent and its physical snapshot on @@ -340,17 +349,22 @@ type VolumeSnapshotContentSpec struct { // This field is immutable. // This field is an alpha field. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="sourceVolumeMode is immutable" SourceVolumeMode *core_v1.PersistentVolumeMode `json:"sourceVolumeMode" protobuf:"bytes,6,opt,name=sourceVolumeMode"` } // VolumeSnapshotContentSource represents the CSI source of a snapshot. // Exactly one of its members must be set. // Members in VolumeSnapshotContentSource are immutable. +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeHandle) || has(self.volumeHandle)", message="volumeHandle is required once set" +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.snapshotHandle) || has(self.snapshotHandle)", message="snapshotHandle is required once set" +// +kubebuilder:validation:XValidation:rule="(has(self.volumeHandle) && !has(self.snapshotHandle)) || (!has(self.volumeHandle) && has(self.snapshotHandle))", message="exactly one of volumeHandle and snapshotHandle must be set" type VolumeSnapshotContentSource struct { // volumeHandle specifies the CSI "volume_id" of the volume from which a snapshot // should be dynamically taken from. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeHandle is immutable" VolumeHandle *string `json:"volumeHandle,omitempty" protobuf:"bytes,1,opt,name=volumeHandle"` // snapshotHandle specifies the CSI "snapshot_id" of a pre-existing snapshot on @@ -358,6 +372,7 @@ type VolumeSnapshotContentSource struct { // was (or should be) created. // This field is immutable. // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="snapshotHandle is immutable" SnapshotHandle *string `json:"snapshotHandle,omitempty" protobuf:"bytes,2,opt,name=snapshotHandle"` } diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/zz_generated.deepcopy.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1/zz_generated.deepcopy.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/zz_generated.deepcopy.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme/doc.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme/doc.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme/doc.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme/doc.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme/register.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme/register.go similarity index 96% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme/register.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme/register.go index 10104e68009..7ecf08084f6 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme/register.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme/register.go @@ -19,8 +19,8 @@ limitations under the License. package scheme import ( - groupsnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1" - snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" + groupsnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/doc.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/doc.go new file mode 100644 index 00000000000..ecc54622106 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/generated_expansion.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..76c6ee96a6f --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type VolumeGroupSnapshotExpansion interface{} + +type VolumeGroupSnapshotClassExpansion interface{} + +type VolumeGroupSnapshotContentExpansion interface{} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshot.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshot.go new file mode 100644 index 00000000000..413d6bcac87 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshot.go @@ -0,0 +1,195 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + scheme "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// VolumeGroupSnapshotsGetter has a method to return a VolumeGroupSnapshotInterface. +// A group's client should implement this interface. +type VolumeGroupSnapshotsGetter interface { + VolumeGroupSnapshots(namespace string) VolumeGroupSnapshotInterface +} + +// VolumeGroupSnapshotInterface has methods to work with VolumeGroupSnapshot resources. +type VolumeGroupSnapshotInterface interface { + Create(ctx context.Context, volumeGroupSnapshot *v1alpha1.VolumeGroupSnapshot, opts v1.CreateOptions) (*v1alpha1.VolumeGroupSnapshot, error) + Update(ctx context.Context, volumeGroupSnapshot *v1alpha1.VolumeGroupSnapshot, opts v1.UpdateOptions) (*v1alpha1.VolumeGroupSnapshot, error) + UpdateStatus(ctx context.Context, volumeGroupSnapshot *v1alpha1.VolumeGroupSnapshot, opts v1.UpdateOptions) (*v1alpha1.VolumeGroupSnapshot, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.VolumeGroupSnapshot, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.VolumeGroupSnapshotList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VolumeGroupSnapshot, err error) + VolumeGroupSnapshotExpansion +} + +// volumeGroupSnapshots implements VolumeGroupSnapshotInterface +type volumeGroupSnapshots struct { + client rest.Interface + ns string +} + +// newVolumeGroupSnapshots returns a VolumeGroupSnapshots +func newVolumeGroupSnapshots(c *GroupsnapshotV1alpha1Client, namespace string) *volumeGroupSnapshots { + return &volumeGroupSnapshots{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the volumeGroupSnapshot, and returns the corresponding volumeGroupSnapshot object, and an error if there is any. +func (c *volumeGroupSnapshots) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.VolumeGroupSnapshot, err error) { + result = &v1alpha1.VolumeGroupSnapshot{} + err = c.client.Get(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VolumeGroupSnapshots that match those selectors. +func (c *volumeGroupSnapshots) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeGroupSnapshotList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.VolumeGroupSnapshotList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested volumeGroupSnapshots. +func (c *volumeGroupSnapshots) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a volumeGroupSnapshot and creates it. Returns the server's representation of the volumeGroupSnapshot, and an error, if there is any. +func (c *volumeGroupSnapshots) Create(ctx context.Context, volumeGroupSnapshot *v1alpha1.VolumeGroupSnapshot, opts v1.CreateOptions) (result *v1alpha1.VolumeGroupSnapshot, err error) { + result = &v1alpha1.VolumeGroupSnapshot{} + err = c.client.Post(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshot). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a volumeGroupSnapshot and updates it. Returns the server's representation of the volumeGroupSnapshot, and an error, if there is any. +func (c *volumeGroupSnapshots) Update(ctx context.Context, volumeGroupSnapshot *v1alpha1.VolumeGroupSnapshot, opts v1.UpdateOptions) (result *v1alpha1.VolumeGroupSnapshot, err error) { + result = &v1alpha1.VolumeGroupSnapshot{} + err = c.client.Put(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + Name(volumeGroupSnapshot.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshot). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *volumeGroupSnapshots) UpdateStatus(ctx context.Context, volumeGroupSnapshot *v1alpha1.VolumeGroupSnapshot, opts v1.UpdateOptions) (result *v1alpha1.VolumeGroupSnapshot, err error) { + result = &v1alpha1.VolumeGroupSnapshot{} + err = c.client.Put(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + Name(volumeGroupSnapshot.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshot). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the volumeGroupSnapshot and deletes it. Returns an error if one occurs. +func (c *volumeGroupSnapshots) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *volumeGroupSnapshots) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched volumeGroupSnapshot. +func (c *volumeGroupSnapshots) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VolumeGroupSnapshot, err error) { + result = &v1alpha1.VolumeGroupSnapshot{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("volumegroupsnapshots"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshot_client.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshot_client.go new file mode 100644 index 00000000000..14cf7707d41 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshot_client.go @@ -0,0 +1,117 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type GroupsnapshotV1alpha1Interface interface { + RESTClient() rest.Interface + VolumeGroupSnapshotsGetter + VolumeGroupSnapshotClassesGetter + VolumeGroupSnapshotContentsGetter +} + +// GroupsnapshotV1alpha1Client is used to interact with features provided by the groupsnapshot.storage.k8s.io group. +type GroupsnapshotV1alpha1Client struct { + restClient rest.Interface +} + +func (c *GroupsnapshotV1alpha1Client) VolumeGroupSnapshots(namespace string) VolumeGroupSnapshotInterface { + return newVolumeGroupSnapshots(c, namespace) +} + +func (c *GroupsnapshotV1alpha1Client) VolumeGroupSnapshotClasses() VolumeGroupSnapshotClassInterface { + return newVolumeGroupSnapshotClasses(c) +} + +func (c *GroupsnapshotV1alpha1Client) VolumeGroupSnapshotContents() VolumeGroupSnapshotContentInterface { + return newVolumeGroupSnapshotContents(c) +} + +// NewForConfig creates a new GroupsnapshotV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*GroupsnapshotV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new GroupsnapshotV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*GroupsnapshotV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &GroupsnapshotV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new GroupsnapshotV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *GroupsnapshotV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new GroupsnapshotV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *GroupsnapshotV1alpha1Client { + return &GroupsnapshotV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *GroupsnapshotV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshotclass.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshotclass.go new file mode 100644 index 00000000000..7abdf2c6b76 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshotclass.go @@ -0,0 +1,168 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + scheme "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// VolumeGroupSnapshotClassesGetter has a method to return a VolumeGroupSnapshotClassInterface. +// A group's client should implement this interface. +type VolumeGroupSnapshotClassesGetter interface { + VolumeGroupSnapshotClasses() VolumeGroupSnapshotClassInterface +} + +// VolumeGroupSnapshotClassInterface has methods to work with VolumeGroupSnapshotClass resources. +type VolumeGroupSnapshotClassInterface interface { + Create(ctx context.Context, volumeGroupSnapshotClass *v1alpha1.VolumeGroupSnapshotClass, opts v1.CreateOptions) (*v1alpha1.VolumeGroupSnapshotClass, error) + Update(ctx context.Context, volumeGroupSnapshotClass *v1alpha1.VolumeGroupSnapshotClass, opts v1.UpdateOptions) (*v1alpha1.VolumeGroupSnapshotClass, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.VolumeGroupSnapshotClass, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.VolumeGroupSnapshotClassList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VolumeGroupSnapshotClass, err error) + VolumeGroupSnapshotClassExpansion +} + +// volumeGroupSnapshotClasses implements VolumeGroupSnapshotClassInterface +type volumeGroupSnapshotClasses struct { + client rest.Interface +} + +// newVolumeGroupSnapshotClasses returns a VolumeGroupSnapshotClasses +func newVolumeGroupSnapshotClasses(c *GroupsnapshotV1alpha1Client) *volumeGroupSnapshotClasses { + return &volumeGroupSnapshotClasses{ + client: c.RESTClient(), + } +} + +// Get takes name of the volumeGroupSnapshotClass, and returns the corresponding volumeGroupSnapshotClass object, and an error if there is any. +func (c *volumeGroupSnapshotClasses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.VolumeGroupSnapshotClass, err error) { + result = &v1alpha1.VolumeGroupSnapshotClass{} + err = c.client.Get(). + Resource("volumegroupsnapshotclasses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VolumeGroupSnapshotClasses that match those selectors. +func (c *volumeGroupSnapshotClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeGroupSnapshotClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.VolumeGroupSnapshotClassList{} + err = c.client.Get(). + Resource("volumegroupsnapshotclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested volumeGroupSnapshotClasses. +func (c *volumeGroupSnapshotClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("volumegroupsnapshotclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a volumeGroupSnapshotClass and creates it. Returns the server's representation of the volumeGroupSnapshotClass, and an error, if there is any. +func (c *volumeGroupSnapshotClasses) Create(ctx context.Context, volumeGroupSnapshotClass *v1alpha1.VolumeGroupSnapshotClass, opts v1.CreateOptions) (result *v1alpha1.VolumeGroupSnapshotClass, err error) { + result = &v1alpha1.VolumeGroupSnapshotClass{} + err = c.client.Post(). + Resource("volumegroupsnapshotclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshotClass). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a volumeGroupSnapshotClass and updates it. Returns the server's representation of the volumeGroupSnapshotClass, and an error, if there is any. +func (c *volumeGroupSnapshotClasses) Update(ctx context.Context, volumeGroupSnapshotClass *v1alpha1.VolumeGroupSnapshotClass, opts v1.UpdateOptions) (result *v1alpha1.VolumeGroupSnapshotClass, err error) { + result = &v1alpha1.VolumeGroupSnapshotClass{} + err = c.client.Put(). + Resource("volumegroupsnapshotclasses"). + Name(volumeGroupSnapshotClass.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshotClass). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the volumeGroupSnapshotClass and deletes it. Returns an error if one occurs. +func (c *volumeGroupSnapshotClasses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("volumegroupsnapshotclasses"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *volumeGroupSnapshotClasses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("volumegroupsnapshotclasses"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched volumeGroupSnapshotClass. +func (c *volumeGroupSnapshotClasses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VolumeGroupSnapshotClass, err error) { + result = &v1alpha1.VolumeGroupSnapshotClass{} + err = c.client.Patch(pt). + Resource("volumegroupsnapshotclasses"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshotcontent.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshotcontent.go new file mode 100644 index 00000000000..e27f3d09257 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1/volumegroupsnapshotcontent.go @@ -0,0 +1,184 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + scheme "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// VolumeGroupSnapshotContentsGetter has a method to return a VolumeGroupSnapshotContentInterface. +// A group's client should implement this interface. +type VolumeGroupSnapshotContentsGetter interface { + VolumeGroupSnapshotContents() VolumeGroupSnapshotContentInterface +} + +// VolumeGroupSnapshotContentInterface has methods to work with VolumeGroupSnapshotContent resources. +type VolumeGroupSnapshotContentInterface interface { + Create(ctx context.Context, volumeGroupSnapshotContent *v1alpha1.VolumeGroupSnapshotContent, opts v1.CreateOptions) (*v1alpha1.VolumeGroupSnapshotContent, error) + Update(ctx context.Context, volumeGroupSnapshotContent *v1alpha1.VolumeGroupSnapshotContent, opts v1.UpdateOptions) (*v1alpha1.VolumeGroupSnapshotContent, error) + UpdateStatus(ctx context.Context, volumeGroupSnapshotContent *v1alpha1.VolumeGroupSnapshotContent, opts v1.UpdateOptions) (*v1alpha1.VolumeGroupSnapshotContent, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.VolumeGroupSnapshotContent, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.VolumeGroupSnapshotContentList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VolumeGroupSnapshotContent, err error) + VolumeGroupSnapshotContentExpansion +} + +// volumeGroupSnapshotContents implements VolumeGroupSnapshotContentInterface +type volumeGroupSnapshotContents struct { + client rest.Interface +} + +// newVolumeGroupSnapshotContents returns a VolumeGroupSnapshotContents +func newVolumeGroupSnapshotContents(c *GroupsnapshotV1alpha1Client) *volumeGroupSnapshotContents { + return &volumeGroupSnapshotContents{ + client: c.RESTClient(), + } +} + +// Get takes name of the volumeGroupSnapshotContent, and returns the corresponding volumeGroupSnapshotContent object, and an error if there is any. +func (c *volumeGroupSnapshotContents) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.VolumeGroupSnapshotContent, err error) { + result = &v1alpha1.VolumeGroupSnapshotContent{} + err = c.client.Get(). + Resource("volumegroupsnapshotcontents"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VolumeGroupSnapshotContents that match those selectors. +func (c *volumeGroupSnapshotContents) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeGroupSnapshotContentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.VolumeGroupSnapshotContentList{} + err = c.client.Get(). + Resource("volumegroupsnapshotcontents"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested volumeGroupSnapshotContents. +func (c *volumeGroupSnapshotContents) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("volumegroupsnapshotcontents"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a volumeGroupSnapshotContent and creates it. Returns the server's representation of the volumeGroupSnapshotContent, and an error, if there is any. +func (c *volumeGroupSnapshotContents) Create(ctx context.Context, volumeGroupSnapshotContent *v1alpha1.VolumeGroupSnapshotContent, opts v1.CreateOptions) (result *v1alpha1.VolumeGroupSnapshotContent, err error) { + result = &v1alpha1.VolumeGroupSnapshotContent{} + err = c.client.Post(). + Resource("volumegroupsnapshotcontents"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshotContent). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a volumeGroupSnapshotContent and updates it. Returns the server's representation of the volumeGroupSnapshotContent, and an error, if there is any. +func (c *volumeGroupSnapshotContents) Update(ctx context.Context, volumeGroupSnapshotContent *v1alpha1.VolumeGroupSnapshotContent, opts v1.UpdateOptions) (result *v1alpha1.VolumeGroupSnapshotContent, err error) { + result = &v1alpha1.VolumeGroupSnapshotContent{} + err = c.client.Put(). + Resource("volumegroupsnapshotcontents"). + Name(volumeGroupSnapshotContent.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshotContent). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *volumeGroupSnapshotContents) UpdateStatus(ctx context.Context, volumeGroupSnapshotContent *v1alpha1.VolumeGroupSnapshotContent, opts v1.UpdateOptions) (result *v1alpha1.VolumeGroupSnapshotContent, err error) { + result = &v1alpha1.VolumeGroupSnapshotContent{} + err = c.client.Put(). + Resource("volumegroupsnapshotcontents"). + Name(volumeGroupSnapshotContent.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(volumeGroupSnapshotContent). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the volumeGroupSnapshotContent and deletes it. Returns an error if one occurs. +func (c *volumeGroupSnapshotContents) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("volumegroupsnapshotcontents"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *volumeGroupSnapshotContents) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("volumegroupsnapshotcontents"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched volumeGroupSnapshotContent. +func (c *volumeGroupSnapshotContents) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VolumeGroupSnapshotContent, err error) { + result = &v1alpha1.VolumeGroupSnapshotContent{} + err = c.client.Patch(pt). + Resource("volumegroupsnapshotcontents"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/doc.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/doc.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/doc.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/doc.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/generated_expansion.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/generated_expansion.go similarity index 100% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/generated_expansion.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/generated_expansion.go diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot.go similarity index 98% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot.go index 81b6579e496..c99b4917503 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot.go @@ -22,8 +22,8 @@ import ( "context" "time" - v1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" - scheme "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme" + v1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" + scheme "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot_client.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot_client.go similarity index 96% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot_client.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot_client.go index 42fe7776437..877208fd6c2 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot_client.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshot_client.go @@ -21,8 +21,8 @@ package v1 import ( "net/http" - v1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" - "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme" + v1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" + "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotclass.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotclass.go similarity index 98% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotclass.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotclass.go index b1edaa75da2..5fa38735a81 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotclass.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotclass.go @@ -22,8 +22,8 @@ import ( "context" "time" - v1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" - scheme "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme" + v1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" + scheme "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotcontent.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotcontent.go similarity index 98% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotcontent.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotcontent.go index ff40a76ccbc..d425cb3db53 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotcontent.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1/volumesnapshotcontent.go @@ -22,8 +22,8 @@ import ( "context" "time" - v1 "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" - scheme "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme" + v1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" + scheme "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" diff --git a/vendor/modules.txt b/vendor/modules.txt index b89dec03113..708e5690cce 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -472,12 +472,13 @@ github.com/kubernetes-csi/csi-lib-utils/connection github.com/kubernetes-csi/csi-lib-utils/metrics github.com/kubernetes-csi/csi-lib-utils/protosanitizer github.com/kubernetes-csi/csi-lib-utils/rpc -# github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0 -## explicit; go 1.21 -github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1 -github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1 -github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/scheme -github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1 +# github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0 +## explicit; go 1.22.0 +github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1 +github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1 +github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/scheme +github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumegroupsnapshot/v1alpha1 +github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/typed/volumesnapshot/v1 # github.com/kylelemons/godebug v1.1.0 ## explicit; go 1.11 github.com/kylelemons/godebug/diff