Skip to content

Commit 212956b

Browse files
committed
controllers: Generates VGSClass
Signed-off-by: raaizik <[email protected]>
1 parent 273a0c9 commit 212956b

File tree

14 files changed

+1237
-25
lines changed

14 files changed

+1237
-25
lines changed

bundle/manifests/ocs-client-operator.clusterserviceversion.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,24 @@ spec:
208208
- list
209209
- update
210210
- watch
211+
- apiGroups:
212+
- groupsnapshot.storage.k8s.io
213+
resources:
214+
- volumegroupsnapshotclasses
215+
verbs:
216+
- create
217+
- delete
218+
- get
219+
- list
220+
- watch
221+
- apiGroups:
222+
- groupsnapshot.storage.k8s.io
223+
resources:
224+
- volumegroupsnapshotcontents
225+
verbs:
226+
- get
227+
- list
228+
- watch
211229
- apiGroups:
212230
- monitoring.coreos.com
213231
resources:

config/rbac/role.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ rules:
165165
- list
166166
- update
167167
- watch
168+
- apiGroups:
169+
- groupsnapshot.storage.k8s.io
170+
resources:
171+
- volumegroupsnapshotclasses
172+
verbs:
173+
- create
174+
- delete
175+
- get
176+
- list
177+
- watch
178+
- apiGroups:
179+
- groupsnapshot.storage.k8s.io
180+
resources:
181+
- volumegroupsnapshotcontents
182+
verbs:
183+
- get
184+
- list
185+
- watch
168186
- apiGroups:
169187
- monitoring.coreos.com
170188
resources:

go.mod

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.22.7
55
replace (
66
github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 // required by Rook v1.12
77
github.com/red-hat-storage/ocs-client-operator/api => ./api
8+
k8s.io/client-go v12.0.0+incompatible => k8s.io/client-go v0.29.0
89
vbom.ml/util => github.com/fvbommel/util v0.0.0-20180919145318-efcd4e0f9787
910
)
1011

@@ -18,20 +19,22 @@ exclude (
1819
)
1920

