diff --git a/.github/workflows/snyk-container-image.yaml b/.github/workflows/snyk-container-image.yaml index a9a7a63dec9..3f3a1251220 100644 --- a/.github/workflows/snyk-container-image.yaml +++ b/.github/workflows/snyk-container-image.yaml @@ -41,6 +41,6 @@ jobs: args: --file=./deploy/cephcsi/image/Dockerfile - name: Upload result to GitHub Code Scanning # yamllint disable-line rule:line-length - uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 + uses: github/codeql-action/upload-sarif@4e83f6b818d7c9f52143570963b2c7f7f055decb # v3.28.6 with: sarif_file: snyk.sarif diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index 629919591e8..90eb489d967 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -19,7 +19,7 @@ jobs: if: github.repository == 'ceph/ceph-csi' steps: # yamllint disable-line rule:line-length - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 + - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} days-before-issue-stale: 30 diff --git a/charts/ceph-csi-cephfs/README.md b/charts/ceph-csi-cephfs/README.md index dfa125c77c1..7b6edf687d6 100644 --- a/charts/ceph-csi-cephfs/README.md +++ b/charts/ceph-csi-cephfs/README.md @@ -22,27 +22,19 @@ cd charts ### Install Chart -To install the Chart into your Kubernetes cluster +To install the Chart into your Kubernetes cluster(For helm 3.x): -- For helm 2.x +Create the namespace where Helm should install the components with - ```bash - helm install --namespace "ceph-csi-cephfs" --name "ceph-csi-cephfs" ceph-csi/ceph-csi-cephfs - ``` - -- For helm 3.x - - Create the namespace where Helm should install the components with - - ```bash - kubectl create namespace ceph-csi-cephfs - ``` +```bash +kubectl create namespace ceph-csi-cephfs +``` - Run the installation +Run the installation - ```bash - helm install --namespace "ceph-csi-cephfs" "ceph-csi-cephfs" ceph-csi/ceph-csi-cephfs - ``` +```bash +helm install --namespace "ceph-csi-cephfs" "ceph-csi-cephfs" ceph-csi/ceph-csi-cephfs +``` After installation succeeds, you can get a status of Chart @@ -111,17 +103,9 @@ permissions will be granted globally via a *ClusterRole*. If you want to delete your Chart, use this command -- For helm 2.x - - ```bash - helm delete --purge "ceph-csi-cephfs" - ``` - -- For helm 3.x - - ```bash - helm uninstall "ceph-csi-cephfs" --namespace "ceph-csi-cephfs" - ``` +```bash +helm uninstall "ceph-csi-cephfs" --namespace "ceph-csi-cephfs" +``` If you want to delete the namespace, use this command diff --git a/charts/ceph-csi-rbd/README.md b/charts/ceph-csi-rbd/README.md index b01289637ad..0232b87eb80 100644 --- a/charts/ceph-csi-rbd/README.md +++ b/charts/ceph-csi-rbd/README.md @@ -22,27 +22,19 @@ cd charts ### Install chart -To install the Chart into your Kubernetes cluster +To install the Chart into your Kubernetes cluster(For helm 3.x): -- For helm 2.x +Create the namespace where Helm should install the components with - ```bash - helm install --namespace "ceph-csi-rbd" --name "ceph-csi-rbd" ceph-csi/ceph-csi-rbd - ``` - -- For helm 3.x - - Create the namespace where Helm should install the components with - - ```bash - kubectl create namespace "ceph-csi-rbd" - ``` +```bash +kubectl create namespace "ceph-csi-rbd" +``` - Run the installation +Run the installation - ```bash - helm install --namespace "ceph-csi-rbd" "ceph-csi-rbd" ceph-csi/ceph-csi-rbd - ``` +```bash +helm install --namespace "ceph-csi-rbd" "ceph-csi-rbd" ceph-csi/ceph-csi-rbd +``` After installation succeeds, you can get a status of Chart @@ -84,17 +76,9 @@ compare your currently used values with the new default values. If you want to delete your Chart, use this command -- For helm 2.x - - ```bash - helm delete --purge "ceph-csi-rbd" - ``` - -- For helm 3.x - - ```bash - helm uninstall "ceph-csi-rbd" --namespace "ceph-csi-rbd" - ``` +```bash +helm uninstall "ceph-csi-rbd" --namespace "ceph-csi-rbd" +``` If you want to delete the namespace, use this command diff --git a/charts/ceph-csi-rbd/templates/provisioner-clusterrole.yaml b/charts/ceph-csi-rbd/templates/provisioner-clusterrole.yaml index b2c01ae6250..61cf7f8518c 100644 --- a/charts/ceph-csi-rbd/templates/provisioner-clusterrole.yaml +++ b/charts/ceph-csi-rbd/templates/provisioner-clusterrole.yaml @@ -29,6 +29,12 @@ rules: - apiGroups: [""] resources: ["endpoints"] verbs: ["get", "create", "update"] + - apiGroups: ["replication.storage.openshift.io"] + resources: ["volumegroupreplicationcontents"] + verbs: ["get", "list", "watch"] + - apiGroups: ["replication.storage.openshift.io"] + resources: ["volumegroupreplicationclasses"] + verbs: ["get", "list", "watch"] {{- if .Values.provisioner.attacher.enabled }} - apiGroups: ["storage.k8s.io"] resources: ["volumeattachments"] diff --git a/cmd/cephcsi.go b/cmd/cephcsi.go index bc6e1c7a3a0..b56b0cef7d5 100644 --- a/cmd/cephcsi.go +++ b/cmd/cephcsi.go @@ -26,6 +26,7 @@ import ( "github.com/ceph/ceph-csi/internal/cephfs" "github.com/ceph/ceph-csi/internal/controller" "github.com/ceph/ceph-csi/internal/controller/persistentvolume" + "github.com/ceph/ceph-csi/internal/controller/volumegroup" "github.com/ceph/ceph-csi/internal/liveness" nfsdriver "github.com/ceph/ceph-csi/internal/nfs/driver" rbddriver "github.com/ceph/ceph-csi/internal/rbd/driver" @@ -294,6 +295,7 @@ func setPIDLimit(conf *util.Config) { func initControllers() { // Add list of controller here. persistentvolume.Init() + volumegroup.Init() } func validateCloneDepthFlag(conf *util.Config) { diff --git a/deploy/rbd/kubernetes/csi-provisioner-rbac.yaml b/deploy/rbd/kubernetes/csi-provisioner-rbac.yaml index dc714bc454c..41118de60ca 100644 --- a/deploy/rbd/kubernetes/csi-provisioner-rbac.yaml +++ b/deploy/rbd/kubernetes/csi-provisioner-rbac.yaml @@ -75,6 +75,12 @@ rules: - apiGroups: ["groupsnapshot.storage.k8s.io"] resources: ["volumegroupsnapshotcontents/status"] verbs: ["update", "patch"] + - apiGroups: ["replication.storage.openshift.io"] + resources: ["volumegroupreplicationcontents"] + verbs: ["get", "list", "watch"] + - apiGroups: ["replication.storage.openshift.io"] + resources: ["volumegroupreplicationclasses"] + verbs: ["get"] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/go.mod b/go.mod index 0b889cee9cd..e31ae32c94f 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.org/x/net v0.34.0 golang.org/x/sys v0.29.0 google.golang.org/grpc v1.69.4 - google.golang.org/protobuf v1.36.3 + google.golang.org/protobuf v1.36.4 // // when updating k8s.io/kubernetes, make sure to update the replace section too // @@ -48,6 +48,7 @@ require ( require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.3.0 + github.com/csi-addons/kubernetes-csi-addons v0.9.0 ) require ( diff --git a/go.sum b/go.sum index 1d78a04f365..f530aebdfd6 100644 --- a/go.sum +++ b/go.sum @@ -1519,6 +1519,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/csi-addons/kubernetes-csi-addons v0.9.0 h1:Hhb44WcrxtbzmpLY+uqX+DBWCI6HgA/rwQMPyvsyCc8= +github.com/csi-addons/kubernetes-csi-addons v0.9.0/go.mod h1:/YROZDdEi1N/1Ls9rdU5W2VNjm8MK7HHApl8W4Sqt9s= github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 h1:j9NaWj5KmzEVarmsjxS/NDAhes6Uzq1qhkUGHvDlVBk= github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI= github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= @@ -3478,8 +3480,8 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= -google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= -google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= +google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/cephfs/store/volumegroup.go b/internal/cephfs/store/volumegroup.go index 0b64c350096..ba334f12dc8 100644 --- a/internal/cephfs/store/volumegroup.go +++ b/internal/cephfs/store/volumegroup.go @@ -255,7 +255,7 @@ func ReserveVolumeGroup( defer j.Destroy() groupUUID, vgsi.FsVolumeGroupSnapshotName, err = j.ReserveName( - ctx, volOptions.MetadataPool, volOptions.RequestName, volOptions.NamePrefix) + ctx, volOptions.MetadataPool, volOptions.RequestName, volOptions.ReservedID, volOptions.NamePrefix) if err != nil { return nil, err } diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 5c4693d7d22..53dff8fec5e 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -20,7 +20,10 @@ import ( "github.com/ceph/ceph-csi/internal/util/log" - "k8s.io/apimachinery/pkg/runtime" + replicationv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1" + apiruntime "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "k8s.io/client-go/tools/leaderelection/resourcelock" clientConfig "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -62,6 +65,9 @@ func addToManager(mgr manager.Manager, config Config) error { // Start will start all the registered managers. func Start(config Config) error { + scheme := apiruntime.NewScheme() + utilruntime.Must(replicationv1alpha1.AddToScheme(scheme)) + utilruntime.Must(clientgoscheme.AddToScheme(scheme)) electionID := config.DriverName + "-" + config.Namespace opts := manager.Options{ LeaderElection: true, @@ -70,11 +76,12 @@ func Start(config Config) error { LeaderElectionNamespace: config.Namespace, LeaderElectionResourceLock: resourcelock.LeasesResourceLock, LeaderElectionID: electionID, + Scheme: scheme, } kubeConfig := clientConfig.GetConfigOrDie() coreKubeConfig := rest.CopyConfig(kubeConfig) - coreKubeConfig.ContentType = runtime.ContentTypeProtobuf + coreKubeConfig.ContentType = apiruntime.ContentTypeProtobuf mgr, err := manager.New(coreKubeConfig, opts) if err != nil { log.ErrorLogMsg("failed to create manager %s", err) diff --git a/internal/controller/volumegroup/volumegroupreplicationcontent.go b/internal/controller/volumegroup/volumegroupreplicationcontent.go new file mode 100644 index 00000000000..ebe3f67fd82 --- /dev/null +++ b/internal/controller/volumegroup/volumegroupreplicationcontent.go @@ -0,0 +1,247 @@ +/* +Copyright 2025 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 volumegroup + +import ( + "context" + "errors" + "fmt" + "strings" + + replicationv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + "sigs.k8s.io/controller-runtime/pkg/source" + + ctrl "github.com/ceph/ceph-csi/internal/controller" + "github.com/ceph/ceph-csi/internal/rbd" + "github.com/ceph/ceph-csi/internal/util" + "github.com/ceph/ceph-csi/internal/util/log" +) + +type ReconcileVGRContent struct { + client client.Client + config ctrl.Config + Locks *util.VolumeLocks +} + +var ( + _ reconcile.Reconciler = &ReconcileVGRContent{} + _ ctrl.Manager = &ReconcileVGRContent{} +) + +const ( + secretNameParameterName = "replication.storage.openshift.io/group-replication-secret-name" + secretNamespaceParameterName = "replication.storage.openshift.io/group-replication-secret-namespace" + + volumeGroupReplicationContentResourceName = "VolumeGroupReplicationContent" + volumeGroupReplicationClassResourceName = "VolumeGroupReplicationClass" +) + +// Init will add the ReconcileVGRContent to the list. +func Init() { + // add ReconcileVGRContent to the list + ctrl.ControllerList = append(ctrl.ControllerList, &ReconcileVGRContent{}) +} + +// Add adds the newVGRContentReconciler. +func (r *ReconcileVGRContent) Add(mgr manager.Manager, config ctrl.Config) error { + return add(mgr, newVGRContentReconciler(mgr, config)) +} + +// newVGRContentReconciler returns a ReconcileVGRContent. +func newVGRContentReconciler(mgr manager.Manager, config ctrl.Config) reconcile.Reconciler { + r := &ReconcileVGRContent{ + client: mgr.GetClient(), + config: config, + Locks: util.NewVolumeLocks(), + } + + return r +} + +func ensureCRDsInstalled(mgr manager.Manager) (bool, error) { + crdsInstalled := true + missingCRDs := []string{} + + gvk := metav1.PartialObjectMetadata{} + gvk.SetGroupVersionKind(replicationv1alpha1.GroupVersion.WithKind(volumeGroupReplicationContentResourceName)) + _, err := mgr.GetRESTMapper().RESTMapping(gvk.GroupVersionKind().GroupKind(), gvk.GroupVersionKind().Version) + if err != nil { + if !meta.IsNoMatchError(err) { + return false, err + } + + crdsInstalled = false + missingCRDs = append(missingCRDs, volumeGroupReplicationContentResourceName) + } + + gvk.SetGroupVersionKind(replicationv1alpha1.GroupVersion.WithKind(volumeGroupReplicationClassResourceName)) + _, err = mgr.GetRESTMapper().RESTMapping(gvk.GroupVersionKind().GroupKind(), gvk.GroupVersionKind().Version) + if err != nil { + if !meta.IsNoMatchError(err) { + return false, err + } + + crdsInstalled = false + missingCRDs = append(missingCRDs, volumeGroupReplicationClassResourceName) + } + + if !crdsInstalled { + log.ErrorLogMsg("Required CRDs (%s) are not installed", strings.Join(missingCRDs, ", ")) + } + + return crdsInstalled, nil +} + +func add(mgr manager.Manager, r reconcile.Reconciler) error { + // Ensure the required CRDs are installed. + installed, err := ensureCRDsInstalled(mgr) + if err != nil { + return err + } + if !installed { + log.ErrorLogMsg("Skipping controller creation for VolumeGroupReplicationContent. Please install the missing CRDs.") + + return nil + } + + // Create a new controller + c, err := controller.New( + "vgrcontent-controller", + mgr, + controller.Options{MaxConcurrentReconciles: 1, Reconciler: r}) + if err != nil { + return err + } + + // Watch for changes to VolumeGroupReplicationContent + err = c.Watch(source.Kind( + mgr.GetCache(), + &replicationv1alpha1.VolumeGroupReplicationContent{}, + &handler.TypedEnqueueRequestForObject[*replicationv1alpha1.VolumeGroupReplicationContent]{}), + ) + if err != nil { + return fmt.Errorf("failed to watch the changes: %w", err) + } + + return nil +} + +func (r *ReconcileVGRContent) getSecrets( + ctx context.Context, + name, + namespace string, +) (map[string]string, error) { + if name == "" || namespace == "" { + return nil, errors.New("secret name or secret namespace is empty") + } + secret := &corev1.Secret{} + err := r.client.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret) + if err != nil { + return nil, fmt.Errorf("error getting secret %s in namespace %s: %w", name, namespace, err) + } + + secrets := map[string]string{} + for key, value := range secret.Data { + secrets[key] = string(value) + } + + return secrets, nil +} + +func (r *ReconcileVGRContent) reconcileVGRContent(ctx context.Context, obj runtime.Object) error { + vgrc, ok := obj.(*replicationv1alpha1.VolumeGroupReplicationContent) + if !ok { + return nil + } + if vgrc.Spec.Provisioner != r.config.DriverName { + return nil + } + + reqName := vgrc.Name + groupHandle := vgrc.Spec.VolumeGroupReplicationHandle + volumeIds := vgrc.Spec.Source.VolumeHandles + + if groupHandle == "" { + return errors.New("volume group replication handle is empty") + } + + vgrClass := &replicationv1alpha1.VolumeGroupReplicationClass{} + err := r.client.Get(ctx, types.NamespacedName{Name: vgrc.Spec.VolumeGroupReplicationClassName}, vgrClass) + if err != nil { + return err + } + + if ok = r.Locks.TryAcquire(groupHandle); !ok { + return fmt.Errorf("failed to acquire lock for group handle %s", groupHandle) + } + defer r.Locks.Release(groupHandle) + + parameters := vgrClass.Spec.Parameters + secretName := vgrClass.Spec.Parameters[secretNameParameterName] + secretNamespace := vgrClass.Spec.Parameters[secretNamespaceParameterName] + + secrets, err := r.getSecrets(ctx, secretName, secretNamespace) + if err != nil { + return err + } + + mgr := rbd.NewManager(r.config.InstanceID, parameters, secrets) + defer mgr.Destroy(ctx) + + groupID, err := mgr.RegenerateVolumeGroupJournal(ctx, groupHandle, reqName, volumeIds) + if err != nil { + return err + } + if groupID != groupHandle { + log.DebugLog(ctx, "groupHandle changed from %s to %s", groupHandle, groupID) + } + + return nil +} + +// Reconcile reconciles the VolumeGroupReplicationContent object and creates a new omap entries +// for the volume group. +func (r *ReconcileVGRContent) Reconcile(ctx context.Context, + request reconcile.Request, +) (reconcile.Result, error) { + vgrc := &replicationv1alpha1.VolumeGroupReplicationContent{} + err := r.client.Get(ctx, request.NamespacedName, vgrc) + if err != nil { + if apierrors.IsNotFound(err) { + return reconcile.Result{}, nil + } + + return reconcile.Result{}, err + } + + // Proceed with reconciliation only if the object is not marked for deletion. + if vgrc.GetDeletionTimestamp().IsZero() { + err = r.reconcileVGRContent(ctx, vgrc) + } + + return reconcile.Result{}, err +} diff --git a/internal/csi-addons/rbd/encryptionkeyrotation.go b/internal/csi-addons/rbd/encryptionkeyrotation.go index b45ce4468b7..5acb4858aa3 100644 --- a/internal/csi-addons/rbd/encryptionkeyrotation.go +++ b/internal/csi-addons/rbd/encryptionkeyrotation.go @@ -32,11 +32,15 @@ import ( type EncryptionKeyRotationServer struct { *ekr.UnimplementedEncryptionKeyRotationControllerServer - volLock *util.VolumeLocks + driverInstance string + volLock *util.VolumeLocks } -func NewEncryptionKeyRotationServer(volLock *util.VolumeLocks) *EncryptionKeyRotationServer { - return &EncryptionKeyRotationServer{volLock: volLock} +func NewEncryptionKeyRotationServer(driverInstance string, volLock *util.VolumeLocks) *EncryptionKeyRotationServer { + return &EncryptionKeyRotationServer{ + driverInstance: driverInstance, + volLock: volLock, + } } func (ekrs *EncryptionKeyRotationServer) RegisterService(svc grpc.ServiceRegistrar) { @@ -58,15 +62,10 @@ func (ekrs *EncryptionKeyRotationServer) EncryptionKeyRotate( } defer ekrs.volLock.Release(volID) - // Get the credentials required to authenticate - // against a ceph cluster - creds, err := util.NewUserCredentials(req.GetSecrets()) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - defer creds.DeleteCredentials() + mgr := rbd.NewManager(ekrs.driverInstance, nil, req.GetSecrets()) + defer mgr.Destroy(ctx) - rbdVol, err := rbd.GenVolFromVolID(ctx, volID, creds, req.GetSecrets()) + rbdVol, err := mgr.GetVolumeByID(ctx, volID) if err != nil { switch { case errors.Is(err, rbd.ErrImageNotFound): diff --git a/internal/csi-addons/rbd/reclaimspace.go b/internal/csi-addons/rbd/reclaimspace.go index 1d3f4bbfa1e..79ba578a8b1 100644 --- a/internal/csi-addons/rbd/reclaimspace.go +++ b/internal/csi-addons/rbd/reclaimspace.go @@ -37,13 +37,21 @@ import ( // of CSI-addons reclaimspace controller service spec. type ReclaimSpaceControllerServer struct { *rs.UnimplementedReclaimSpaceControllerServer - volumeLocks *util.VolumeLocks + + driverInstance string + volumeLocks *util.VolumeLocks } // NewReclaimSpaceControllerServer creates a new ReclaimSpaceControllerServer which handles // the ReclaimSpace Service requests from the CSI-Addons specification. -func NewReclaimSpaceControllerServer(volumeLocks *util.VolumeLocks) *ReclaimSpaceControllerServer { - return &ReclaimSpaceControllerServer{volumeLocks: volumeLocks} +func NewReclaimSpaceControllerServer( + driverInstance string, + volumeLocks *util.VolumeLocks, +) *ReclaimSpaceControllerServer { + return &ReclaimSpaceControllerServer{ + driverInstance: driverInstance, + volumeLocks: volumeLocks, + } } func (rscs *ReclaimSpaceControllerServer) RegisterService(server grpc.ServiceRegistrar) { @@ -59,12 +67,6 @@ func (rscs *ReclaimSpaceControllerServer) ControllerReclaimSpace( return nil, status.Error(codes.InvalidArgument, "empty volume ID in request") } - cr, err := util.NewUserCredentials(req.GetSecrets()) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - defer cr.DeleteCredentials() - if acquired := rscs.volumeLocks.TryAcquire(volumeID); !acquired { log.ErrorLog(ctx, util.VolumeOperationAlreadyExistsFmt, volumeID) @@ -72,13 +74,16 @@ func (rscs *ReclaimSpaceControllerServer) ControllerReclaimSpace( } defer rscs.volumeLocks.Release(volumeID) - rbdVol, err := rbdutil.GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets()) + mgr := rbdutil.NewManager(rscs.driverInstance, nil, req.GetSecrets()) + defer mgr.Destroy(ctx) + + rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) if err != nil { return nil, status.Errorf(codes.Aborted, "failed to find volume with ID %q: %s", volumeID, err.Error()) } defer rbdVol.Destroy(ctx) - err = rbdVol.Sparsify() + err = rbdVol.Sparsify(ctx) if errors.Is(err, rbdutil.ErrImageInUse) { // FIXME: https://github.com/csi-addons/kubernetes-csi-addons/issues/406. // treat sparsify call as no-op if volume is in use. diff --git a/internal/csi-addons/rbd/reclaimspace_test.go b/internal/csi-addons/rbd/reclaimspace_test.go index d9649f22a83..2ad51f9a282 100644 --- a/internal/csi-addons/rbd/reclaimspace_test.go +++ b/internal/csi-addons/rbd/reclaimspace_test.go @@ -32,7 +32,7 @@ import ( func TestControllerReclaimSpace(t *testing.T) { t.Parallel() - controller := NewReclaimSpaceControllerServer(util.NewVolumeLocks()) + controller := NewReclaimSpaceControllerServer("test.driver", util.NewVolumeLocks()) req := &rs.ControllerReclaimSpaceRequest{ VolumeId: "", diff --git a/internal/csi-addons/rbd/replication.go b/internal/csi-addons/rbd/replication.go index d2814fc4d1d..be0864b6061 100644 --- a/internal/csi-addons/rbd/replication.go +++ b/internal/csi-addons/rbd/replication.go @@ -95,8 +95,8 @@ type ReplicationServer struct { *replication.UnimplementedControllerServer // Embed ControllerServer as it implements helper functions *corerbd.ControllerServer - // csiID is the unique ID for this CSI-driver deployment. - csiID string + // driverInstance is the unique ID for this CSI-driver deployment. + driverInstance string } // NewReplicationServer creates a new ReplicationServer which handles @@ -104,7 +104,7 @@ type ReplicationServer struct { func NewReplicationServer(instanceID string, c *corerbd.ControllerServer) *ReplicationServer { return &ReplicationServer{ ControllerServer: c, - csiID: instanceID, + driverInstance: instanceID, } } @@ -277,7 +277,7 @@ func (rs *ReplicationServer) EnableVolumeReplication(ctx context.Context, } defer rs.VolumeLocks.Release(volumeID) - mgr := rbd.NewManager(rs.csiID, req.GetParameters(), req.GetSecrets()) + mgr := rbd.NewManager(rs.driverInstance, req.GetParameters(), req.GetSecrets()) defer mgr.Destroy(ctx) rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) @@ -347,7 +347,7 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context, } defer rs.VolumeLocks.Release(volumeID) - mgr := rbd.NewManager(rs.csiID, req.GetParameters(), req.GetSecrets()) + mgr := rbd.NewManager(rs.driverInstance, req.GetParameters(), req.GetSecrets()) defer mgr.Destroy(ctx) rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) @@ -415,7 +415,7 @@ func (rs *ReplicationServer) PromoteVolume(ctx context.Context, } defer rs.VolumeLocks.Release(volumeID) - mgr := rbd.NewManager(rs.csiID, req.GetParameters(), req.GetSecrets()) + mgr := rbd.NewManager(rs.driverInstance, req.GetParameters(), req.GetSecrets()) defer mgr.Destroy(ctx) rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) @@ -508,7 +508,7 @@ func (rs *ReplicationServer) DemoteVolume(ctx context.Context, } defer rs.VolumeLocks.Release(volumeID) - mgr := rbd.NewManager(rs.csiID, req.GetParameters(), req.GetSecrets()) + mgr := rbd.NewManager(rs.driverInstance, req.GetParameters(), req.GetSecrets()) defer mgr.Destroy(ctx) rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) @@ -618,7 +618,7 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context, return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volumeID) } defer rs.VolumeLocks.Release(volumeID) - mgr := rbd.NewManager(rs.csiID, req.GetParameters(), req.GetSecrets()) + mgr := rbd.NewManager(rs.driverInstance, req.GetParameters(), req.GetSecrets()) defer mgr.Destroy(ctx) rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) @@ -827,7 +827,7 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context, return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volumeID) } defer rs.VolumeLocks.Release(volumeID) - mgr := rbd.NewManager(rs.csiID, nil, req.GetSecrets()) + mgr := rbd.NewManager(rs.driverInstance, nil, req.GetSecrets()) defer mgr.Destroy(ctx) rbdVol, err := mgr.GetVolumeByID(ctx, volumeID) diff --git a/internal/csi-addons/rbd/volumegroup.go b/internal/csi-addons/rbd/volumegroup.go index c069118b0f4..4727e548b80 100644 --- a/internal/csi-addons/rbd/volumegroup.go +++ b/internal/csi-addons/rbd/volumegroup.go @@ -41,15 +41,15 @@ type VolumeGroupServer struct { // don't need to add all RPC methods leading to forward compatibility. *volumegroup.UnimplementedControllerServer - // csiID is the unique ID for this CSI-driver deployment. - csiID string + // driverInstance is the unique ID for this CSI-driver deployment. + driverInstance string } // NewVolumeGroupServer creates a new VolumeGroupServer which handles the // VolumeGroup Service requests from the CSI-Addons specification. func NewVolumeGroupServer(instanceID string) *VolumeGroupServer { return &VolumeGroupServer{ - csiID: instanceID, + driverInstance: instanceID, } } @@ -85,7 +85,7 @@ func (vs *VolumeGroupServer) CreateVolumeGroup( ctx context.Context, req *volumegroup.CreateVolumeGroupRequest, ) (*volumegroup.CreateVolumeGroupResponse, error) { - mgr := rbd.NewManager(vs.csiID, req.GetParameters(), req.GetSecrets()) + mgr := rbd.NewManager(vs.driverInstance, req.GetParameters(), req.GetSecrets()) defer mgr.Destroy(ctx) // resolve all volumes @@ -188,7 +188,7 @@ func (vs *VolumeGroupServer) DeleteVolumeGroup( ctx context.Context, req *volumegroup.DeleteVolumeGroupRequest, ) (*volumegroup.DeleteVolumeGroupResponse, error) { - mgr := rbd.NewManager(vs.csiID, nil, req.GetSecrets()) + mgr := rbd.NewManager(vs.driverInstance, nil, req.GetSecrets()) defer mgr.Destroy(ctx) // resolve the volume group @@ -285,7 +285,7 @@ func (vs *VolumeGroupServer) ModifyVolumeGroupMembership( ctx context.Context, req *volumegroup.ModifyVolumeGroupMembershipRequest, ) (*volumegroup.ModifyVolumeGroupMembershipResponse, error) { - mgr := rbd.NewManager(vs.csiID, nil, req.GetSecrets()) + mgr := rbd.NewManager(vs.driverInstance, nil, req.GetSecrets()) defer mgr.Destroy(ctx) // resolve the volume group @@ -427,7 +427,7 @@ func (vs *VolumeGroupServer) ControllerGetVolumeGroup( ctx context.Context, req *volumegroup.ControllerGetVolumeGroupRequest, ) (*volumegroup.ControllerGetVolumeGroupResponse, error) { - mgr := rbd.NewManager(vs.csiID, nil, req.GetSecrets()) + mgr := rbd.NewManager(vs.driverInstance, nil, req.GetSecrets()) defer mgr.Destroy(ctx) // resolve the volume group diff --git a/internal/journal/volumegroupjournal.go b/internal/journal/volumegroupjournal.go index 99ad8dafd1b..80012c887b5 100644 --- a/internal/journal/volumegroupjournal.go +++ b/internal/journal/volumegroupjournal.go @@ -54,6 +54,7 @@ type VolumeGroupJournal interface { ctx context.Context, journalPool, reqName, + groupUUID, namePrefix string) (string, string, error) // AddVolumesMapping adds a volumeMap map which contains volumeID's and its // corresponding values mapping which need to be added to the UUID @@ -312,6 +313,7 @@ held, to prevent parallel operations from modifying the state of the omaps for t Input arguments: - journalPool: Pool where the CSI journal is stored - reqName: Name of the volumeGroupSnapshot request received + - groupUUID: UUID need to be reserved instead of auto-generating one (this is useful for RBD mirroring) - namePrefix: Prefix to use when generating the volumeGroupName name (suffix is an auto-generated UUID) Return values: @@ -320,7 +322,7 @@ Return values: - error: non-nil in case of any errors */ func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context, - journalPool, reqName, namePrefix string, + journalPool, reqName, groupUUID, namePrefix string, ) (string, string, error) { cj := vgjc.config @@ -335,7 +337,7 @@ func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context, journalPool, cj.namespace, cj.cephUUIDDirectoryPrefix, - "") + groupUUID) if err != nil { return "", "", err } diff --git a/internal/rbd/diskusage.go b/internal/rbd/diskusage.go index 444a5a604fa..9e97ad148e2 100644 --- a/internal/rbd/diskusage.go +++ b/internal/rbd/diskusage.go @@ -17,6 +17,7 @@ limitations under the License. package rbd import ( + "context" "fmt" ) @@ -25,7 +26,7 @@ import ( // of the image. // This function will return ErrImageInUse if the image is in use, since // sparsifying an image on which i/o is in progress is not optimal. -func (ri *rbdImage) Sparsify() error { +func (ri *rbdImage) Sparsify(_ context.Context) error { inUse, err := ri.isInUse() if err != nil { return fmt.Errorf("failed to check if image is in use: %w", err) diff --git a/internal/rbd/driver/driver.go b/internal/rbd/driver/driver.go index 98b9ca40155..64ca52bff53 100644 --- a/internal/rbd/driver/driver.go +++ b/internal/rbd/driver/driver.go @@ -229,7 +229,7 @@ func (r *Driver) setupCSIAddonsServer(conf *util.Config) error { r.cas.RegisterService(is) if conf.IsControllerServer { - rs := casrbd.NewReclaimSpaceControllerServer(r.cs.VolumeLocks) + rs := casrbd.NewReclaimSpaceControllerServer(conf.InstanceID, r.cs.VolumeLocks) r.cas.RegisterService(rs) fcs := casrbd.NewFenceControllerServer() @@ -249,7 +249,7 @@ func (r *Driver) setupCSIAddonsServer(conf *util.Config) error { rs := casrbd.NewReclaimSpaceNodeServer(r.ns.VolumeLocks) r.cas.RegisterService(rs) - ekr := casrbd.NewEncryptionKeyRotationServer(r.ns.VolumeLocks) + ekr := casrbd.NewEncryptionKeyRotationServer(conf.InstanceID, r.ns.VolumeLocks) r.cas.RegisterService(ekr) } diff --git a/internal/rbd/manager.go b/internal/rbd/manager.go index ced7026fc02..61fcfdcaadf 100644 --- a/internal/rbd/manager.go +++ b/internal/rbd/manager.go @@ -31,8 +31,8 @@ import ( var _ types.Manager = &rbdManager{} type rbdManager struct { - // csiID is the instance id of the CSI-driver (driver name). - csiID string + // driverInstance is the instance id of the CSI-driver (driver name). + driverInstance string // parameters can contain the parameters of a create request. parameters map[string]string // secrets contain the credentials to connect to the Ceph cluster. @@ -46,11 +46,11 @@ type rbdManager struct { // NewManager returns a new manager for handling Volume and Volume Group // operations, combining the requests for RBD and the journalling in RADOS. -func NewManager(csiID string, parameters, secrets map[string]string) types.Manager { +func NewManager(driverInstance string, parameters, secrets map[string]string) types.Manager { return &rbdManager{ - csiID: csiID, - parameters: parameters, - secrets: secrets, + driverInstance: driverInstance, + parameters: parameters, + secrets: secrets, } } @@ -102,7 +102,7 @@ func (mgr *rbdManager) getVolumeGroupJournal(clusterID string) (journal.VolumeGr return nil, fmt.Errorf("failed to find the RADOS namespace for cluster %q: %w", clusterID, err) } - vgJournalConfig := journal.NewCSIVolumeGroupJournalWithNamespace(mgr.csiID, ns) + vgJournalConfig := journal.NewCSIVolumeGroupJournalWithNamespace(mgr.driverInstance, ns) vgJournal, err := vgJournalConfig.Connect(monitors, ns, creds) if err != nil { @@ -144,7 +144,7 @@ func (mgr *rbdManager) getGroupUUID( } else { log.DebugLog(ctx, "the journal does not contain a reservation for group %q yet", name) - uuid, _ /*vgsName*/, err = vgJournal.ReserveName(ctx, journalPool, name, prefix) + uuid, _ /*vgsName*/, err = vgJournal.ReserveName(ctx, journalPool, name, uuid, prefix) if err != nil { return "", nothingToUndo, fmt.Errorf("failed to reserve a UUID for group %q: %w", name, err) } @@ -221,7 +221,7 @@ func (mgr *rbdManager) GetVolumeGroupByID(ctx context.Context, id string) (types return nil, err } - vg, err := rbd_group.GetVolumeGroup(ctx, id, mgr.csiID, creds, mgr) + vg, err := rbd_group.GetVolumeGroup(ctx, id, mgr.driverInstance, creds, mgr) if err != nil { return nil, fmt.Errorf("failed to get volume group with id %q: %w", id, err) } @@ -257,8 +257,8 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type journalPool = pool } - // volumeNamePrefix is an optional parameter, can be an empty string - prefix := mgr.parameters["volumeNamePrefix"] + // volumeGroupNamePrefix is an optional parameter, can be an empty string + prefix := mgr.parameters["volumeGroupNamePrefix"] // check if the journal contains a generated name for the group already vgData, err := vgJournal.CheckReservation(ctx, journalPool, name, prefix) @@ -273,7 +273,7 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type log.DebugLog(ctx, "the journal does not contain a reservation for a volume group with name %q yet", name) var vgName string - uuid, vgName, err = vgJournal.ReserveName(ctx, journalPool, name, prefix) + uuid, vgName, err = vgJournal.ReserveName(ctx, journalPool, name, uuid, prefix) if err != nil { return nil, fmt.Errorf("failed to reserve volume group for name %q: %w", name, err) } @@ -302,7 +302,7 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type return nil, fmt.Errorf("failed to generate a unique CSI volume group with uuid for %q: %w", uuid, err) } - vg, err := rbd_group.GetVolumeGroup(ctx, csiID, mgr.csiID, creds, mgr) + vg, err := rbd_group.GetVolumeGroup(ctx, csiID, mgr.driverInstance, creds, mgr) if err != nil { return nil, fmt.Errorf("failed to get volume group %q at cluster %q: %w", name, clusterID, err) } @@ -329,7 +329,7 @@ func (mgr *rbdManager) GetVolumeGroupSnapshotByID( return nil, err } - vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, id, mgr.csiID, creds, mgr) + vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, id, mgr.driverInstance, creds, mgr) if err != nil { return nil, fmt.Errorf("failed to get volume group with id %q: %w", id, err) } @@ -382,7 +382,7 @@ func (mgr *rbdManager) GetVolumeGroupSnapshotByName( return nil, fmt.Errorf("failed to generate a unique CSI volume group with uuid %q: %w", uuid, err) } - vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, csiID, mgr.csiID, mgr.creds, mgr) + vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, csiID, mgr.driverInstance, mgr.creds, mgr) if err != nil { return nil, fmt.Errorf("failed to get existing volume group snapshot with uuid %q: %w", uuid, err) } @@ -445,7 +445,7 @@ func (mgr *rbdManager) CreateVolumeGroupSnapshot( return nil, fmt.Errorf("failed to generate a unique CSI volume group with uuid for %q: %w", uuid, err) } - vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, groupID, mgr.csiID, mgr.creds, mgr) + vgs, err := rbd_group.GetVolumeGroupSnapshot(ctx, groupID, mgr.driverInstance, mgr.creds, mgr) if vgs != nil { log.DebugLog(ctx, "found existing volume group snapshot %q for id %q", vgs, groupID) @@ -494,7 +494,7 @@ func (mgr *rbdManager) CreateVolumeGroupSnapshot( log.DebugLog(ctx, "volume group snapshot %q contains %d snapshots: %v", name, len(snapshots), snapshots) - vgs, err = rbd_group.NewVolumeGroupSnapshot(ctx, groupID, mgr.csiID, mgr.creds, snapshots) + vgs, err = rbd_group.NewVolumeGroupSnapshot(ctx, groupID, mgr.driverInstance, mgr.creds, snapshots) if err != nil { return nil, fmt.Errorf("failed to create new volume group snapshot %q: %w", name, err) } @@ -503,3 +503,134 @@ func (mgr *rbdManager) CreateVolumeGroupSnapshot( return vgs, nil } + +// RegenerateVolumeGroupJournal regenerate the omap data for the volume group. +// This performs the following operations: +// - extracts clusterID and Mons from the cluster mapping +// - Retrieves pool and journalPool parameters from the VolumeGroupReplicationClass +// - Reserves omap data +// - Add volumeIDs mapping to the reserved volume group omap object +// - Generate new volume group handle +// +// Returns the generated volume group handle. +// +// Note: The new volume group handle will differ from the original as it includes +// poolID and clusterID, which vary between clusters. +func (mgr *rbdManager) RegenerateVolumeGroupJournal( + ctx context.Context, + groupID, requestName string, + volumeIds []string, +) (string, error) { + var ( + clusterID string + monitors string + pool string + journalPool string + namePrefix string + groupUUID string + vgName string + + gi util.CSIIdentifier + ok bool + err error + ) + + err = gi.DecomposeCSIID(groupID) + if err != nil { + return "", fmt.Errorf("%w: error decoding volume group ID (%w) (%s)", ErrInvalidVolID, err, groupID) + } + + monitors, clusterID, err = util.FetchMappedClusterIDAndMons(ctx, gi.ClusterID) + if err != nil { + return "", err + } + + pool, ok = mgr.parameters["pool"] + if !ok { + return "", errors.New("required 'pool' parameter missing in parameters") + } + + journalPool, ok = mgr.parameters["journalPool"] + if !ok || journalPool == "" { + journalPool = pool + } + + vgJournal, err := mgr.getVolumeGroupJournal(clusterID) + if err != nil { + return "", err + } + defer vgJournal.Destroy() + + namePrefix = mgr.parameters["volumeGroupNamePrefix"] + vgData, err := vgJournal.CheckReservation(ctx, journalPool, requestName, namePrefix) + if err != nil { + return "", err + } + + if vgData != nil { + groupUUID = vgData.GroupUUID + vgName = vgData.GroupName + } else { + log.DebugLog(ctx, "the journal does not contain a reservation for a volume group with name %q yet", requestName) + groupUUID, vgName, err = vgJournal.ReserveName(ctx, journalPool, requestName, gi.ObjectUUID, namePrefix) + if err != nil { + return "", fmt.Errorf("failed to reserve volume group for name %q: %w", requestName, err) + } + defer func() { + if err != nil { + undoError := vgJournal.UndoReservation(ctx, journalPool, vgName, requestName) + if undoError != nil { + log.ErrorLog(ctx, "failed to undo the reservation for volume group %q: %w", requestName, undoError) + } + } + }() + } + + volumes := make([]types.Volume, len(volumeIds)) + defer func() { + for _, v := range volumes { + v.Destroy(ctx) + } + }() + var volume types.Volume + for i, id := range volumeIds { + volume, err = mgr.GetVolumeByID(ctx, id) + if err != nil { + return "", fmt.Errorf("failed to find required volume %q for volume group id %q: %w", id, vgName, err) + } + + volumes[i] = volume + } + + var volID string + for _, vol := range volumes { + volID, err = vol.GetID(ctx) + if err != nil { + return "", fmt.Errorf("failed to get VolumeID for %q: %w", vol, err) + } + + toAdd := map[string]string{ + volID: "", + } + log.DebugLog(ctx, "adding volume mapping for volume %q to volume group %q", volID, vgName) + err = mgr.vgJournal.AddVolumesMapping(ctx, pool, gi.ObjectUUID, toAdd) + if err != nil { + return "", fmt.Errorf("failed to add mapping for volume %q to volume group %q: %w", volID, vgName, err) + } + } + + _, poolID, err := util.GetPoolIDs(ctx, monitors, journalPool, pool, mgr.creds) + if err != nil { + return "", fmt.Errorf("failed to get poolID for %q: %w", groupUUID, err) + } + + groupHandle, err := util.GenerateVolID(ctx, monitors, mgr.creds, poolID, pool, clusterID, groupUUID) + if err != nil { + return "", fmt.Errorf("failed to generate a unique CSI volume group with uuid for %q: %w", groupUUID, err) + } + + log.DebugLog(ctx, "re-generated Group ID (%s) and Group Name (%s) for request name (%s)", + groupHandle, vgName, requestName) + + return groupHandle, nil +} diff --git a/internal/rbd/types/manager.go b/internal/rbd/types/manager.go index 273bd58109f..458bc93dc0d 100644 --- a/internal/rbd/types/manager.go +++ b/internal/rbd/types/manager.go @@ -67,4 +67,8 @@ type Manager interface { // VolumeGroup was paused, the snapshots in the group are crash // consistent. CreateVolumeGroupSnapshot(ctx context.Context, vg VolumeGroup, name string) (VolumeGroupSnapshot, error) + + // RegenerateVolumeGroupJournal regenerate the omap data for the volume group. + // returns the volume group handle + RegenerateVolumeGroupJournal(ctx context.Context, groupID, requestName string, volumeIds []string) (string, error) } diff --git a/internal/rbd/types/volume.go b/internal/rbd/types/volume.go index fde0125b139..3e5d8ab94c0 100644 --- a/internal/rbd/types/volume.go +++ b/internal/rbd/types/volume.go @@ -25,47 +25,62 @@ import ( "github.com/ceph/ceph-csi/internal/util" ) -//nolint:interfacebloat // more than 10 methods are needed for the interface -type Volume interface { - journalledObject - // Destroy frees the resources used by the Volume. - Destroy(ctx context.Context) - - // Delete removes the volume from the storage backend. - Delete(ctx context.Context) error +type snapshottableVolume interface { + // NewSnapshotByID creates a new Snapshot object based on the details of the Volume. + NewSnapshotByID(ctx context.Context, cr *util.Credentials, name string, id uint64) (Snapshot, error) - // ToCSI creates a CSI protocol formatted struct of the volume. - ToCSI(ctx context.Context) (*csi.Volume, error) + // PrepareVolumeForSnapshot prepares the volume for snapshot by + // checking snapshots limit and clone depth limit and flatten it + // if required. + PrepareVolumeForSnapshot(ctx context.Context, cr *util.Credentials) error +} +type csiAddonsVolume interface { // AddToGroup adds the Volume to the VolumeGroup. AddToGroup(ctx context.Context, vg VolumeGroup) error // RemoveFromGroup removes the Volume from the VolumeGroup. RemoveFromGroup(ctx context.Context, vg VolumeGroup) error - // GetCreationTime returns the creation time of the volume. - GetCreationTime(ctx context.Context) (*time.Time, error) + // RotateEncryptionKey processes the key rotation for the RBD Volume. + RotateEncryptionKey(ctx context.Context) error + + // Sparsify tries to free unused blocks of the volume from the CSI-Addons Controller. + Sparsify(ctx context.Context) error - // GetMetadata returns the value of the metadata key from the volume. - GetMetadata(key string) (string, error) - // SetMetadata sets the value of the metadata key on the volume. - SetMetadata(key, value string) error - // RepairResyncedImageID updates the existing image ID with new one in OMAP. - RepairResyncedImageID(ctx context.Context, ready bool) error // HandleParentImageExistence checks the image's parent. // if the parent image does not exist and is not in trash, it returns nil. // if the flattenMode is FlattenModeForce, it flattens the image itself. // if the parent image is in trash, it returns an error. // if the parent image exists and is not enabled for mirroring, it returns an error. HandleParentImageExistence(ctx context.Context, flattenMode FlattenMode) error - // PrepareVolumeForSnapshot prepares the volume for snapshot by - // checking snapshots limit and clone depth limit and flatten it - // if required. - PrepareVolumeForSnapshot(ctx context.Context, cr *util.Credentials) error + + // RepairResyncedImageID updates the existing image ID with new one in OMAP. + RepairResyncedImageID(ctx context.Context, ready bool) error // ToMirror converts the Volume to a Mirror. ToMirror() (Mirror, error) +} - // NewSnapshotByID creates a new Snapshot object based on the details of the Volume. - NewSnapshotByID(ctx context.Context, cr *util.Credentials, name string, id uint64) (Snapshot, error) +type Volume interface { + journalledObject + snapshottableVolume + csiAddonsVolume + + // Destroy frees the resources used by the Volume. + Destroy(ctx context.Context) + + // Delete removes the volume from the storage backend. + Delete(ctx context.Context) error + + // ToCSI creates a CSI protocol formatted struct of the volume. + ToCSI(ctx context.Context) (*csi.Volume, error) + + // GetCreationTime returns the creation time of the volume. + GetCreationTime(ctx context.Context) (*time.Time, error) + + // GetMetadata returns the value of the metadata key from the volume. + GetMetadata(key string) (string, error) + // SetMetadata sets the value of the metadata key on the volume. + SetMetadata(key, value string) error } diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/LICENSE b/vendor/github.com/csi-addons/kubernetes-csi-addons/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/groupversion_info.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/groupversion_info.go new file mode 100644 index 00000000000..37182b68daf --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/groupversion_info.go @@ -0,0 +1,36 @@ +/* +Copyright 2022 The Kubernetes-CSI-Addons 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 contains API Schema definitions for the replication.storage v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=replication.storage.openshift.io +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "replication.storage.openshift.io", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplication_types.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplication_types.go new file mode 100644 index 00000000000..8ad2bff704f --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplication_types.go @@ -0,0 +1,105 @@ +/* +Copyright 2024 The Kubernetes-CSI-Addons 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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// VolumeGroupReplicationSpec defines the desired state of VolumeGroupReplication +type VolumeGroupReplicationSpec struct { + // volumeGroupReplicationClassName is the volumeGroupReplicationClass name for this VolumeGroupReplication resource + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationClassName is immutable" + VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"` + + // volumeReplicationClassName is the volumeReplicationClass name for VolumeReplication object + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumReplicationClassName is immutable" + VolumeReplicationClassName string `json:"volumeReplicationClassName"` + + // Name of the VolumeReplication object created for this volumeGroupReplication + // +kubebuilder:validation:Optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationName is immutable" + VolumeReplicationName string `json:"volumeReplicationName,omitempty"` + + // Name of the VolumeGroupReplicationContent object created for this volumeGroupReplication + // +kubebuilder:validation:Optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationContentName is immutable" + VolumeGroupReplicationContentName string `json:"volumeGroupReplicationContentName,omitempty"` + + // Source specifies where a group replications will be created from. + // This field is immutable after creation. + // Required. + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="source is immutable" + Source VolumeGroupReplicationSource `json:"source"` + + // ReplicationState represents the replication operation to be performed on the group. + // Supported operations are "primary", "secondary" and "resync" + // +kubebuilder:validation:Required + ReplicationState ReplicationState `json:"replicationState"` + + // AutoResync represents the group to be auto resynced when + // ReplicationState is "secondary" + // +kubebuilder:default:=false + AutoResync bool `json:"autoResync"` +} + +// VolumeGroupReplicationSource specifies the source for the the volumeGroupReplication +type VolumeGroupReplicationSource struct { + // Selector is a label query over persistent volume claims that are to be + // grouped together for replication. + // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="selector is immutable" + Selector *metav1.LabelSelector `json:"selector,omitempty"` +} + +// VolumeGroupReplicationStatus defines the observed state of VolumeGroupReplication +type VolumeGroupReplicationStatus struct { + VolumeReplicationStatus `json:",inline"` + // PersistentVolumeClaimsRefList is the list of PVCs for the volume group replication. + // The maximum number of allowed PVCs in the group is 100. + // +optional + PersistentVolumeClaimsRefList []corev1.LocalObjectReference `json:"persistentVolumeClaimsRefList,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// VolumeGroupReplication is the Schema for the volumegroupreplications API +type VolumeGroupReplication struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec VolumeGroupReplicationSpec `json:"spec,omitempty"` + Status VolumeGroupReplicationStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// VolumeGroupReplicationList contains a list of VolumeGroupReplication +type VolumeGroupReplicationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VolumeGroupReplication `json:"items"` +} + +func init() { + SchemeBuilder.Register(&VolumeGroupReplication{}, &VolumeGroupReplicationList{}) +} diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationclass_types.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationclass_types.go new file mode 100644 index 00000000000..972bcd1ba4b --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationclass_types.go @@ -0,0 +1,67 @@ +/* +Copyright 2024 The Kubernetes-CSI-Addons 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" +) + +// VolumeGroupReplicationClassSpec specifies parameters that an underlying storage system uses +// when creating a volumegroup replica. A specific VolumeGroupReplicationClass is used by specifying +// its name in a VolumeGroupReplication object. +// +kubebuilder:validation:XValidation:rule="has(self.parameters) == has(oldSelf.parameters)",message="parameters are immutable" +type VolumeGroupReplicationClassSpec struct { + // Provisioner is the name of storage provisioner + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="provisioner is immutable" + Provisioner string `json:"provisioner"` + // Parameters is a key-value map with storage provisioner specific configurations for + // creating volume group replicas + // +kubebuilder:validation:Optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="parameters are immutable" + Parameters map[string]string `json:"parameters,omitempty"` +} + +// VolumeGroupReplicationClassStatus defines the observed state of VolumeGroupReplicationClass +type VolumeGroupReplicationClassStatus struct { +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:resource:scope=Cluster + +// VolumeGroupReplicationClass is the Schema for the volumegroupreplicationclasses API +type VolumeGroupReplicationClass struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec VolumeGroupReplicationClassSpec `json:"spec,omitempty"` + Status VolumeGroupReplicationClassStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// VolumeGroupReplicationClassList contains a list of VolumeGroupReplicationClass +type VolumeGroupReplicationClassList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VolumeGroupReplicationClass `json:"items"` +} + +func init() { + SchemeBuilder.Register(&VolumeGroupReplicationClass{}, &VolumeGroupReplicationClassList{}) +} diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go new file mode 100644 index 00000000000..fcbb7a95a88 --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go @@ -0,0 +1,101 @@ +/* +Copyright 2024 The Kubernetes-CSI-Addons 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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// VolumeGroupReplicationContentSpec defines the desired state of VolumeGroupReplicationContent +type VolumeGroupReplicationContentSpec struct { + // VolumeGroupreplicationRef specifies the VolumeGroupReplication object to which this + // VolumeGroupReplicationContent object is bound. + // VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to + // this VolumeGroupReplicationContent's name for the bidirectional binding to be valid. + // For a pre-existing VolumeGroupReplicationContent object, name and namespace of the + // VolumeGroupReplication 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 volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace must be set" + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationRef is immutable" + VolumeGroupReplicationRef corev1.ObjectReference `json:"volumeGroupReplicationRef"` + + // VolumeGroupReplicationHandle is a unique id returned by the CSI driver + // to identify the VolumeGroupReplication on the storage system. + VolumeGroupReplicationHandle string `json:"volumeGroupReplicationHandle"` + + // provisioner is the name of the CSI driver used to create the physical + // volume group on + // the underlying storage system. + // This MUST be the same as the name returned by the CSI GetPluginName() call for + // that driver. + // Required. + Provisioner string `json:"provisioner"` + + // VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from + // which this group replication was (or will be) created. + // +optional + VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"` + + // 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 VolumeGroupReplicationContentSource `json:"source"` +} + +// VolumeGroupReplicationContentSource represents the CSI source of a group replication. +type VolumeGroupReplicationContentSource struct { + // VolumeHandles is a list of volume handles on the backend to be grouped + // and replicated. + VolumeHandles []string `json:"volumeHandles"` +} + +// VolumeGroupReplicationContentStatus defines the status of VolumeGroupReplicationContent +type VolumeGroupReplicationContentStatus struct { + // PersistentVolumeRefList is the list of of PV for the group replication + // The maximum number of allowed PV in the group is 100. + // +optional + PersistentVolumeRefList []corev1.LocalObjectReference `json:"persistentVolumeRefList,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:resource:scope=Cluster + +// VolumeGroupReplicationContent is the Schema for the volumegroupreplicationcontents API +type VolumeGroupReplicationContent struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec VolumeGroupReplicationContentSpec `json:"spec,omitempty"` + Status VolumeGroupReplicationContentStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// VolumeGroupReplicationContentList contains a list of VolumeGroupReplicationContent +type VolumeGroupReplicationContentList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VolumeGroupReplicationContent `json:"items"` +} + +func init() { + SchemeBuilder.Register(&VolumeGroupReplicationContent{}, &VolumeGroupReplicationContentList{}) +} diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplication_types.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplication_types.go new file mode 100644 index 00000000000..d9fca40ad99 --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplication_types.go @@ -0,0 +1,131 @@ +/* +Copyright 2022 The Kubernetes-CSI-Addons 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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + VolumeReplicationNameAnnotation = "replication.storage.openshift.io/volume-replication-name" +) + +// ReplicationState represents the replication operations to be performed on the volume. +// +kubebuilder:validation:Enum=primary;secondary;resync +type ReplicationState string + +const ( + // Primary ReplicationState enables mirroring and promotes the volume to primary. + Primary ReplicationState = "primary" + + // Secondary ReplicationState demotes the volume to secondary and resyncs the volume if out of sync. + Secondary ReplicationState = "secondary" + + // Resync option resyncs the volume. + Resync ReplicationState = "resync" +) + +// State captures the latest state of the replication operation. +type State string + +const ( + // PrimaryState represents the Primary replication state. + PrimaryState State = "Primary" + + // SecondaryState represents the Secondary replication state. + SecondaryState State = "Secondary" + + // UnknownState represents the Unknown replication state. + UnknownState State = "Unknown" +) + +// VolumeReplicationSpec defines the desired state of VolumeReplication. +type VolumeReplicationSpec struct { + // VolumeReplicationClass is the VolumeReplicationClass name for this VolumeReplication resource + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationClass is immutable" + VolumeReplicationClass string `json:"volumeReplicationClass"` + + // ReplicationState represents the replication operation to be performed on the volume. + // Supported operations are "primary", "secondary" and "resync" + // +kubebuilder:validation:Required + ReplicationState ReplicationState `json:"replicationState"` + + // DataSource represents the object associated with the volume + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="dataSource is immutable" + DataSource corev1.TypedLocalObjectReference `json:"dataSource"` + + // AutoResync represents the volume to be auto resynced when + // ReplicationState is "secondary" + // +kubebuilder:default:=false + AutoResync bool `json:"autoResync"` + + // replicationHandle represents an existing (but new) replication id + // +kubebuilder:validation:Optional + ReplicationHandle string `json:"replicationHandle"` +} + +// VolumeReplicationStatus defines the observed state of VolumeReplication. +type VolumeReplicationStatus struct { + State State `json:"state,omitempty"` + Message string `json:"message,omitempty"` + // Conditions are the list of conditions and their status. + Conditions []metav1.Condition `json:"conditions,omitempty"` + // observedGeneration is the last generation change the operator has dealt with + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + LastStartTime *metav1.Time `json:"lastStartTime,omitempty"` + LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"` + LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"` + LastSyncBytes *int64 `json:"lastSyncBytes,omitempty"` + LastSyncDuration *metav1.Duration `json:"lastSyncDuration,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date +// +kubebuilder:printcolumn:JSONPath=".spec.volumeReplicationClass",name=volumeReplicationClass,type=string +// +kubebuilder:printcolumn:JSONPath=".spec.dataSource.name",name=pvcName,type=string +// +kubebuilder:printcolumn:JSONPath=".spec.replicationState",name=desiredState,type=string +// +kubebuilder:printcolumn:JSONPath=".status.state",name=currentState,type=string +// +kubebuilder:resource:shortName=vr + +// VolumeReplication is the Schema for the volumereplications API. +type VolumeReplication struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +kubebuilder:validation:Required + Spec VolumeReplicationSpec `json:"spec"` + + Status VolumeReplicationStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// VolumeReplicationList contains a list of VolumeReplication. +type VolumeReplicationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VolumeReplication `json:"items"` +} + +func init() { + SchemeBuilder.Register(&VolumeReplication{}, &VolumeReplicationList{}) +} diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplicationclass_types.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplicationclass_types.go new file mode 100644 index 00000000000..25632a04948 --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/volumereplicationclass_types.go @@ -0,0 +1,69 @@ +/* +Copyright 2022 The Kubernetes-CSI-Addons 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" +) + +// VolumeReplicationClassSpec specifies parameters that an underlying storage system uses +// when creating a volume replica. A specific VolumeReplicationClass is used by specifying +// its name in a VolumeReplication object. +// +kubebuilder:validation:XValidation:rule="has(self.parameters) == has(oldSelf.parameters)",message="parameters are immutable" +type VolumeReplicationClassSpec struct { + // Provisioner is the name of storage provisioner + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="provisioner is immutable" + Provisioner string `json:"provisioner"` + // Parameters is a key-value map with storage provisioner specific configurations for + // creating volume replicas + // +kubebuilder:validation:Optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="parameters are immutable" + Parameters map[string]string `json:"parameters,omitempty"` +} + +// VolumeReplicationClassStatus defines the observed state of VolumeReplicationClass. +type VolumeReplicationClassStatus struct{} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,shortName=vrc +// +kubebuilder:printcolumn:JSONPath=".spec.provisioner",name=provisioner,type=string + +// VolumeReplicationClass is the Schema for the volumereplicationclasses API. +type VolumeReplicationClass struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +kubebuilder:validation:Required + Spec VolumeReplicationClassSpec `json:"spec"` + + Status VolumeReplicationClassStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// VolumeReplicationClassList contains a list of VolumeReplicationClass. +type VolumeReplicationClassList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VolumeReplicationClass `json:"items"` +} + +func init() { + SchemeBuilder.Register(&VolumeReplicationClass{}, &VolumeReplicationClassList{}) +} diff --git a/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..dcfe62b4615 --- /dev/null +++ b/vendor/github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,570 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2022 The Kubernetes-CSI-Addons 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 controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + "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 *VolumeGroupReplication) DeepCopyInto(out *VolumeGroupReplication) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplication. +func (in *VolumeGroupReplication) DeepCopy() *VolumeGroupReplication { + if in == nil { + return nil + } + out := new(VolumeGroupReplication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupReplication) 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 *VolumeGroupReplicationClass) DeepCopyInto(out *VolumeGroupReplicationClass) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClass. +func (in *VolumeGroupReplicationClass) DeepCopy() *VolumeGroupReplicationClass { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationClass) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupReplicationClass) 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 *VolumeGroupReplicationClassList) DeepCopyInto(out *VolumeGroupReplicationClassList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeGroupReplicationClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClassList. +func (in *VolumeGroupReplicationClassList) DeepCopy() *VolumeGroupReplicationClassList { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationClassList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupReplicationClassList) 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 *VolumeGroupReplicationClassSpec) DeepCopyInto(out *VolumeGroupReplicationClassSpec) { + *out = *in + 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 + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClassSpec. +func (in *VolumeGroupReplicationClassSpec) DeepCopy() *VolumeGroupReplicationClassSpec { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationClassSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationClassStatus) DeepCopyInto(out *VolumeGroupReplicationClassStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationClassStatus. +func (in *VolumeGroupReplicationClassStatus) DeepCopy() *VolumeGroupReplicationClassStatus { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationClassStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationContent) DeepCopyInto(out *VolumeGroupReplicationContent) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContent. +func (in *VolumeGroupReplicationContent) DeepCopy() *VolumeGroupReplicationContent { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationContent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupReplicationContent) 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 *VolumeGroupReplicationContentList) DeepCopyInto(out *VolumeGroupReplicationContentList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeGroupReplicationContent, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentList. +func (in *VolumeGroupReplicationContentList) DeepCopy() *VolumeGroupReplicationContentList { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationContentList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupReplicationContentList) 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 *VolumeGroupReplicationContentSource) DeepCopyInto(out *VolumeGroupReplicationContentSource) { + *out = *in + if in.VolumeHandles != nil { + in, out := &in.VolumeHandles, &out.VolumeHandles + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentSource. +func (in *VolumeGroupReplicationContentSource) DeepCopy() *VolumeGroupReplicationContentSource { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationContentSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationContentSpec) DeepCopyInto(out *VolumeGroupReplicationContentSpec) { + *out = *in + out.VolumeGroupReplicationRef = in.VolumeGroupReplicationRef + in.Source.DeepCopyInto(&out.Source) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentSpec. +func (in *VolumeGroupReplicationContentSpec) DeepCopy() *VolumeGroupReplicationContentSpec { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationContentSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationContentStatus) DeepCopyInto(out *VolumeGroupReplicationContentStatus) { + *out = *in + if in.PersistentVolumeRefList != nil { + in, out := &in.PersistentVolumeRefList, &out.PersistentVolumeRefList + *out = make([]corev1.LocalObjectReference, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationContentStatus. +func (in *VolumeGroupReplicationContentStatus) DeepCopy() *VolumeGroupReplicationContentStatus { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationContentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationList) DeepCopyInto(out *VolumeGroupReplicationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeGroupReplication, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationList. +func (in *VolumeGroupReplicationList) DeepCopy() *VolumeGroupReplicationList { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeGroupReplicationList) 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 *VolumeGroupReplicationSource) DeepCopyInto(out *VolumeGroupReplicationSource) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationSource. +func (in *VolumeGroupReplicationSource) DeepCopy() *VolumeGroupReplicationSource { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationSpec) DeepCopyInto(out *VolumeGroupReplicationSpec) { + *out = *in + in.Source.DeepCopyInto(&out.Source) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationSpec. +func (in *VolumeGroupReplicationSpec) DeepCopy() *VolumeGroupReplicationSpec { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupReplicationStatus) DeepCopyInto(out *VolumeGroupReplicationStatus) { + *out = *in + in.VolumeReplicationStatus.DeepCopyInto(&out.VolumeReplicationStatus) + if in.PersistentVolumeClaimsRefList != nil { + in, out := &in.PersistentVolumeClaimsRefList, &out.PersistentVolumeClaimsRefList + *out = make([]corev1.LocalObjectReference, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupReplicationStatus. +func (in *VolumeGroupReplicationStatus) DeepCopy() *VolumeGroupReplicationStatus { + if in == nil { + return nil + } + out := new(VolumeGroupReplicationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeReplication) DeepCopyInto(out *VolumeReplication) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplication. +func (in *VolumeReplication) DeepCopy() *VolumeReplication { + if in == nil { + return nil + } + out := new(VolumeReplication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeReplication) 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 *VolumeReplicationClass) DeepCopyInto(out *VolumeReplicationClass) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClass. +func (in *VolumeReplicationClass) DeepCopy() *VolumeReplicationClass { + if in == nil { + return nil + } + out := new(VolumeReplicationClass) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeReplicationClass) 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 *VolumeReplicationClassList) DeepCopyInto(out *VolumeReplicationClassList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeReplicationClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClassList. +func (in *VolumeReplicationClassList) DeepCopy() *VolumeReplicationClassList { + if in == nil { + return nil + } + out := new(VolumeReplicationClassList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeReplicationClassList) 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 *VolumeReplicationClassSpec) DeepCopyInto(out *VolumeReplicationClassSpec) { + *out = *in + 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 + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClassSpec. +func (in *VolumeReplicationClassSpec) DeepCopy() *VolumeReplicationClassSpec { + if in == nil { + return nil + } + out := new(VolumeReplicationClassSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeReplicationClassStatus) DeepCopyInto(out *VolumeReplicationClassStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationClassStatus. +func (in *VolumeReplicationClassStatus) DeepCopy() *VolumeReplicationClassStatus { + if in == nil { + return nil + } + out := new(VolumeReplicationClassStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeReplicationList) DeepCopyInto(out *VolumeReplicationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VolumeReplication, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationList. +func (in *VolumeReplicationList) DeepCopy() *VolumeReplicationList { + if in == nil { + return nil + } + out := new(VolumeReplicationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VolumeReplicationList) 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 *VolumeReplicationSpec) DeepCopyInto(out *VolumeReplicationSpec) { + *out = *in + in.DataSource.DeepCopyInto(&out.DataSource) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationSpec. +func (in *VolumeReplicationSpec) DeepCopy() *VolumeReplicationSpec { + if in == nil { + return nil + } + out := new(VolumeReplicationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeReplicationStatus) DeepCopyInto(out *VolumeReplicationStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.LastStartTime != nil { + in, out := &in.LastStartTime, &out.LastStartTime + *out = (*in).DeepCopy() + } + if in.LastCompletionTime != nil { + in, out := &in.LastCompletionTime, &out.LastCompletionTime + *out = (*in).DeepCopy() + } + if in.LastSyncTime != nil { + in, out := &in.LastSyncTime, &out.LastSyncTime + *out = (*in).DeepCopy() + } + if in.LastSyncBytes != nil { + in, out := &in.LastSyncBytes, &out.LastSyncBytes + *out = new(int64) + **out = **in + } + if in.LastSyncDuration != nil { + in, out := &in.LastSyncDuration, &out.LastSyncDuration + *out = new(v1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeReplicationStatus. +func (in *VolumeReplicationStatus) DeepCopy() *VolumeReplicationStatus { + if in == nil { + return nil + } + out := new(VolumeReplicationStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/google.golang.org/protobuf/internal/version/version.go b/vendor/google.golang.org/protobuf/internal/version/version.go index f5c06280fe3..4a39af0c635 100644 --- a/vendor/google.golang.org/protobuf/internal/version/version.go +++ b/vendor/google.golang.org/protobuf/internal/version/version.go @@ -52,7 +52,7 @@ import ( const ( Major = 1 Minor = 36 - Patch = 3 + Patch = 4 PreRelease = "" ) diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go b/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go index f55b0369596..697a61b290e 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go @@ -11,6 +11,7 @@ import ( "google.golang.org/protobuf/internal/editiondefaults" "google.golang.org/protobuf/internal/filedesc" + "google.golang.org/protobuf/internal/genid" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/descriptorpb" @@ -128,23 +129,39 @@ func mergeEditionFeatures(parentDesc protoreflect.Descriptor, child *descriptorp // We must not use proto.GetExtension(child, gofeaturespb.E_Go) // because that only works for messages we generated, but not for // dynamicpb messages. See golang/protobuf#1669. + // + // Further, we harden this code against adversarial inputs: a + // service which accepts descriptors from a possibly malicious + // source shouldn't crash. goFeatures := child.ProtoReflect().Get(gofeaturespb.E_Go.TypeDescriptor()) if !goFeatures.IsValid() { return parentFS } + gf, ok := goFeatures.Interface().(protoreflect.Message) + if !ok { + return parentFS + } // gf.Interface() could be *dynamicpb.Message or *gofeaturespb.GoFeatures. - gf := goFeatures.Message() fields := gf.Descriptor().Fields() - if fd := fields.ByName("legacy_unmarshal_json_enum"); gf.Has(fd) { + if fd := fields.ByNumber(genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number); fd != nil && + !fd.IsList() && + fd.Kind() == protoreflect.BoolKind && + gf.Has(fd) { parentFS.GenerateLegacyUnmarshalJSON = gf.Get(fd).Bool() } - if fd := fields.ByName("strip_enum_prefix"); gf.Has(fd) { + if fd := fields.ByNumber(genid.GoFeatures_StripEnumPrefix_field_number); fd != nil && + !fd.IsList() && + fd.Kind() == protoreflect.EnumKind && + gf.Has(fd) { parentFS.StripEnumPrefix = int(gf.Get(fd).Enum()) } - if fd := fields.ByName("api_level"); gf.Has(fd) { + if fd := fields.ByNumber(genid.GoFeatures_ApiLevel_field_number); fd != nil && + !fd.IsList() && + fd.Kind() == protoreflect.EnumKind && + gf.Has(fd) { parentFS.APILevel = int(gf.Get(fd).Enum()) } diff --git a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go index a551e7ae945..a5163376741 100644 --- a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +++ b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go @@ -46,6 +46,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) // The full set of known editions. @@ -4360,7 +4361,7 @@ func (x *GeneratedCodeInfo_Annotation) GetSemantic() GeneratedCodeInfo_Annotatio var File_google_protobuf_descriptor_proto protoreflect.FileDescriptor -var file_google_protobuf_descriptor_proto_rawDesc = []byte{ +var file_google_protobuf_descriptor_proto_rawDesc = string([]byte{ 0x0a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, @@ -5130,16 +5131,16 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, -} +}) var ( file_google_protobuf_descriptor_proto_rawDescOnce sync.Once - file_google_protobuf_descriptor_proto_rawDescData = file_google_protobuf_descriptor_proto_rawDesc + file_google_protobuf_descriptor_proto_rawDescData []byte ) func file_google_protobuf_descriptor_proto_rawDescGZIP() []byte { file_google_protobuf_descriptor_proto_rawDescOnce.Do(func() { - file_google_protobuf_descriptor_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_descriptor_proto_rawDescData) + file_google_protobuf_descriptor_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_descriptor_proto_rawDesc), len(file_google_protobuf_descriptor_proto_rawDesc))) }) return file_google_protobuf_descriptor_proto_rawDescData } @@ -5292,7 +5293,7 @@ func file_google_protobuf_descriptor_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_descriptor_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_descriptor_proto_rawDesc), len(file_google_protobuf_descriptor_proto_rawDesc)), NumEnums: 17, NumMessages: 33, NumExtensions: 0, @@ -5304,7 +5305,6 @@ func file_google_protobuf_descriptor_proto_init() { MessageInfos: file_google_protobuf_descriptor_proto_msgTypes, }.Build() File_google_protobuf_descriptor_proto = out.File - file_google_protobuf_descriptor_proto_rawDesc = nil file_google_protobuf_descriptor_proto_goTypes = nil file_google_protobuf_descriptor_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go index e0b72eaf922..28d24bad79e 100644 --- a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go +++ b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go @@ -16,6 +16,7 @@ import ( descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" sync "sync" + unsafe "unsafe" ) type GoFeatures_APILevel int32 @@ -227,7 +228,7 @@ var ( var File_google_protobuf_go_features_proto protoreflect.FileDescriptor -var file_google_protobuf_go_features_proto_rawDesc = []byte{ +var file_google_protobuf_go_features_proto_rawDesc = string([]byte{ 0x0a, 0x21, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x6f, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, @@ -283,16 +284,16 @@ var file_google_protobuf_go_features_proto_rawDesc = []byte{ 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x67, 0x6f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x70, 0x62, -} +}) var ( file_google_protobuf_go_features_proto_rawDescOnce sync.Once - file_google_protobuf_go_features_proto_rawDescData = file_google_protobuf_go_features_proto_rawDesc + file_google_protobuf_go_features_proto_rawDescData []byte ) func file_google_protobuf_go_features_proto_rawDescGZIP() []byte { file_google_protobuf_go_features_proto_rawDescOnce.Do(func() { - file_google_protobuf_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_go_features_proto_rawDescData) + file_google_protobuf_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_go_features_proto_rawDesc), len(file_google_protobuf_go_features_proto_rawDesc))) }) return file_google_protobuf_go_features_proto_rawDescData } @@ -326,7 +327,7 @@ func file_google_protobuf_go_features_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_go_features_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_go_features_proto_rawDesc), len(file_google_protobuf_go_features_proto_rawDesc)), NumEnums: 2, NumMessages: 1, NumExtensions: 1, @@ -339,7 +340,6 @@ func file_google_protobuf_go_features_proto_init() { ExtensionInfos: file_google_protobuf_go_features_proto_extTypes, }.Build() File_google_protobuf_go_features_proto = out.File - file_google_protobuf_go_features_proto_rawDesc = nil file_google_protobuf_go_features_proto_goTypes = nil file_google_protobuf_go_features_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go index 191552cce09..497da66e91f 100644 --- a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go @@ -122,6 +122,7 @@ import ( reflect "reflect" strings "strings" sync "sync" + unsafe "unsafe" ) // `Any` contains an arbitrary serialized protocol buffer message along with a @@ -411,7 +412,7 @@ func (x *Any) GetValue() []byte { var File_google_protobuf_any_proto protoreflect.FileDescriptor -var file_google_protobuf_any_proto_rawDesc = []byte{ +var file_google_protobuf_any_proto_rawDesc = string([]byte{ 0x0a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x36, 0x0a, 0x03, @@ -427,16 +428,16 @@ var file_google_protobuf_any_proto_rawDesc = []byte{ 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_any_proto_rawDescOnce sync.Once - file_google_protobuf_any_proto_rawDescData = file_google_protobuf_any_proto_rawDesc + file_google_protobuf_any_proto_rawDescData []byte ) func file_google_protobuf_any_proto_rawDescGZIP() []byte { file_google_protobuf_any_proto_rawDescOnce.Do(func() { - file_google_protobuf_any_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_any_proto_rawDescData) + file_google_protobuf_any_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_any_proto_rawDesc), len(file_google_protobuf_any_proto_rawDesc))) }) return file_google_protobuf_any_proto_rawDescData } @@ -462,7 +463,7 @@ func file_google_protobuf_any_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_any_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_any_proto_rawDesc), len(file_google_protobuf_any_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -473,7 +474,6 @@ func file_google_protobuf_any_proto_init() { MessageInfos: file_google_protobuf_any_proto_msgTypes, }.Build() File_google_protobuf_any_proto = out.File - file_google_protobuf_any_proto_rawDesc = nil file_google_protobuf_any_proto_goTypes = nil file_google_protobuf_any_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go b/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go index 34d76e6cd93..193880d1813 100644 --- a/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go @@ -80,6 +80,7 @@ import ( reflect "reflect" sync "sync" time "time" + unsafe "unsafe" ) // A Duration represents a signed, fixed-length span of time represented @@ -288,7 +289,7 @@ func (x *Duration) GetNanos() int32 { var File_google_protobuf_duration_proto protoreflect.FileDescriptor -var file_google_protobuf_duration_proto_rawDesc = []byte{ +var file_google_protobuf_duration_proto_rawDesc = string([]byte{ 0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, @@ -305,16 +306,16 @@ var file_google_protobuf_duration_proto_rawDesc = []byte{ 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_duration_proto_rawDescOnce sync.Once - file_google_protobuf_duration_proto_rawDescData = file_google_protobuf_duration_proto_rawDesc + file_google_protobuf_duration_proto_rawDescData []byte ) func file_google_protobuf_duration_proto_rawDescGZIP() []byte { file_google_protobuf_duration_proto_rawDescOnce.Do(func() { - file_google_protobuf_duration_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_duration_proto_rawDescData) + file_google_protobuf_duration_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_duration_proto_rawDesc), len(file_google_protobuf_duration_proto_rawDesc))) }) return file_google_protobuf_duration_proto_rawDescData } @@ -340,7 +341,7 @@ func file_google_protobuf_duration_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_duration_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_duration_proto_rawDesc), len(file_google_protobuf_duration_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -351,7 +352,6 @@ func file_google_protobuf_duration_proto_init() { MessageInfos: file_google_protobuf_duration_proto_msgTypes, }.Build() File_google_protobuf_duration_proto = out.File - file_google_protobuf_duration_proto_rawDesc = nil file_google_protobuf_duration_proto_goTypes = nil file_google_protobuf_duration_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go index 7fcdd382cc9..a5b8657c4ba 100644 --- a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go @@ -38,6 +38,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) // A generic empty message that you can re-use to avoid defining duplicated @@ -85,7 +86,7 @@ func (*Empty) Descriptor() ([]byte, []int) { var File_google_protobuf_empty_proto protoreflect.FileDescriptor -var file_google_protobuf_empty_proto_rawDesc = []byte{ +var file_google_protobuf_empty_proto_rawDesc = string([]byte{ 0x0a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x07, @@ -98,16 +99,16 @@ var file_google_protobuf_empty_proto_rawDesc = []byte{ 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_empty_proto_rawDescOnce sync.Once - file_google_protobuf_empty_proto_rawDescData = file_google_protobuf_empty_proto_rawDesc + file_google_protobuf_empty_proto_rawDescData []byte ) func file_google_protobuf_empty_proto_rawDescGZIP() []byte { file_google_protobuf_empty_proto_rawDescOnce.Do(func() { - file_google_protobuf_empty_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_empty_proto_rawDescData) + file_google_protobuf_empty_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_empty_proto_rawDesc), len(file_google_protobuf_empty_proto_rawDesc))) }) return file_google_protobuf_empty_proto_rawDescData } @@ -133,7 +134,7 @@ func file_google_protobuf_empty_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_empty_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_empty_proto_rawDesc), len(file_google_protobuf_empty_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -144,7 +145,6 @@ func file_google_protobuf_empty_proto_init() { MessageInfos: file_google_protobuf_empty_proto_msgTypes, }.Build() File_google_protobuf_empty_proto = out.File - file_google_protobuf_empty_proto_rawDesc = nil file_google_protobuf_empty_proto_goTypes = nil file_google_protobuf_empty_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go b/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go index e5d7da38c20..041feb0f3ec 100644 --- a/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go @@ -83,6 +83,7 @@ import ( sort "sort" strings "strings" sync "sync" + unsafe "unsafe" ) // `FieldMask` represents a set of symbolic field paths, for example: @@ -503,7 +504,7 @@ func (x *FieldMask) GetPaths() []string { var File_google_protobuf_field_mask_proto protoreflect.FileDescriptor -var file_google_protobuf_field_mask_proto_rawDesc = []byte{ +var file_google_protobuf_field_mask_proto_rawDesc = string([]byte{ 0x0a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, @@ -519,16 +520,16 @@ var file_google_protobuf_field_mask_proto_rawDesc = []byte{ 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_field_mask_proto_rawDescOnce sync.Once - file_google_protobuf_field_mask_proto_rawDescData = file_google_protobuf_field_mask_proto_rawDesc + file_google_protobuf_field_mask_proto_rawDescData []byte ) func file_google_protobuf_field_mask_proto_rawDescGZIP() []byte { file_google_protobuf_field_mask_proto_rawDescOnce.Do(func() { - file_google_protobuf_field_mask_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_field_mask_proto_rawDescData) + file_google_protobuf_field_mask_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_field_mask_proto_rawDesc), len(file_google_protobuf_field_mask_proto_rawDesc))) }) return file_google_protobuf_field_mask_proto_rawDescData } @@ -554,7 +555,7 @@ func file_google_protobuf_field_mask_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_field_mask_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_field_mask_proto_rawDesc), len(file_google_protobuf_field_mask_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -565,7 +566,6 @@ func file_google_protobuf_field_mask_proto_init() { MessageInfos: file_google_protobuf_field_mask_proto_msgTypes, }.Build() File_google_protobuf_field_mask_proto = out.File - file_google_protobuf_field_mask_proto_rawDesc = nil file_google_protobuf_field_mask_proto_goTypes = nil file_google_protobuf_field_mask_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go index f2c53ea337c..ecdd31ab538 100644 --- a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go @@ -128,6 +128,7 @@ import ( reflect "reflect" sync "sync" utf8 "unicode/utf8" + unsafe "unsafe" ) // `NullValue` is a singleton enumeration to represent the null value for the @@ -671,7 +672,7 @@ func (x *ListValue) GetValues() []*Value { var File_google_protobuf_struct_proto protoreflect.FileDescriptor -var file_google_protobuf_struct_proto_rawDesc = []byte{ +var file_google_protobuf_struct_proto_rawDesc = string([]byte{ 0x0a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, @@ -719,16 +720,16 @@ var file_google_protobuf_struct_proto_rawDesc = []byte{ 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_struct_proto_rawDescOnce sync.Once - file_google_protobuf_struct_proto_rawDescData = file_google_protobuf_struct_proto_rawDesc + file_google_protobuf_struct_proto_rawDescData []byte ) func file_google_protobuf_struct_proto_rawDescGZIP() []byte { file_google_protobuf_struct_proto_rawDescOnce.Do(func() { - file_google_protobuf_struct_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_struct_proto_rawDescData) + file_google_protobuf_struct_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_struct_proto_rawDesc), len(file_google_protobuf_struct_proto_rawDesc))) }) return file_google_protobuf_struct_proto_rawDescData } @@ -773,7 +774,7 @@ func file_google_protobuf_struct_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_struct_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_struct_proto_rawDesc), len(file_google_protobuf_struct_proto_rawDesc)), NumEnums: 1, NumMessages: 4, NumExtensions: 0, @@ -785,7 +786,6 @@ func file_google_protobuf_struct_proto_init() { MessageInfos: file_google_protobuf_struct_proto_msgTypes, }.Build() File_google_protobuf_struct_proto = out.File - file_google_protobuf_struct_proto_rawDesc = nil file_google_protobuf_struct_proto_goTypes = nil file_google_protobuf_struct_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go index 9550109aa3b..00ac835c0bb 100644 --- a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go @@ -78,6 +78,7 @@ import ( reflect "reflect" sync "sync" time "time" + unsafe "unsafe" ) // A Timestamp represents a point in time independent of any time zone or local @@ -297,7 +298,7 @@ func (x *Timestamp) GetNanos() int32 { var File_google_protobuf_timestamp_proto protoreflect.FileDescriptor -var file_google_protobuf_timestamp_proto_rawDesc = []byte{ +var file_google_protobuf_timestamp_proto_rawDesc = string([]byte{ 0x0a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, @@ -314,16 +315,16 @@ var file_google_protobuf_timestamp_proto_rawDesc = []byte{ 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_timestamp_proto_rawDescOnce sync.Once - file_google_protobuf_timestamp_proto_rawDescData = file_google_protobuf_timestamp_proto_rawDesc + file_google_protobuf_timestamp_proto_rawDescData []byte ) func file_google_protobuf_timestamp_proto_rawDescGZIP() []byte { file_google_protobuf_timestamp_proto_rawDescOnce.Do(func() { - file_google_protobuf_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_timestamp_proto_rawDescData) + file_google_protobuf_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_timestamp_proto_rawDesc), len(file_google_protobuf_timestamp_proto_rawDesc))) }) return file_google_protobuf_timestamp_proto_rawDescData } @@ -349,7 +350,7 @@ func file_google_protobuf_timestamp_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_timestamp_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_timestamp_proto_rawDesc), len(file_google_protobuf_timestamp_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -360,7 +361,6 @@ func file_google_protobuf_timestamp_proto_init() { MessageInfos: file_google_protobuf_timestamp_proto_msgTypes, }.Build() File_google_protobuf_timestamp_proto = out.File - file_google_protobuf_timestamp_proto_rawDesc = nil file_google_protobuf_timestamp_proto_goTypes = nil file_google_protobuf_timestamp_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go b/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go index 15b424ec12c..5de5301063b 100644 --- a/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go @@ -48,6 +48,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) // Wrapper message for `double`. @@ -529,7 +530,7 @@ func (x *BytesValue) GetValue() []byte { var File_google_protobuf_wrappers_proto protoreflect.FileDescriptor -var file_google_protobuf_wrappers_proto_rawDesc = []byte{ +var file_google_protobuf_wrappers_proto_rawDesc = string([]byte{ 0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, @@ -563,16 +564,16 @@ var file_google_protobuf_wrappers_proto_rawDesc = []byte{ 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_google_protobuf_wrappers_proto_rawDescOnce sync.Once - file_google_protobuf_wrappers_proto_rawDescData = file_google_protobuf_wrappers_proto_rawDesc + file_google_protobuf_wrappers_proto_rawDescData []byte ) func file_google_protobuf_wrappers_proto_rawDescGZIP() []byte { file_google_protobuf_wrappers_proto_rawDescOnce.Do(func() { - file_google_protobuf_wrappers_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_wrappers_proto_rawDescData) + file_google_protobuf_wrappers_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_wrappers_proto_rawDesc), len(file_google_protobuf_wrappers_proto_rawDesc))) }) return file_google_protobuf_wrappers_proto_rawDescData } @@ -606,7 +607,7 @@ func file_google_protobuf_wrappers_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_wrappers_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_wrappers_proto_rawDesc), len(file_google_protobuf_wrappers_proto_rawDesc)), NumEnums: 0, NumMessages: 9, NumExtensions: 0, @@ -617,7 +618,6 @@ func file_google_protobuf_wrappers_proto_init() { MessageInfos: file_google_protobuf_wrappers_proto_msgTypes, }.Build() File_google_protobuf_wrappers_proto = out.File - file_google_protobuf_wrappers_proto_rawDesc = nil file_google_protobuf_wrappers_proto_goTypes = nil file_google_protobuf_wrappers_proto_depIdxs = nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 12f47331e10..e0b161b9943 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -265,6 +265,9 @@ github.com/coreos/go-semver/semver github.com/coreos/go-systemd/v22/daemon github.com/coreos/go-systemd/v22/dbus github.com/coreos/go-systemd/v22/journal +# github.com/csi-addons/kubernetes-csi-addons v0.9.0 +## explicit; go 1.22.0 +github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1 # github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 ## explicit github.com/csi-addons/spec/lib/go/encryptionkeyrotation @@ -1003,7 +1006,7 @@ google.golang.org/grpc/serviceconfig google.golang.org/grpc/stats google.golang.org/grpc/status google.golang.org/grpc/tap -# google.golang.org/protobuf v1.36.3 +# google.golang.org/protobuf v1.36.4 ## explicit; go 1.21 google.golang.org/protobuf/encoding/protodelim google.golang.org/protobuf/encoding/protojson @@ -2067,6 +2070,7 @@ sigs.k8s.io/controller-runtime/pkg/metrics/server sigs.k8s.io/controller-runtime/pkg/predicate sigs.k8s.io/controller-runtime/pkg/reconcile sigs.k8s.io/controller-runtime/pkg/recorder +sigs.k8s.io/controller-runtime/pkg/scheme sigs.k8s.io/controller-runtime/pkg/source sigs.k8s.io/controller-runtime/pkg/webhook sigs.k8s.io/controller-runtime/pkg/webhook/admission diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/scheme/scheme.go b/vendor/sigs.k8s.io/controller-runtime/pkg/scheme/scheme.go new file mode 100644 index 00000000000..55ebe217735 --- /dev/null +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/scheme/scheme.go @@ -0,0 +1,93 @@ +/* +Copyright 2018 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 scheme contains utilities for gradually building Schemes, +// which contain information associating Go types with Kubernetes +// groups, versions, and kinds. +// +// Each API group should define a utility function +// called AddToScheme for adding its types to a Scheme: +// +// // in package myapigroupv1... +// var ( +// SchemeGroupVersion = schema.GroupVersion{Group: "my.api.group", Version: "v1"} +// SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} +// AddToScheme = SchemeBuilder.AddToScheme +// ) +// +// func init() { +// SchemeBuilder.Register(&MyType{}, &MyTypeList) +// } +// var ( +// scheme *runtime.Scheme = runtime.NewScheme() +// ) +// +// This also true of the built-in Kubernetes types. Then, in the entrypoint for +// your manager, assemble the scheme containing exactly the types you need, +// panicing if scheme registration failed. For instance, if our controller needs +// types from the core/v1 API group (e.g. Pod), plus types from my.api.group/v1: +// +// func init() { +// utilruntime.Must(myapigroupv1.AddToScheme(scheme)) +// utilruntime.Must(kubernetesscheme.AddToScheme(scheme)) +// } +// +// func main() { +// mgr := controllers.NewManager(context.Background(), controllers.GetConfigOrDie(), manager.Options{ +// Scheme: scheme, +// }) +// // ... +// } +package scheme + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// Builder builds a new Scheme for mapping go types to Kubernetes GroupVersionKinds. +type Builder struct { + GroupVersion schema.GroupVersion + runtime.SchemeBuilder +} + +// Register adds one or more objects to the SchemeBuilder so they can be added to a Scheme. Register mutates bld. +func (bld *Builder) Register(object ...runtime.Object) *Builder { + bld.SchemeBuilder.Register(func(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(bld.GroupVersion, object...) + metav1.AddToGroupVersion(scheme, bld.GroupVersion) + return nil + }) + return bld +} + +// RegisterAll registers all types from the Builder argument. RegisterAll mutates bld. +func (bld *Builder) RegisterAll(b *Builder) *Builder { + bld.SchemeBuilder = append(bld.SchemeBuilder, b.SchemeBuilder...) + return bld +} + +// AddToScheme adds all registered types to s. +func (bld *Builder) AddToScheme(s *runtime.Scheme) error { + return bld.SchemeBuilder.AddToScheme(s) +} + +// Build returns a new Scheme containing the registered types. +func (bld *Builder) Build() (*runtime.Scheme, error) { + s := runtime.NewScheme() + return s, bld.AddToScheme(s) +}