@@ -39,17 +39,19 @@ type Driver struct {
3939 mounter * mount.SafeFormatAndMount
4040 // A map storing all volumes with ongoing operations so that additional operations
4141 // for that same volume (as defined by VolumeID) return an Aborted error
42- volumeLocks * volumeLocks
43- workingMountDir string
42+ volumeLocks * volumeLocks
43+ workingMountDir string
44+ enableGetVolumeStats bool
4445}
4546
4647// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
4748// does not support optional driver plugin info manifest field. Refer to CSI spec for more details.
48- func NewDriver (nodeID , driverName string ) * Driver {
49+ func NewDriver (nodeID , driverName string , enableGetVolumeStats bool ) * Driver {
4950 driver := Driver {}
5051 driver .Name = driverName
5152 driver .Version = driverVersion
5253 driver .NodeID = nodeID
54+ driver .enableGetVolumeStats = enableGetVolumeStats
5355 driver .volumeLocks = newVolumeLocks ()
5456 return & driver
5557}
@@ -84,12 +86,15 @@ func (d *Driver) Run(endpoint, kubeconfig string, testMode bool) {
8486 csi .VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER ,
8587 })
8688
87- d .AddNodeServiceCapabilities ([]csi.NodeServiceCapability_RPC_Type {
88- csi .NodeServiceCapability_RPC_GET_VOLUME_STATS ,
89+ nodeCap := []csi.NodeServiceCapability_RPC_Type {
8990 csi .NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME ,
9091 csi .NodeServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER ,
9192 csi .NodeServiceCapability_RPC_VOLUME_MOUNT_GROUP ,
92- })
93+ }
94+ if d .enableGetVolumeStats {
95+ nodeCap = append (nodeCap , csi .NodeServiceCapability_RPC_GET_VOLUME_STATS )
96+ }
97+ d .AddNodeServiceCapabilities (nodeCap )
9398
9499 s := csicommon .NewNonBlockingGRPCServer ()
95100 // Driver d act as IdentityServer, ControllerServer and NodeServer
0 commit comments