2021
require (
21-
github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3
22+
github.com/ceph/ceph-csi-operator/api v0.0.0-20241119082218-62dc94e55c32
2223
github.com/csi-addons/kubernetes-csi-addons v0.10.0
2324
github.com/go-logr/logr v1.4.2
24-
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0
25+
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0
2526
github.com/onsi/ginkgo v1.16.5
2627
github.com/onsi/gomega v1.34.2
2728
github.com/openshift/api v0.0.0-20240828125535-01b3675ba7b3
2829
github.com/operator-framework/api v0.27.0
30+
github.com/pkg/errors v0.9.1 // indirect
2931
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.76.0
30-
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237
32+
github.com/ramendr/ramen/api v0.0.0-20241105140706-d8587766acb3
3133
github.com/red-hat-storage/ocs-client-operator/api v0.0.0-00010101000000-000000000000
3234
github.com/red-hat-storage/ocs-operator/services/provider/api/v4 v4.0.0-20241120160011-2e7cf0127dd4
3335
github.com/stretchr/testify v1.9.0
3436
google.golang.org/grpc v1.68.0
37+
gopkg.in/yaml.v2 v2.4.0 // indirect
3538
k8s.io/api v0.31.1
3639
k8s.io/apiextensions-apiserver v0.31.0
3740
k8s.io/apimachinery v0.31.1
@@ -46,10 +49,8 @@ require (
4649
github.com/klauspost/compress v1.17.9 // indirect
4750
github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect
4851
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 // indirect
49-
github.com/pkg/errors v0.9.1 // indirect
5052
github.com/x448/float16 v0.8.4 // indirect
5153
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
52-
gopkg.in/yaml.v2 v2.4.0 // indirect
5354
k8s.io/component-base v0.31.0 // indirect
5455
sigs.k8s.io/container-object-storage-interface-api v0.1.0 // indirect
5556
)

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
5454
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
5555
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
5656
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
57-
github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3 h1:ft8h5V7BfQqIGJAyiTvn6x86Oi/yMs8yqW7rfKvN9SQ=
58-
github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3/go.mod h1:odEUoarG26wXBCC2l4O4nMWhAz6VTKr2FRkv9yELgi8=
57+
github.com/ceph/ceph-csi-operator/api v0.0.0-20241119082218-62dc94e55c32 h1:IawGJ9fPalvY77XtDElI4ZoVfU5aLnEKL3kwWBn3YEA=
58+
github.com/ceph/ceph-csi-operator/api v0.0.0-20241119082218-62dc94e55c32/go.mod h1:odEUoarG26wXBCC2l4O4nMWhAz6VTKr2FRkv9yELgi8=
5959
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
6060
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
6161
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@@ -256,8 +256,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
256256
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
257257
github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 h1:dQEHhTfi+bSIOSViQrKY9PqJvZenD6tFz+3lPzux58o=
258258
github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1/go.mod h1:my+EVjOJLeQ9lUR9uVkxRvNNkhO2saSGIgzV8GZT9HY=
259-
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0 h1:mjQG0Vakr2h246kEDR85U8y8ZhPgT3bguTCajRa/jaw=
260-
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0/go.mod h1:E3vdYxHj2C2q6qo8/Da4g7P+IcwqRZyy3gJBzYybV9Y=
259+
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0 h1:Q3jQ1NkFqv5o+F8dMmHd8SfEmlcwNeo1immFApntEwE=
260+
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0/go.mod h1:E3vdYxHj2C2q6qo8/Da4g7P+IcwqRZyy3gJBzYybV9Y=
261261
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
262262
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
263263
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
@@ -325,8 +325,8 @@ github.com/prometheus/common v0.57.0 h1:Ro/rKjwdq9mZn1K5QPctzh+MA4Lp0BuYk5ZZEVho
325325
github.com/prometheus/common v0.57.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
326326
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
327327
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
328-
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237 h1:ig6ePD0yopC5Qi5BRmhsIsKaOkdsGXTSmG3HTYIpquo=
329-
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237/go.mod h1:nO6VM/+PEhcPGyFIQJdhY6ip822cA61PAy/s6IjenAA=
328+
github.com/ramendr/ramen/api v0.0.0-20241105140706-d8587766acb3 h1:q4UjNvv3jzKOeG/S+S1Ms2FV3WajBIE6266/7BIxdX4=
329+
github.com/ramendr/ramen/api v0.0.0-20241105140706-d8587766acb3/go.mod h1:O7VpTy8MMrh31DF4fv+2SZBSouAr8NlzIY4KYx7K75U=
330330
github.com/red-hat-storage/ocs-operator/services/provider/api/v4 v4.0.0-20241120160011-2e7cf0127dd4 h1:ppE7R+yh9I2PZuGPaUDdwQ45ZFV8YfHFNKccOxTo8tg=
331331
github.com/red-hat-storage/ocs-operator/services/provider/api/v4 v4.0.0-20241120160011-2e7cf0127dd4/go.mod h1:XEZxUtzjlARPV8YvzcX2p7iiRbrUbDP4Q/CXx9ly5lw=
332332
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=

internal/controller/operatorconfigmap_controller.go

+4
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ func (c *OperatorConfigMapReconciler) reconcileDelegatedCSI() error {
351351
templates.CSIOperatorConfigSpec.DeepCopyInto(&csiOperatorConfig.Spec)
352352
csiOperatorConfig.Spec.DriverSpecDefaults.ImageSet = &corev1.LocalObjectReference{Name: cmName}
353353
csiOperatorConfig.Spec.DriverSpecDefaults.ClusterName = ptr.To(string(clusterVersion.Spec.ClusterID))
354+
if c.AvailableCrds[volumeGroupSnapshotClassCrd] {
355+
csiOperatorConfig.Spec.DriverSpecDefaults.SnapshotPolicy = csiopv1a1.VolumeGroupSnapshotPolicy
356+
}
357+
354358
return nil
355359
}); err != nil {
356360
return fmt.Errorf("failed to reconcile csi operator config: %v", err)

internal/controller/storageclaim_controller.go

+121-7
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23+
"slices"
24+
"strings"
25+
2326
v1alpha1 "github.com/red-hat-storage/ocs-client-operator/api/v1alpha1"
2427
"github.com/red-hat-storage/ocs-client-operator/pkg/templates"
2528
"github.com/red-hat-storage/ocs-client-operator/pkg/utils"
26-
"slices"
27-
"strings"
2829

2930
csiopv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
3031
"github.com/go-logr/logr"
3132

3233
replicationv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/replication.storage/v1alpha1"
34+
groupsnapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1"
3335
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
3436
providerclient "github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client"
3537
corev1 "k8s.io/api/core/v1"
3638
storagev1 "k8s.io/api/storage/v1"
39+
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3740
"k8s.io/apimachinery/pkg/api/errors"
3841
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3942
"k8s.io/apimachinery/pkg/runtime"
@@ -42,6 +45,7 @@ import (
4245
"sigs.k8s.io/controller-runtime/pkg/cache"
4346
"sigs.k8s.io/controller-runtime/pkg/client"
4447
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
48+
"sigs.k8s.io/controller-runtime/pkg/handler"
4549
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
4650
"sigs.k8s.io/controller-runtime/pkg/predicate"
4751
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -52,8 +56,10 @@ const (
5256
storageClaimAnnotation = "ocs.openshift.io/storageclaim"
5357
keyRotationAnnotation = "keyrotation.csiaddons.openshift.io/schedule"
5458

55-
pvClusterIDIndexName = "index:persistentVolumeClusterID"
56-
vscClusterIDIndexName = "index:volumeSnapshotContentCSIDriver"
59+
pvClusterIDIndexName = "index:persistentVolumeClusterID"
60+
vscClusterIDIndexName = "index:volumeSnapshotContentCSIDriver"
61+
vgscClusterIDIndexName = "index:volumeGroupSnapshotContentCSIDriver"
62+
volumeGroupSnapshotClassCrd = "groupsnapshot.storage.k8s.io/volumegroupsnapshotclass"
5763
)
5864

5965
// StorageClaimReconciler reconciles a StorageClaim object
@@ -62,6 +68,7 @@ type StorageClaimReconciler struct {
6268
cache.Cache
6369
Scheme *runtime.Scheme
6470
OperatorNamespace string
71+
AvailableCrds map[string]bool
6572

6673
log logr.Logger
6774
ctx context.Context
@@ -104,13 +111,46 @@ func (r *StorageClaimReconciler) SetupWithManager(mgr ctrl.Manager) error {
104111
return fmt.Errorf("unable to set up FieldIndexer for VSC csi driver name: %v", err)
105112
}
106113

114+
if err := mgr.GetCache().IndexField(ctx, &groupsnapapi.VolumeGroupSnapshotContent{}, vgscClusterIDIndexName, func(o client.Object) []string {
115+
vgsc := o.(*groupsnapapi.VolumeGroupSnapshotContent)
116+
if vgsc != nil &&
117+
slices.Contains(csiDrivers, vgsc.Spec.Driver) &&
118+
vgsc.Status != nil &&
119+
vgsc.Status.VolumeGroupSnapshotHandle != nil {
120+
parts := strings.Split(*vgsc.Status.VolumeGroupSnapshotHandle, "-")
121+
if len(parts) == 9 {
122+
// second entry in the volumeID is clusterID which is unique across the cluster
123+
return []string{parts[2]}
124+
}
125+
}
126+
return nil
127+
}); err != nil {
128+
return fmt.Errorf("unable to set up FieldIndexer for VSC csi driver name: %v", err)
129+
}
130+
107131
generationChangePredicate := predicate.GenerationChangedPredicate{}
108132
bldr := ctrl.NewControllerManagedBy(mgr).
109133
For(&v1alpha1.StorageClaim{}, builder.WithPredicates(generationChangePredicate)).
110134
Owns(&storagev1.StorageClass{}).
111135
Owns(&snapapi.VolumeSnapshotClass{}).
112-
Owns(&replicationv1alpha1.VolumeReplicationClass{}, builder.WithPredicates(generationChangePredicate)).
113-
Owns(&csiopv1a1.ClientProfile{}, builder.WithPredicates(generationChangePredicate))
136+
Owns(&csiopv1a1.ClientProfile{}, builder.WithPredicates(generationChangePredicate)).
137+
Watches(
138+
&extv1.CustomResourceDefinition{},
139+
&handler.EnqueueRequestForObject{},
140+
builder.WithPredicates(
141+
utils.NamePredicate(volumeGroupSnapshotClassCrd),
142+
utils.EventTypePredicate(
143+
!r.AvailableCrds[volumeGroupSnapshotClassCrd],
144+
false,
145+
r.AvailableCrds[volumeGroupSnapshotClassCrd],
146+
false,
147+
),
148+
),
149+
builder.OnlyMetadata,
150+
)
151+
if r.AvailableCrds[volumeGroupSnapshotClassCrd] {
152+
bldr = bldr.Owns(&groupsnapapi.VolumeGroupSnapshotClass{})
153+
}
114154

115155
return bldr.Complete(r)
116156
}
@@ -121,8 +161,10 @@ func (r *StorageClaimReconciler) SetupWithManager(mgr ctrl.Manager) error {
121161
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;delete
122162
//+kubebuilder:rbac:groups=storage.k8s.io,resources=storageclasses,verbs=get;list;watch;create;update;patch;delete
123163
//+kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotclasses,verbs=get;list;watch;create;delete
164+
//+kubebuilder:rbac:groups=groupsnapshot.storage.k8s.io,resources=volumegroupsnapshotclasses,verbs=create;delete;get;list;watch
124165
//+kubebuilder:rbac:groups=core,resources=persistentvolumes,verbs=get;list;watch
125166
//+kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotcontents,verbs=get;list;watch
167+
//+kubebuilder:rbac:groups=groupsnapshot.storage.k8s.io,resources=volumegroupsnapshotcontents,verbs=get;list;watch
126168
//+kubebuilder:rbac:groups=csi.ceph.io,resources=clientprofiles,verbs=get;list;update;create;watch;delete
127169
//+kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumereplicationclasses,verbs=get;list;watch;create;delete
128170

@@ -141,6 +183,17 @@ func (r *StorageClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request
141183
r.ctx = ctrllog.IntoContext(ctx, r.log)
142184
r.log.Info("Reconciling StorageClaim.")
143185

186+
crd := &metav1.PartialObjectMetadata{}
187+
for _, crdName := range []string{volumeGroupSnapshotClassCrd} {
188+
crd.SetGroupVersionKind(extv1.SchemeGroupVersion.WithKind("CustomResourceDefinition"))
189+
crd.Name = crdName
190+
if err := r.Client.Get(ctx, client.ObjectKeyFromObject(crd), crd); client.IgnoreNotFound(err) != nil {
191+
r.log.Error(err, "Failed to get CRD", "CRD", crdName)
192+
return reconcile.Result{}, err
193+
}
194+
}
195+
utils.AssertEqual(r.AvailableCrds[crd.Name], crd.UID != "", utils.ExitCodeThatShouldRestartTheProcess)
196+
144197
// Fetch the StorageClaim instance
145198
r.storageClaim = &v1alpha1.StorageClaim{}
146199
r.storageClaim.Name = req.Name
@@ -401,7 +454,35 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) {
401454
return nil
402455
})
403456
if err != nil {
404-
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err)
457+
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err)
458+
}
459+
case "VolumeGroupSnapshotClass":
460+
// check for CRD availability
461+
if r.AvailableCrds[("VolumeGroupSnapshotClass")] {
462+
var volumeGroupSnapshotClass *groupsnapapi.VolumeGroupSnapshotClass
463+
data := map[string]string{}
464+
err = json.Unmarshal(resource.Data, &data)
465+
if err != nil {
466+
return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response: %v", err)
467+
}
468+
data["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = r.OperatorNamespace
469+
// generate a new clusterID for cephfs subvolumegroup, as
470+
// storageclaim is clusterscoped resources using its
471+
// hash as the clusterID
472+
data["clusterID"] = r.storageClaimHash
473+
driverName := templates.CephFsDriverName
474+
if strings.Contains(strings.ToLower(resource.Name), "rbd") {
475+
driverName = templates.RBDDriverName
476+
}
477+
volumeGroupSnapshotClass = r.getCephDriverVolumeGroupSnapshotClass(resource.Labels, resource.Annotations, driverName)
478+
utils.AddAnnotation(volumeGroupSnapshotClass, storageClaimAnnotation, r.storageClaim.Name)
479+
err = utils.CreateOrReplace(r.ctx, r.Client, volumeGroupSnapshotClass, func() error {
480+
volumeGroupSnapshotClass.Parameters = data
481+
return nil
482+
})
483+
if err != nil {
484+
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeGroupSnapshotClass: %s", err)
485+
}
405486
}
406487
case "VolumeReplicationClass":
407488
vrc := &replicationv1alpha1.VolumeReplicationClass{}
@@ -466,6 +547,11 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) {
466547
} else if exist {
467548
return reconcile.Result{}, fmt.Errorf("one or more volumesnapshotcontents exist that are dependent on storageclaim %s", r.storageClaim.Name)
468549
}
550+
if exist, err := r.hasVolumeGroupSnapshotContents(); err != nil {
551+
return reconcile.Result{}, fmt.Errorf("failed to verify volumegroupsnapshotcontents dependent on storageclaim %q: %v", r.storageClaim.Name, err)
552+
} else if exist {
553+
return reconcile.Result{}, fmt.Errorf("one or more volumegroupsnapshotcontents exist that are dependent on storageclaim %s", r.storageClaim.Name)
554+
}
469555

