From 89f459e84edbba90292c35f7fbaf71f1cafd5311 Mon Sep 17 00:00:00 2001 From: raaizik <132667934+raaizik@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:37:12 +0300 Subject: [PATCH] controllers: Generates VGSClass Signed-off-by: raaizik <132667934+raaizik@users.noreply.github.com> --- ...client-operator.clusterserviceversion.yaml | 20 +- cmd/main.go | 3 +- config/rbac/role.yaml | 18 + go.mod | 2 +- go.sum | 4 +- .../operatorconfigmap_controller.go | 5 + .../controller/storageclaim_controller.go | 212 ++++---- pkg/utils/k8sutils.go | 51 ++ .../client/{v6 => v8}/LICENSE | 0 .../apis/volumegroupsnapshot/v1alpha1/doc.go | 20 + .../volumegroupsnapshot/v1alpha1/register.go | 57 +++ .../volumegroupsnapshot/v1alpha1/types.go | 412 ++++++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 459 ++++++++++++++++++ .../{v6 => v8}/apis/volumesnapshot/v1/doc.go | 0 .../apis/volumesnapshot/v1/register.go | 0 .../apis/volumesnapshot/v1/types.go | 21 +- .../v1/zz_generated.deepcopy.go | 6 +- vendor/modules.txt | 7 +- 18 files changed, 1165 insertions(+), 132 deletions(-) rename vendor/github.com/kubernetes-csi/external-snapshotter/client/{v6 => v8}/LICENSE (100%) create mode 100644 vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/doc.go create mode 100644 vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/register.go create mode 100644 vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go create mode 100644 vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go rename vendor/github.com/kubernetes-csi/external-snapshotter/client/{v6 => v8}/apis/volumesnapshot/v1/doc.go (100%) rename vendor/github.com/kubernetes-csi/external-snapshotter/client/{v6 => v8}/apis/volumesnapshot/v1/register.go (100%) rename vendor/github.com/kubernetes-csi/external-snapshotter/client/{v6 => v8}/apis/volumesnapshot/v1/types.go (90%) rename vendor/github.com/kubernetes-csi/external-snapshotter/client/{v6 => v8}/apis/volumesnapshot/v1/zz_generated.deepcopy.go (98%) diff --git a/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml b/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml index 80de0fd44..38d93afd4 100644 --- a/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml +++ b/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml @@ -7,7 +7,7 @@ metadata: categories: Storage console.openshift.io/plugins: '["odf-client-console"]' containerImage: quay.io/ocs-dev/ocs-client-operator:latest - createdAt: "2024-10-29T07:06:57Z" + createdAt: "2024-10-30T11:43:15Z" description: OpenShift Data Foundation client operator enables consumption of storage services from a remote centralized OpenShift Data Foundation provider cluster. @@ -197,6 +197,24 @@ spec: - list - update - watch + - apiGroups: + - groupsnapshot.storage.k8s.io + resources: + - volumegroupsnapshotclasses + verbs: + - create + - delete + - get + - list + - watch + - apiGroups: + - groupsnapshot.storage.k8s.io + resources: + - volumegroupsnapshotcontents + verbs: + - get + - list + - watch - apiGroups: - monitoring.coreos.com resources: diff --git a/cmd/main.go b/cmd/main.go index f9f2d91df..9465b60cf 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -31,7 +31,7 @@ import ( // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. csiopv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" nbapis "github.com/noobaa/noobaa-operator/v5/pkg/apis" configv1 "github.com/openshift/api/config/v1" consolev1 "github.com/openshift/api/console/v1" @@ -203,6 +203,7 @@ func main() { Scheme: mgr.GetScheme(), OperatorNamespace: utils.GetOperatorNamespace(), ConsolePort: int32(consolePort), + AvailCrds: availCrds, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "OperatorConfigMapReconciler") os.Exit(1) diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index a10832889..82cd9683a 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -154,6 +154,24 @@ rules: - list - update - watch +- apiGroups: + - groupsnapshot.storage.k8s.io + resources: + - volumegroupsnapshotclasses + verbs: + - create + - delete + - get + - list + - watch +- apiGroups: + - groupsnapshot.storage.k8s.io + resources: + - volumegroupsnapshotcontents + verbs: + - get + - list + - watch - apiGroups: - monitoring.coreos.com resources: diff --git a/go.mod b/go.mod index c0d6f4824..6efd61f15 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ exclude ( require ( github.com/ceph/ceph-csi-operator/api v0.0.0-20240812072523-4d50cf3a32a0 github.com/go-logr/logr v1.4.2 - github.com/kubernetes-csi/external-snapshotter/client/v6 v6.3.0 + github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.34.1 github.com/openshift/api v0.0.0-20240828125535-01b3675ba7b3 diff --git a/go.sum b/go.sum index 5482fdc75..8451b4263 100644 --- a/go.sum +++ b/go.sum @@ -254,8 +254,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 h1:dQEHhTfi+bSIOSViQrKY9PqJvZenD6tFz+3lPzux58o= github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1/go.mod h1:my+EVjOJLeQ9lUR9uVkxRvNNkhO2saSGIgzV8GZT9HY= -github.com/kubernetes-csi/external-snapshotter/client/v6 v6.3.0 h1:qS4r4ljINLWKJ9m9Ge3Q3sGZ/eIoDVDT2RhAdQFHb1k= -github.com/kubernetes-csi/external-snapshotter/client/v6 v6.3.0/go.mod h1:oGXx2XTEzs9ikW2V6IC1dD8trgjRsS/Mvc2JRiC618Y= +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/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/internal/controller/operatorconfigmap_controller.go b/internal/controller/operatorconfigmap_controller.go index 3920269fe..c75c8f933 100644 --- a/internal/controller/operatorconfigmap_controller.go +++ b/internal/controller/operatorconfigmap_controller.go @@ -79,6 +79,7 @@ type OperatorConfigMapReconciler struct { OperatorNamespace string ConsolePort int32 Scheme *runtime.Scheme + AvailCrds map[string]bool log logr.Logger ctx context.Context @@ -327,6 +328,10 @@ func (c *OperatorConfigMapReconciler) reconcileDelegatedCSI() error { templates.CSIOperatorConfigSpec.DeepCopyInto(&csiOperatorConfig.Spec) csiOperatorConfig.Spec.DriverSpecDefaults.ImageSet = &corev1.LocalObjectReference{Name: cmName} csiOperatorConfig.Spec.DriverSpecDefaults.ClusterName = ptr.To(string(clusterVersion.Spec.ClusterID)) + if c.AvailCrds[volumeGroupSnapshotClassCrd] { + csiOperatorConfig.Spec.DriverSpecDefaults.SnapshotPolicy = csiopv1a1.VolumeGroupSnapshotPolicy + } + return nil }); err != nil { return fmt.Errorf("failed to reconcile csi operator config: %v", err) diff --git a/internal/controller/storageclaim_controller.go b/internal/controller/storageclaim_controller.go index 6c3d8e479..d0344bd0b 100644 --- a/internal/controller/storageclaim_controller.go +++ b/internal/controller/storageclaim_controller.go @@ -20,7 +20,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "slices" "strings" "time" @@ -31,7 +30,9 @@ import ( csiopv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1" "github.com/go-logr/logr" - snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" + + groupsnapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" ramenv1alpha1 "github.com/ramendr/ramen/api/v1alpha1" providerclient "github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client" corev1 "k8s.io/api/core/v1" @@ -40,7 +41,6 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/cache" @@ -57,10 +57,10 @@ const ( storageClaimAnnotation = "ocs.openshift.io/storageclaim" keyRotationAnnotation = "keyrotation.csiaddons.openshift.io/schedule" - pvClusterIDIndexName = "index:persistentVolumeClusterID" - vscClusterIDIndexName = "index:volumeSnapshotContentCSIDriver" - - drClusterConfigCRDName = "drclusterconfigs.ramendr.openshift.io" + pvClusterIDIndexName = "index:persistentVolumeClusterID" + vscClusterIDIndexName = "index:volumeSnapshotContentCSIDriver" + volumeGroupSnapshotClassCrd = "groupsnapshot.storage.k8s.io/volumegroupsnapshotclass" + drClusterConfigCRDName = "drclusterconfigs.ramendr.openshift.io" ) // StorageClaimReconciler reconciles a StorageClaim object @@ -117,16 +117,21 @@ func (r *StorageClaimReconciler) SetupWithManager(mgr ctrl.Manager) error { For(&v1alpha1.StorageClaim{}, builder.WithPredicates(generationChangePredicate)). Owns(&storagev1.StorageClass{}). Owns(&snapapi.VolumeSnapshotClass{}). + Owns(&csiopv1a1.ClientProfile{}, builder.WithPredicates(generationChangePredicate)). Watches( &extv1.CustomResourceDefinition{}, &handler.EnqueueRequestForObject{}, builder.WithPredicates( + utils.NamePredicate(volumeGroupSnapshotClassCrd), + utils.CrdCreateAndDeletePredicate(&r.log, volumeGroupSnapshotClassCrd, r.AvailableCrds[volumeGroupSnapshotClassCrd]), utils.NamePredicate(drClusterConfigCRDName), utils.CrdCreateAndDeletePredicate(&r.log, drClusterConfigCRDName, r.AvailableCrds[drClusterConfigCRDName]), ), builder.OnlyMetadata, - ). - Owns(&csiopv1a1.ClientProfile{}, builder.WithPredicates(generationChangePredicate)) + ) + if r.AvailableCrds[volumeGroupSnapshotClassCrd] { + bldr = bldr.Owns(&groupsnapapi.VolumeGroupSnapshotClass{}) + } if r.AvailableCrds[drClusterConfigCRDName] { bldr = bldr.Owns(&ramenv1alpha1.DRClusterConfig{}, builder.WithPredicates(generationChangePredicate)) @@ -141,8 +146,10 @@ func (r *StorageClaimReconciler) SetupWithManager(mgr ctrl.Manager) error { //+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;delete //+kubebuilder:rbac:groups=storage.k8s.io,resources=storageclasses,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotclasses,verbs=get;list;watch;create;delete +//+kubebuilder:rbac:groups=groupsnapshot.storage.k8s.io,resources=volumegroupsnapshotclasses,verbs=create;delete;get;list;watch //+kubebuilder:rbac:groups=core,resources=persistentvolumes,verbs=get;list;watch //+kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotcontents,verbs=get;list;watch +//+kubebuilder:rbac:groups=groupsnapshot.storage.k8s.io,resources=volumegroupsnapshotcontents,verbs=get;list;watch //+kubebuilder:rbac:groups=csi.ceph.io,resources=clientprofiles,verbs=get;list;update;create;watch;delete //+kubebuilder:rbac:groups=ramendr.openshift.io,resources=drclusterconfigs,verbs=get;list;update;create;watch;delete @@ -162,13 +169,15 @@ func (r *StorageClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request r.log.Info("Reconciling StorageClaim.") crd := &metav1.PartialObjectMetadata{} - crd.SetGroupVersionKind(extv1.SchemeGroupVersion.WithKind("CustomResourceDefinition")) - crd.Name = drClusterConfigCRDName - if err := r.Client.Get(ctx, client.ObjectKeyFromObject(crd), crd); client.IgnoreNotFound(err) != nil { - r.log.Error(err, "Failed to get CRD", "CRD", drClusterConfigCRDName) - return reconcile.Result{}, err + for _, crdName := range []string{volumeGroupSnapshotClassCrd, drClusterConfigCRDName} { + crd.SetGroupVersionKind(extv1.SchemeGroupVersion.WithKind("CustomResourceDefinition")) + crd.Name = crdName + if err := r.Client.Get(ctx, client.ObjectKeyFromObject(crd), crd); client.IgnoreNotFound(err) != nil { + r.log.Error(err, "Failed to get CRD", "CRD", crdName) + return reconcile.Result{}, err + } + utils.AssertEqual(r.AvailableCrds[crdName], crd.UID != "", utils.ExitCodeThatShouldRestartTheProcess) } - utils.AssertEqual(r.AvailableCrds[drClusterConfigCRDName], crd.UID != "", utils.ExitCodeThatShouldRestartTheProcess) // Fetch the StorageClaim instance r.storageClaim = &v1alpha1.StorageClaim{} @@ -387,12 +396,15 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) { data["clusterID"] = r.storageClaimHash if resource.Name == "cephfs" { - storageClass = r.getCephFSStorageClass(data) + storageClass = r.getCephFSStorageClass() } else if resource.Name == "ceph-rbd" { - storageClass = r.getCephRBDStorageClass(data) + storageClass = r.getCephRBDStorageClass() } utils.AddAnnotation(storageClass, storageClaimAnnotation, r.storageClaim.Name) - err = r.createOrReplaceStorageClass(storageClass) + err = utils.CreateOrReplace(r.ctx, r.Client, storageClass, func() error { + storageClass.Parameters = data + return nil + }) if err != nil { return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err) } @@ -408,14 +420,38 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) { // storageclaim is clusterscoped resources using its // hash as the clusterID data["clusterID"] = r.storageClaimHash - if resource.Name == "cephfs" { - volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data) - } else if resource.Name == "ceph-rbd" { - volumeSnapshotClass = r.getCephRBDVolumeSnapshotClass(data) - } + volumeSnapshotClass = r.getCephDriverVolumeSnapshotClass(resource.Labels, resource.Annotations) utils.AddAnnotation(volumeSnapshotClass, storageClaimAnnotation, r.storageClaim.Name) - if err := r.createOrReplaceVolumeSnapshotClass(volumeSnapshotClass); err != nil { - return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err) + err = utils.CreateOrReplace(r.ctx, r.Client, volumeSnapshotClass, func() error { + volumeSnapshotClass.Parameters = data + return nil + }) + if err != nil { + return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err) + } + case "VolumeGroupSnapshotClass": + // check for CRD availability + if r.AvailableCrds[("VolumeGroupSnapshotClass")] { + var volumeGroupSnapshotClass *groupsnapapi.VolumeGroupSnapshotClass + data := map[string]string{} + err = json.Unmarshal(resource.Data, &data) + if err != nil { + return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response: %v", err) + } + data["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = r.OperatorNamespace + // generate a new clusterID for cephfs subvolumegroup, as + // storageclaim is clusterscoped resources using its + // hash as the clusterID + data["clusterID"] = r.storageClaimHash + volumeGroupSnapshotClass = r.getCephDriverVolumeGroupSnapshotClass(resource.Labels, resource.Annotations) + utils.AddAnnotation(volumeGroupSnapshotClass, storageClaimAnnotation, r.storageClaim.Name) + err = utils.CreateOrReplace(r.ctx, r.Client, volumeGroupSnapshotClass, func() error { + volumeGroupSnapshotClass.Parameters = data + return nil + }) + if err != nil { + return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err) + } } case "ClientProfile": clientProfile := &csiopv1a1.ClientProfile{} @@ -459,6 +495,11 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) { } else if exist { return reconcile.Result{}, fmt.Errorf("one or more volumesnapshotcontents exist that are dependent on storageclaim %s", r.storageClaim.Name) } + if exist, err := r.hasVolumeGroupSnapshotContents(); err != nil { + return reconcile.Result{}, fmt.Errorf("failed to verify volumegroupsnapshotcontents dependent on storageclaim %q: %v", r.storageClaim.Name, err) + } else if exist { + return reconcile.Result{}, fmt.Errorf("one or more volumegroupsnapshotcontents exist that are dependent on storageclaim %s", r.storageClaim.Name) + } // Call `RevokeStorageClaim` service on the provider server with StorageClaim as a request message. // Check if StorageClaim is still exists (it might have been manually removed during the StorageClass @@ -482,7 +523,7 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) { return reconcile.Result{}, nil } -func (r *StorageClaimReconciler) getCephFSStorageClass(data map[string]string) *storagev1.StorageClass { +func (r *StorageClaimReconciler) getCephFSStorageClass() *storagev1.StorageClass { pvReclaimPolicy := corev1.PersistentVolumeReclaimDelete allowVolumeExpansion := true storageClass := &storagev1.StorageClass{ @@ -495,12 +536,11 @@ func (r *StorageClaimReconciler) getCephFSStorageClass(data map[string]string) * ReclaimPolicy: &pvReclaimPolicy, AllowVolumeExpansion: &allowVolumeExpansion, Provisioner: templates.CephFsDriverName, - Parameters: data, } return storageClass } -func (r *StorageClaimReconciler) getCephRBDStorageClass(data map[string]string) *storagev1.StorageClass { +func (r *StorageClaimReconciler) getCephRBDStorageClass() *storagev1.StorageClass { pvReclaimPolicy := corev1.PersistentVolumeReclaimDelete allowVolumeExpansion := true storageClass := &storagev1.StorageClass{ @@ -514,7 +554,6 @@ func (r *StorageClaimReconciler) getCephRBDStorageClass(data map[string]string) ReclaimPolicy: &pvReclaimPolicy, AllowVolumeExpansion: &allowVolumeExpansion, Provisioner: templates.RBDDriverName, - Parameters: data, } if r.storageClaim.Spec.EncryptionMethod != "" { @@ -523,66 +562,32 @@ func (r *StorageClaimReconciler) getCephRBDStorageClass(data map[string]string) return storageClass } -func (r *StorageClaimReconciler) getCephFSVolumeSnapshotClass(data map[string]string) *snapapi.VolumeSnapshotClass { +func (r *StorageClaimReconciler) getCephDriverVolumeSnapshotClass( + labels map[string]string, annotations map[string]string) *snapapi.VolumeSnapshotClass { volumesnapshotclass := &snapapi.VolumeSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ - Name: r.storageClaim.Name, + Name: r.storageClaim.Name, + Labels: labels, + Annotations: annotations, }, Driver: templates.CephFsDriverName, DeletionPolicy: snapapi.VolumeSnapshotContentDelete, - Parameters: data, } return volumesnapshotclass } -func (r *StorageClaimReconciler) getCephRBDVolumeSnapshotClass(data map[string]string) *snapapi.VolumeSnapshotClass { - volumesnapshotclass := &snapapi.VolumeSnapshotClass{ +func (r *StorageClaimReconciler) getCephDriverVolumeGroupSnapshotClass( + labels map[string]string, annotations map[string]string) *groupsnapapi.VolumeGroupSnapshotClass { + volumegroupsnapshotclass := &groupsnapapi.VolumeGroupSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ - Name: r.storageClaim.Name, + Name: r.storageClaim.Name, + Labels: labels, + Annotations: annotations, }, Driver: templates.RBDDriverName, DeletionPolicy: snapapi.VolumeSnapshotContentDelete, - Parameters: data, } - return volumesnapshotclass -} - -func (r *StorageClaimReconciler) createOrReplaceStorageClass(storageClass *storagev1.StorageClass) error { - existing := &storagev1.StorageClass{} - existing.Name = r.storageClaim.Name - - if err := r.own(storageClass); err != nil { - return fmt.Errorf("failed to own storageclass: %v", err) - } - - if err := r.get(existing); err != nil && !errors.IsNotFound(err) { - return fmt.Errorf("failed to get StorageClass: %v", err) - } - - // If present then compare the existing StorageClass with the received StorageClass, and only proceed if they differ. - if reflect.DeepEqual(existing.Parameters, storageClass.Parameters) { - return nil - } - - // StorageClass already exists, but parameters have changed. Delete the existing StorageClass and create a new one. - if existing.UID != "" { - - // Since we have to update the existing StorageClass, so we will delete the existing StorageClass and create a new one. - r.log.Info("StorageClass needs to be updated, deleting it.", "StorageClass", klog.KRef(storageClass.Namespace, existing.Name)) - - // Delete the StorageClass. - err := r.delete(existing) - if err != nil { - r.log.Error(err, "Failed to delete StorageClass.", "StorageClass", klog.KRef(storageClass.Namespace, existing.Name)) - return fmt.Errorf("failed to delete StorageClass: %v", err) - } - } - r.log.Info("Creating StorageClass.", "StorageClass", klog.KRef(storageClass.Namespace, existing.Name)) - err := r.Client.Create(r.ctx, storageClass) - if err != nil { - return fmt.Errorf("failed to create StorageClass: %v", err) - } - return nil + return volumegroupsnapshotclass } func (r *StorageClaimReconciler) get(obj client.Object) error { @@ -598,53 +603,10 @@ func (r *StorageClaimReconciler) list(obj client.ObjectList, listOptions ...clie return r.Client.List(r.ctx, obj, listOptions...) } -func (r *StorageClaimReconciler) delete(obj client.Object) error { - if err := r.Client.Delete(r.ctx, obj); err != nil && !errors.IsNotFound(err) { - return err - } - return nil -} - func (r *StorageClaimReconciler) own(resource metav1.Object) error { return controllerutil.SetControllerReference(r.storageClaim, resource, r.Scheme) } -func (r *StorageClaimReconciler) createOrReplaceVolumeSnapshotClass(volumeSnapshotClass *snapapi.VolumeSnapshotClass) error { - existing := &snapapi.VolumeSnapshotClass{} - existing.Name = r.storageClaim.Name - - if err := r.own(volumeSnapshotClass); err != nil { - return fmt.Errorf("failed to own volumesnapshotclass: %v", err) - } - - if err := r.get(existing); err != nil && !errors.IsNotFound(err) { - return fmt.Errorf("failed to get VolumeSnapshotClass: %v", err) - } - - // If present then compare the existing VolumeSnapshotClass parameters with - // the received VolumeSnapshotClass parameters, and only proceed if they differ. - if reflect.DeepEqual(existing.Parameters, volumeSnapshotClass.Parameters) { - return nil - } - - // VolumeSnapshotClass already exists, but parameters have changed. Delete the existing VolumeSnapshotClass and create a new one. - if existing.UID != "" { - // Since we have to update the existing VolumeSnapshotClass, so we will delete the existing VolumeSnapshotClass and create a new one. - r.log.Info("VolumeSnapshotClass needs to be updated, deleting it.", "Name", existing.Name) - - // Delete the VolumeSnapshotClass. - if err := r.delete(existing); err != nil { - r.log.Error(err, "Failed to delete VolumeSnapshotClass.", "Name", existing.Name) - return fmt.Errorf("failed to delete VolumeSnapshotClass: %v", err) - } - } - r.log.Info("Creating VolumeSnapshotClass.", "Name", existing.Name) - if err := r.Client.Create(r.ctx, volumeSnapshotClass); err != nil { - return fmt.Errorf("failed to create VolumeSnapshotClass: %v", err) - } - return nil -} - func (r *StorageClaimReconciler) hasPersistentVolumes() (bool, error) { pvList := &corev1.PersistentVolumeList{} if err := r.list(pvList, client.MatchingFields{pvClusterIDIndexName: r.storageClaimHash}, client.Limit(1)); err != nil { @@ -672,3 +634,17 @@ func (r *StorageClaimReconciler) hasVolumeSnapshotContents() (bool, error) { return false, nil } + +func (r *StorageClaimReconciler) hasVolumeGroupSnapshotContents() (bool, error) { + vscList := &groupsnapapi.VolumeGroupSnapshotContentList{} + if err := r.list(vscList, client.MatchingFields{vscClusterIDIndexName: r.storageClaimHash}); err != nil { + return false, fmt.Errorf("failed to list volume group snapshot content resources: %v", err) + } + + if len(vscList.Items) != 0 { + r.log.Info(fmt.Sprintf("VolumeGroupSnapshotContent referring storageclaim %q exists", r.storageClaim.Name)) + return true, nil + } + + return false, nil +} diff --git a/pkg/utils/k8sutils.go b/pkg/utils/k8sutils.go index 8f1a98a41..10a99c450 100644 --- a/pkg/utils/k8sutils.go +++ b/pkg/utils/k8sutils.go @@ -17,13 +17,18 @@ limitations under the License. package utils import ( + "context" "crypto/md5" "encoding/hex" "fmt" "maps" "os" + "reflect" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) // OperatorNamespaceEnvVar is the constant for env variable OPERATOR_NAMESPACE @@ -113,3 +118,49 @@ func GetMD5Hash(text string) string { hash := md5.Sum([]byte(text)) return hex.EncodeToString(hash[:]) } + +func CreateOrReplace(ctx context.Context, c client.Client, obj client.Object, f controllerutil.MutateFn) error { + key := client.ObjectKeyFromObject(obj) + if err := c.Get(ctx, key, obj); err != nil { + if !errors.IsNotFound(err) { + return err + } + if err := mutate(f, key, obj); err != nil { + return err + } + if err := c.Create(ctx, obj); err != nil { + return err + } + return nil + } + + existing := obj.DeepCopyObject() + if err := mutate(f, key, obj); err != nil { + return err + } + + if reflect.DeepEqual(existing, obj) { + return nil + } + + if err := c.Delete(ctx, obj); err != nil { + return err + } + + obj.SetResourceVersion("") + if err := c.Create(ctx, obj); err != nil { + return err + } + return nil +} + +// mutate wraps a MutateFn and applies validation to its result. +func mutate(f controllerutil.MutateFn, key client.ObjectKey, obj client.Object) error { + if err := f(); err != nil { + return err + } + if newKey := client.ObjectKeyFromObject(obj); key != newKey { + return fmt.Errorf("MutateFn cannot mutate object name and/or object namespace") + } + return nil +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/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/v6/LICENSE rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/LICENSE diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/doc.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/doc.go new file mode 100644 index 000000000..f3b8d19ef --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2023 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. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=groupsnapshot.storage.k8s.io + +package v1alpha1 diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/register.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/register.go new file mode 100644 index 000000000..42b82aaee --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2023 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. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package. +const GroupName = "groupsnapshot.storage.k8s.io" + +var ( + // SchemeBuilder is the new scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme adds to scheme + AddToScheme = SchemeBuilder.AddToScheme + // SchemeGroupVersion is the group version used to register these objects. + SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} +) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + SchemeBuilder.Register(addKnownTypes) +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &VolumeGroupSnapshotClass{}, + &VolumeGroupSnapshotClassList{}, + &VolumeGroupSnapshot{}, + &VolumeGroupSnapshotList{}, + &VolumeGroupSnapshotContent{}, + &VolumeGroupSnapshotContentList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go new file mode 100644 index 000000000..445a2ee01 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go @@ -0,0 +1,412 @@ +/* +Copyright 2023 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. +*/ +// +kubebuilder:object:generate=true +package v1alpha1 + +import ( + core_v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" +) + +// VolumeGroupSnapshotSpec defines the desired state of a volume group snapshot. +type VolumeGroupSnapshotSpec struct { + // Source specifies where a group snapshot will be created from. + // This field is immutable after creation. + // Required. + Source VolumeGroupSnapshotSource `json:"source" protobuf:"bytes,1,opt,name=source"` + + // VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass + // requested by the VolumeGroupSnapshot. + // VolumeGroupSnapshotClassName may be left nil to indicate that the default + // 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"` +} + +// VolumeGroupSnapshotSource specifies whether the underlying group snapshot should be +// dynamically taken upon creation or if a pre-existing VolumeGroupSnapshotContent +// 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. + // This labelSelector will be used to match the label added to a PVC. + // If the label is added or removed to a volume after a group snapshot + // is created, the existing group snapshots won't be modified. + // 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 + // object representing an existing volume group snapshot. + // This field should be set if the volume group snapshot already exists and + // 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"` +} + +// VolumeGroupSnapshotStatus defines the observed state of volume group snapshot. +type VolumeGroupSnapshotStatus struct { + // BoundVolumeGroupSnapshotContentName is the name of the VolumeGroupSnapshotContent + // object to which this VolumeGroupSnapshot object intends to bind to. + // If not specified, it indicates that the VolumeGroupSnapshot object has not + // been successfully bound to a VolumeGroupSnapshotContent object yet. + // NOTE: To avoid possible security issues, consumers must verify binding between + // VolumeGroupSnapshot and VolumeGroupSnapshotContent objects is successful + // (by validating that both VolumeGroupSnapshot and VolumeGroupSnapshotContent + // point at each other) before using this object. + // +optional + BoundVolumeGroupSnapshotContentName *string `json:"boundVolumeGroupSnapshotContentName,omitempty" protobuf:"bytes,1,opt,name=boundVolumeGroupSnapshotContentName"` + + // CreationTime is the timestamp when the point-in-time group snapshot is taken + // by the underlying storage system. + // If not specified, it may indicate that the creation time of the group snapshot + // is unknown. + // The format of this field is a Unix nanoseconds time encoded as an int64. + // On Unix, the command date +%s%N returns the current time in nanoseconds + // since 1970-01-01 00:00:00 UTC. + // +optional + CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"` + + // ReadyToUse indicates if all the individual snapshots in the group are ready + // to be used to restore a group of volumes. + // ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. + // If not specified, it means the readiness of a group snapshot is unknown. + // +optional + ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` + + // Error is the last observed error during group snapshot creation, if any. + // This field could be helpful to upper level controllers (i.e., application + // controller) to decide whether they should continue on waiting for the group + // snapshot to be created based on the type of error reported. + // The snapshot controller will keep retrying when an error occurs during the + // group snapshot creation. Upon success, this error field will be cleared. + // +optional + Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"` + + // 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 + 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 +//+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VolumeGroupSnapshot is a user's request for creating either a point-in-time +// group snapshot or binding to a pre-existing group snapshot. +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Namespaced,shortName=vgs +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="ReadyToUse",type=boolean,JSONPath=`.status.readyToUse`,description="Indicates if all the individual snapshots in the group are ready to be used to restore a group of volumes." +// +kubebuilder:printcolumn:name="VolumeGroupSnapshotClass",type=string,JSONPath=`.spec.volumeGroupSnapshotClassName`,description="The name of the VolumeGroupSnapshotClass requested by the VolumeGroupSnapshot." +// +kubebuilder:printcolumn:name="VolumeGroupSnapshotContent",type=string,JSONPath=`.status.boundVolumeGroupSnapshotContentName`,description="Name of the VolumeGroupSnapshotContent object to which the VolumeGroupSnapshot object intends to bind to. Please note that verification of binding actually requires checking both VolumeGroupSnapshot and VolumeGroupSnapshotContent to ensure both are pointing at each other. Binding MUST be verified prior to usage of this object." +// +kubebuilder:printcolumn:name="CreationTime",type=date,JSONPath=`.status.creationTime`,description="Timestamp when the point-in-time group snapshot was taken by the underlying storage system." +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` +type VolumeGroupSnapshot struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Spec defines the desired characteristics of a group snapshot requested by a user. + // Required. + Spec VolumeGroupSnapshotSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` + // Status represents the current information of a group snapshot. + // Consumers must verify binding between VolumeGroupSnapshot and + // VolumeGroupSnapshotContent objects is successful (by validating that both + // VolumeGroupSnapshot and VolumeGroupSnapshotContent point to each other) before + // using this object. + // +optional + Status *VolumeGroupSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// VolumeGroupSnapshotList contains a list of VolumeGroupSnapshot objects. +type VolumeGroupSnapshotList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + // Items is the list of VolumeGroupSnapshots. + Items []VolumeGroupSnapshot `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +//+genclient +//+genclient:nonNamespaced +//+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VolumeGroupSnapshotClass specifies parameters that a underlying storage system +// uses when creating a volume group snapshot. A specific VolumeGroupSnapshotClass +// is used by specifying its name in a VolumeGroupSnapshot object. +// VolumeGroupSnapshotClasses are non-namespaced. +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster,shortName=vgsclass;vgsclasses +// +kubebuilder:printcolumn:name="Driver",type=string,JSONPath=`.driver` +// +kubebuilder:printcolumn:name="DeletionPolicy",type=string,JSONPath=`.deletionPolicy`,description="Determines whether a VolumeGroupSnapshotContent created through the VolumeGroupSnapshotClass should be deleted when its bound VolumeGroupSnapshot is deleted." +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` +type VolumeGroupSnapshotClass struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Driver is the name of the storage driver expected to handle this VolumeGroupSnapshotClass. + // Required. + Driver string `json:"driver" protobuf:"bytes,2,opt,name=driver"` + + // Parameters is a key-value map with storage driver specific parameters for + // creating group snapshots. + // These values are opaque to Kubernetes and are passed directly to the driver. + // +optional + Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` + + // DeletionPolicy determines whether a VolumeGroupSnapshotContent created + // through the VolumeGroupSnapshotClass should be deleted when its bound + // VolumeGroupSnapshot is deleted. + // Supported values are "Retain" and "Delete". + // "Retain" means that the VolumeGroupSnapshotContent and its physical group + // snapshot on underlying storage system are kept. + // "Delete" means that the VolumeGroupSnapshotContent and its physical group + // snapshot on underlying storage system are deleted. + // Required. + DeletionPolicy snapshotv1.DeletionPolicy `json:"deletionPolicy" protobuf:"bytes,4,opt,name=deletionPolicy"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VolumeGroupSnapshotClassList is a collection of VolumeGroupSnapshotClasses. +// +kubebuilder:object:root=true +type VolumeGroupSnapshotClassList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Items is the list of VolumeGroupSnapshotClasses. + Items []VolumeGroupSnapshotClass `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VolumeGroupSnapshotContent represents the actual "on-disk" group snapshot object +// in the underlying storage system +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster,shortName=vgsc;vgscs +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="ReadyToUse",type=boolean,JSONPath=`.status.readyToUse`,description="Indicates if all the individual snapshots in the group are ready to be used to restore a group of volumes." +// +kubebuilder:printcolumn:name="DeletionPolicy",type=string,JSONPath=`.spec.deletionPolicy`,description="Determines whether this VolumeGroupSnapshotContent and its physical group snapshot on the underlying storage system should be deleted when its bound VolumeGroupSnapshot is deleted." +// +kubebuilder:printcolumn:name="Driver",type=string,JSONPath=`.spec.driver`,description="Name of the CSI driver used to create the physical group snapshot on the underlying storage system." +// +kubebuilder:printcolumn:name="VolumeGroupSnapshotClass",type=string,JSONPath=`.spec.volumeGroupSnapshotClassName`,description="Name of the VolumeGroupSnapshotClass from which this group snapshot was (or will be) created." +// +kubebuilder:printcolumn:name="VolumeGroupSnapshotNamespace",type=string,JSONPath=`.spec.volumeGroupSnapshotRef.namespace`,description="Namespace of the VolumeGroupSnapshot object to which this VolumeGroupSnapshotContent object is bound." +// +kubebuilder:printcolumn:name="VolumeGroupSnapshot",type=string,JSONPath=`.spec.volumeGroupSnapshotRef.name`,description="Name of the VolumeGroupSnapshot object to which this VolumeGroupSnapshotContent object is bound." +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` +type VolumeGroupSnapshotContent struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Spec defines properties of a VolumeGroupSnapshotContent created by the underlying storage system. + // Required. + Spec VolumeGroupSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` + // status represents the current information of a group snapshot. + // +optional + Status *VolumeGroupSnapshotContentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VolumeGroupSnapshotContentList is a list of VolumeGroupSnapshotContent objects +// +kubebuilder:object:root=true +type VolumeGroupSnapshotContentList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Items is the list of VolumeGroupSnapshotContents. + Items []VolumeGroupSnapshotContent `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// VolumeGroupSnapshotContentSpec describes the common attributes of a group snapshot content +type VolumeGroupSnapshotContentSpec struct { + // VolumeGroupSnapshotRef specifies the VolumeGroupSnapshot object to which this + // VolumeGroupSnapshotContent object is bound. + // VolumeGroupSnapshot.Spec.VolumeGroupSnapshotContentName field must reference to + // this VolumeGroupSnapshotContent's name for the bidirectional binding to be valid. + // For a pre-existing VolumeGroupSnapshotContent object, name and namespace of the + // 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 + // physical group snapshot on the underlying storage system should be deleted + // when the bound VolumeGroupSnapshot is deleted. + // Supported values are "Retain" and "Delete". + // "Retain" means that the VolumeGroupSnapshotContent and its physical group + // snapshot on underlying storage system are kept. + // "Delete" means that the VolumeGroupSnapshotContent and its physical group + // snapshot on underlying storage system are deleted. + // For dynamically provisioned group snapshots, this field will automatically + // be filled in by the CSI snapshotter sidecar with the "DeletionPolicy" field + // defined in the corresponding VolumeGroupSnapshotClass. + // For pre-existing snapshots, users MUST specify this field when creating the + // VolumeGroupSnapshotContent object. + // Required. + DeletionPolicy snapshotv1.DeletionPolicy `json:"deletionPolicy" protobuf:"bytes,2,opt,name=deletionPolicy"` + + // Driver is the name of the CSI driver used to create the physical group snapshot on + // the underlying storage system. + // This MUST be the same as the name returned by the CSI GetPluginName() call for + // that driver. + // Required. + Driver string `json:"driver" protobuf:"bytes,3,opt,name=driver"` + + // VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass from + // which this group snapshot was (or will be) created. + // Note that after provisioning, the VolumeGroupSnapshotClass may be deleted or + // recreated with different set of values, and as such, should not be referenced + // post-snapshot creation. + // For dynamic provisioning, this field must be set. + // This field may be unset for pre-provisioned snapshots. + // +optional + VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,4,opt,name=volumeGroupSnapshotClassName"` + + // Source specifies whether the snapshot is (or should be) dynamically provisioned + // or already exists, and just requires a Kubernetes object representation. + // This field is immutable after creation. + // Required. + Source VolumeGroupSnapshotContentSource `json:"source" protobuf:"bytes,5,opt,name=source"` +} + +// VolumeGroupSnapshotContentStatus defines the observed state of VolumeGroupSnapshotContent. +type VolumeGroupSnapshotContentStatus struct { + // VolumeGroupSnapshotHandle is a unique id returned by the CSI driver + // to identify the VolumeGroupSnapshot on the storage system. + // If a storage system does not provide such an id, the + // CSI driver can choose to return the VolumeGroupSnapshot name. + // +optional + VolumeGroupSnapshotHandle *string `json:"volumeGroupSnapshotHandle,omitempty" protobuf:"bytes,1,opt,name=volumeGroupSnapshotHandle"` + + // CreationTime is the timestamp when the point-in-time group snapshot is taken + // by the underlying storage system. + // If not specified, it indicates the creation time is unknown. + // If not specified, it means the readiness of a group snapshot is unknown. + // The format of this field is a Unix nanoseconds time encoded as an int64. + // On Unix, the command date +%s%N returns the current time in nanoseconds + // since 1970-01-01 00:00:00 UTC. + // +optional + CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,2,opt,name=creationTime"` + + // ReadyToUse indicates if all the individual snapshots in the group are ready to be + // used to restore a group of volumes. + // ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. + // +optional + ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` + + // Error is the last observed error during group snapshot creation, if any. + // Upon success after retry, this error field will be cleared. + // +optional + Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"` + + // 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 + 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 + // group snapshot and a list of CSI "snapshot_id" of pre-existing snapshots + // on the underlying storage system for which a Kubernetes object + // 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"` +} + +type GroupSnapshotHandles struct { + // VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id" of a pre-existing + // group snapshot on the underlying storage system for which a Kubernetes object + // representation was (or should be) created. + // This field is immutable. + // Required. + VolumeGroupSnapshotHandle string `json:"volumeGroupSnapshotHandle" protobuf:"bytes,1,opt,name=volumeGroupSnapshotHandle"` + + // VolumeSnapshotHandles is a list of CSI "snapshot_id" of pre-existing + // snapshots on the underlying storage system for which Kubernetes objects + // representation were (or should be) created. + // This field is immutable. + // Required. + VolumeSnapshotHandles []string `json:"volumeSnapshotHandles" protobuf:"bytes,2,opt,name=volumeSnapshotHandles"` +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..dd58419d9 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,459 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + 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" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupSnapshotHandles) DeepCopyInto(out *GroupSnapshotHandles) { + *out = *in + if in.VolumeSnapshotHandles != nil { + in, out := &in.VolumeSnapshotHandles, &out.VolumeSnapshotHandles + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupSnapshotHandles. +func (in *GroupSnapshotHandles) DeepCopy() *GroupSnapshotHandles { + if in == nil { + return nil + } + out := new(GroupSnapshotHandles) + in.DeepCopyInto(out) + 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 + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(VolumeGroupSnapshotStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshot. +func (in *VolumeGroupSnapshot) DeepCopy() *VolumeGroupSnapshot { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshot) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupSnapshot) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotClass) DeepCopyInto(out *VolumeGroupSnapshotClass) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotClass. +func (in *VolumeGroupSnapshotClass) DeepCopy() *VolumeGroupSnapshotClass { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotClass) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupSnapshotClass) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotClassList) DeepCopyInto(out *VolumeGroupSnapshotClassList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeGroupSnapshotClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotClassList. +func (in *VolumeGroupSnapshotClassList) DeepCopy() *VolumeGroupSnapshotClassList { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotClassList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupSnapshotClassList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotContent) DeepCopyInto(out *VolumeGroupSnapshotContent) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(VolumeGroupSnapshotContentStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotContent. +func (in *VolumeGroupSnapshotContent) DeepCopy() *VolumeGroupSnapshotContent { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotContent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupSnapshotContent) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotContentList) DeepCopyInto(out *VolumeGroupSnapshotContentList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeGroupSnapshotContent, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotContentList. +func (in *VolumeGroupSnapshotContentList) DeepCopy() *VolumeGroupSnapshotContentList { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotContentList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupSnapshotContentList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotContentSource) DeepCopyInto(out *VolumeGroupSnapshotContentSource) { + *out = *in + if in.VolumeHandles != nil { + in, out := &in.VolumeHandles, &out.VolumeHandles + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.GroupSnapshotHandles != nil { + in, out := &in.GroupSnapshotHandles, &out.GroupSnapshotHandles + *out = new(GroupSnapshotHandles) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotContentSource. +func (in *VolumeGroupSnapshotContentSource) DeepCopy() *VolumeGroupSnapshotContentSource { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotContentSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotContentSpec) DeepCopyInto(out *VolumeGroupSnapshotContentSpec) { + *out = *in + out.VolumeGroupSnapshotRef = in.VolumeGroupSnapshotRef + if in.VolumeGroupSnapshotClassName != nil { + in, out := &in.VolumeGroupSnapshotClassName, &out.VolumeGroupSnapshotClassName + *out = new(string) + **out = **in + } + in.Source.DeepCopyInto(&out.Source) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotContentSpec. +func (in *VolumeGroupSnapshotContentSpec) DeepCopy() *VolumeGroupSnapshotContentSpec { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotContentSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapshotContentStatus) { + *out = *in + if in.VolumeGroupSnapshotHandle != nil { + in, out := &in.VolumeGroupSnapshotHandle, &out.VolumeGroupSnapshotHandle + *out = new(string) + **out = **in + } + if in.CreationTime != nil { + in, out := &in.CreationTime, &out.CreationTime + *out = new(int64) + **out = **in + } + if in.ReadyToUse != nil { + in, out := &in.ReadyToUse, &out.ReadyToUse + *out = new(bool) + **out = **in + } + if in.Error != nil { + in, out := &in.Error, &out.Error + *out = new(v1.VolumeSnapshotError) + (*in).DeepCopyInto(*out) + } + if in.PVVolumeSnapshotContentList != nil { + in, out := &in.PVVolumeSnapshotContentList, &out.PVVolumeSnapshotContentList + *out = make([]PVVolumeSnapshotContentPair, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotContentStatus. +func (in *VolumeGroupSnapshotContentStatus) DeepCopy() *VolumeGroupSnapshotContentStatus { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotContentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotList) DeepCopyInto(out *VolumeGroupSnapshotList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeGroupSnapshot, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotList. +func (in *VolumeGroupSnapshotList) DeepCopy() *VolumeGroupSnapshotList { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupSnapshotList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.VolumeGroupSnapshotContentName != nil { + in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotSource. +func (in *VolumeGroupSnapshotSource) DeepCopy() *VolumeGroupSnapshotSource { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotSpec) DeepCopyInto(out *VolumeGroupSnapshotSpec) { + *out = *in + in.Source.DeepCopyInto(&out.Source) + if in.VolumeGroupSnapshotClassName != nil { + in, out := &in.VolumeGroupSnapshotClassName, &out.VolumeGroupSnapshotClassName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotSpec. +func (in *VolumeGroupSnapshotSpec) DeepCopy() *VolumeGroupSnapshotSpec { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotStatus) DeepCopyInto(out *VolumeGroupSnapshotStatus) { + *out = *in + if in.BoundVolumeGroupSnapshotContentName != nil { + in, out := &in.BoundVolumeGroupSnapshotContentName, &out.BoundVolumeGroupSnapshotContentName + *out = new(string) + **out = **in + } + if in.CreationTime != nil { + in, out := &in.CreationTime, &out.CreationTime + *out = (*in).DeepCopy() + } + if in.ReadyToUse != nil { + in, out := &in.ReadyToUse, &out.ReadyToUse + *out = new(bool) + **out = **in + } + if in.Error != nil { + in, out := &in.Error, &out.Error + *out = new(v1.VolumeSnapshotError) + (*in).DeepCopyInto(*out) + } + if in.PVCVolumeSnapshotRefList != nil { + in, out := &in.PVCVolumeSnapshotRefList, &out.PVCVolumeSnapshotRefList + *out = make([]PVCVolumeSnapshotPair, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotStatus. +func (in *VolumeGroupSnapshotStatus) DeepCopy() *VolumeGroupSnapshotStatus { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/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/v6/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/v6/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/v6/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/v6/apis/volumesnapshot/v1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/types.go similarity index 90% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1/types.go rename to vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/types.go index 608094615..36f60dc95 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/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"` } @@ -421,10 +436,10 @@ type VolumeSnapshotContentStatus struct { // +optional Error *VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"` - // VolumeGroupSnapshotContentName is the name of the VolumeGroupSnapshotContent of - // which this VolumeSnapshotContent is a part of. + // VolumeGroupSnapshotHandle is the CSI "group_snapshot_id" of a group snapshot + // on the underlying storage system. // +optional - VolumeGroupSnapshotContentName *string `json:"volumeGroupSnapshotContentName,omitempty" protobuf:"bytes,6,opt,name=volumeGroupSnapshotContentName"` + VolumeGroupSnapshotHandle *string `json:"volumeGroupSnapshotHandle,omitempty" protobuf:"bytes,6,opt,name=volumeGroupSnapshotHandle"` } // DeletionPolicy describes a policy for end-of-life maintenance of volume snapshot contents diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/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 98% rename from vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/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 index 460309263..a590aef06 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2023 The Kubernetes Authors. +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. @@ -271,8 +271,8 @@ func (in *VolumeSnapshotContentStatus) DeepCopyInto(out *VolumeSnapshotContentSt *out = new(VolumeSnapshotError) (*in).DeepCopyInto(*out) } - if in.VolumeGroupSnapshotContentName != nil { - in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName + if in.VolumeGroupSnapshotHandle != nil { + in, out := &in.VolumeGroupSnapshotHandle, &out.VolumeGroupSnapshotHandle *out = new(string) **out = **in } diff --git a/vendor/modules.txt b/vendor/modules.txt index 6ebdb2a1a..67d2c6ca9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -104,9 +104,10 @@ github.com/klauspost/compress/zstd/internal/xxhash github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1 github.com/kube-object-storage/lib-bucket-provisioner/pkg/provisioner/api -# github.com/kubernetes-csi/external-snapshotter/client/v6 v6.3.0 -## explicit; go 1.20 -github.com/kubernetes-csi/external-snapshotter/client/v6/apis/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/mailru/easyjson v0.7.7 ## explicit; go 1.12 github.com/mailru/easyjson/buffer