@@ -20,19 +20,17 @@ import (
2020 "context"
2121 "flag"
2222 "fmt"
23- "github.com/kubernetes-csi/external-snapshotter/v6/pkg/group_snapshotter"
2423 "net/http"
2524 "os"
2625 "os/signal"
2726 "strings"
2827 "time"
2928
30- utils "github.com/kubernetes-csi/external-snapshotter/v6/pkg/utils"
31-
3229 "google.golang.org/grpc"
3330
3431 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3532 "k8s.io/apimachinery/pkg/labels"
33+ coreinformers "k8s.io/client-go/informers"
3634 "k8s.io/client-go/kubernetes"
3735 "k8s.io/client-go/kubernetes/scheme"
3836 "k8s.io/client-go/rest"
@@ -51,7 +49,8 @@ import (
5149 clientset "github.com/kubernetes-csi/external-snapshotter/client/v6/clientset/versioned"
5250 snapshotscheme "github.com/kubernetes-csi/external-snapshotter/client/v6/clientset/versioned/scheme"
5351 informers "github.com/kubernetes-csi/external-snapshotter/client/v6/informers/externalversions"
54- coreinformers "k8s.io/client-go/informers"
52+ "github.com/kubernetes-csi/external-snapshotter/v6/pkg/group_snapshotter"
53+ utils "github.com/kubernetes-csi/external-snapshotter/v6/pkg/utils"
5554)
5655
5756const (
@@ -229,6 +228,12 @@ func main() {
229228 snapShotter := snapshotter .NewSnapshotter (csiConn )
230229 var groupSnapshotter group_snapshotter.GroupSnapshotter
231230 if * enableVolumeGroupSnapshots {
231+ supportsCreateVolumeGroupSnapshot , err := supportsGroupControllerCreateVolumeGroupSnapshot (ctx , csiConn )
232+ if err != nil {
233+ klog .Errorf ("error determining if driver supports create/delete group snapshot operations: %v" , err )
234+ } else if ! supportsCreateVolumeGroupSnapshot {
235+ klog .Warningf ("CSI driver %s does not support GroupControllerCreateVolumeGroupSnapshot when the --enable-volume-group-snapshots flag is true" , driverName )
236+ }
232237 groupSnapshotter = group_snapshotter .NewGroupSnapshotter (csiConn )
233238 if len (* groupSnapshotNamePrefix ) == 0 {
234239 klog .Error ("group snapshot name prefix cannot be of length 0" )
@@ -317,3 +322,12 @@ func supportsControllerCreateSnapshot(ctx context.Context, conn *grpc.ClientConn
317322
318323 return capabilities [csi .ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT ], nil
319324}
325+
326+ func supportsGroupControllerCreateVolumeGroupSnapshot (ctx context.Context , conn * grpc.ClientConn ) (bool , error ) {
327+ capabilities , err := csirpc .GetGroupControllerCapabilities (ctx , conn )
328+ if err != nil {
329+ return false , err
330+ }
331+
332+ return capabilities [csi .GroupControllerServiceCapability_RPC_CREATE_DELETE_GET_VOLUME_GROUP_SNAPSHOT ], nil
333+ }
0 commit comments