470556
// Call `RevokeStorageClaim` service on the provider server with StorageClaim as a request message.
471557
// Check if StorageClaim is still exists (it might have been manually removed during the StorageClass
@@ -550,6 +636,20 @@ func (r *StorageClaimReconciler) getCephRBDVolumeSnapshotClass() *snapapi.Volume
550636
return volumesnapshotclass
551637
}
552638

639+
func (r *StorageClaimReconciler) getCephDriverVolumeGroupSnapshotClass(
640+
labels map[string]string, annotations map[string]string, driver string) *groupsnapapi.VolumeGroupSnapshotClass {
641+
volumegroupsnapshotclass := &groupsnapapi.VolumeGroupSnapshotClass{
642+
ObjectMeta: metav1.ObjectMeta{
643+
Name: r.storageClaim.Name,
644+
Labels: labels,
645+
Annotations: annotations,
646+
},
647+
Driver: driver,
648+
DeletionPolicy: snapapi.VolumeSnapshotContentDelete,
649+
}
650+
return volumegroupsnapshotclass
651+
}
652+
553653
func (r *StorageClaimReconciler) get(obj client.Object) error {
554654
key := client.ObjectKeyFromObject(obj)
555655
return r.Client.Get(r.ctx, key, obj)
@@ -594,3 +694,17 @@ func (r *StorageClaimReconciler) hasVolumeSnapshotContents() (bool, error) {
594694

595695
return false, nil
596696
}
697+
698+
func (r *StorageClaimReconciler) hasVolumeGroupSnapshotContents() (bool, error) {
699+
vscList := &groupsnapapi.VolumeGroupSnapshotContentList{}
700+
if err := r.list(vscList, client.MatchingFields{vgscClusterIDIndexName: r.storageClaimHash}); err != nil {
701+
return false, fmt.Errorf("failed to list volume group snapshot content resources: %v", err)
702+
}
703+
704+
if len(vscList.Items) != 0 {
705+
r.log.Info(fmt.Sprintf("VolumeGroupSnapshotContent referring storageclaim %q exists", r.storageClaim.Name))
706+
return true, nil
707+
}
708+
709+
return false, nil
710+
}

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/doc.go

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)