Skip to content

Commit

Permalink
Add disableVolumeMetrics flag for CSI Driver
Browse files Browse the repository at this point in the history
If customer does not use Prometheus metrics of the volume, let
them disable it. The metrics execute statVolume and that is bit
expensive and causes load on Quobyte registry (client cache
can be configured to cache response via TTL to reduce the affect).

At the moment, there are efforts on registry side to improve
the statVolume call path, but if customer does not use the metric,
probing the stats is not useful.
  • Loading branch information
venkatsc committed Jul 12, 2024
1 parent 03de02f commit 80f6d6c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- "--quobyte_version={{ .Values.quobyte.version }}"
- "--immediate_erase={{ .Values.quobyte.immediateErase }}"
- "--use_k8s_namespace_as_tenant={{ .Values.quobyte.useK8SNamespaceAsTenant }}"
- "--disable_volume_metrics={{ .Values.quobyte.disableVolumeMetrics }}"
- "--role=node_driver"
env:
- name: NODE_ID
Expand Down
4 changes: 4 additions & 0 deletions csi-driver-templates/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ quobyte:
# Name or UUID of the shared volume (UUIDs are preferred to avoid name collisions)
sharedVolumesList: ""

# Set to 'true' if PVC/volume metrics (used/available/total bytes and inodes)
# are not required to be exported as Prometheus metrics.
disableVolumeMetrics: false

podKiller:
# To disable pod killer, uninstall current CSI driver (helm uninstall <chart-name>)
# set enable: false and install CSI driver again
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
driverVersion = flag.String("driver_version", "", "Quobyte CSI driver version")
useNameSpaceAsTenant = flag.Bool("use_k8s_namespace_as_tenant", false, "Uses k8s PVC.namespace as Quobyte tenant")
enableQuobyteAccessKeyMounts = flag.Bool("enable_access_key_mounts", false, "Enables use of Quobyte Access keys for mounting volumes")
disableVolumeMetrics = flag.Bool("disable_volume_metrics", false, "Disables volume metrics (space and inodes) export")
immediateErase = flag.Bool("immediate_erase", false, "Schedules erase volume task immediately (supported from Quobyte 3.x)")
quobyteVersion = flag.Int("quobyte_version", 2, "Specify Quobyte major version (2 for Quobyte 2.x and 3 for Quobyte 3.x)")
sharedVolumes = flag.String("shared_volumes_list", "", "Comma separated list of shared volumes (applicable only for Quobyte 2.x)")
Expand Down Expand Up @@ -93,7 +94,8 @@ func main() {
*useNameSpaceAsTenant,
*enableQuobyteAccessKeyMounts,
*immediateErase,
*quobyteVersion)
*quobyteVersion,
*disableVolumeMetrics)
err = qd.Run()
if err != nil {
klog.Errorf("Failed to start Quobyte CSI grpc server due to error: %v.", err)
Expand Down
15 changes: 10 additions & 5 deletions src/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type QuobyteDriver struct {
IsQuobyteAccessKeyMountsEnabled bool
ImmediateErase bool
QuobyteVersion int
disabledVolumeMetrics bool
quoybteClientFactory QuobyteApiClientProvider
mounter Mounter
}
Expand All @@ -42,7 +43,8 @@ func NewQuobyteDriver(
useNamespaceAsQuobyteTenant,
enableQuobyteAccessKeyMounts bool,
immediateErase bool,
quobyteVersion int) *QuobyteDriver {
quobyteVersion int,
disableVolumeMetrics bool) *QuobyteDriver {
return &QuobyteDriver{
driverName,
driverVersion,
Expand All @@ -55,6 +57,7 @@ func NewQuobyteDriver(
enableQuobyteAccessKeyMounts,
immediateErase,
quobyteVersion,
disableVolumeMetrics,
&QuobyteApiClientFactory{},
&LinuxMounter{},
}
Expand Down Expand Up @@ -103,11 +106,13 @@ func (d *QuobyteDriver) Run() error {
}
return resp, err
}
klog.Infof("Starting Quobyte-CSI Driver - driver: '%s' version: '%s'"+
"GRPC socket: '%s' mount point: '%s' API URL: '%s' "+
" MapNamespaceNameToQuobyteTenant: %t QuobyteAccesskeysEnabled: %t",
klog.Infof("Starting Quobyte-CSI Driver - driver: '%s' version: '%s'" +
"GRPC socket: '%s' mount point: '%s' API URL: '%s' " +
" MapNamespaceNameToQuobyteTenant: %t QuobyteAccesskeysEnabled: %t" +
" VolumeMetricsDisabled: %t",
d.Name, d.Version, d.endpoint, d.clientMountPoint, d.ApiURL,
d.UseK8SNamespaceAsQuobyteTenant, d.IsQuobyteAccessKeyMountsEnabled)
d.UseK8SNamespaceAsQuobyteTenant, d.IsQuobyteAccessKeyMountsEnabled,
d.disabledVolumeMetrics)
d.server = grpc.NewServer(grpc.UnaryInterceptor(errHandler))
csi.RegisterNodeServer(d.server, d)
csi.RegisterControllerServer(d.server, d)
Expand Down
3 changes: 3 additions & 0 deletions src/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func (d *QuobyteDriver) NodeExpandVolume(ctx context.Context, req *csi.NodeExpan
}

func (d *QuobyteDriver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
if d.disabledVolumeMetrics {
return nil, fmt.Errorf("volume/PVC metrics export is disabled for the Quobyte CSI Driver %s", d.Name);
}
volumePath := req.GetVolumePath()
if len(volumePath) <= 0 {
return nil, fmt.Errorf("volume path must not be empty")
Expand Down
16 changes: 12 additions & 4 deletions src/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,24 @@ func TestNodeUnpublishVolume(t *testing.T) {
d.mounter = mounter
req = &csi.NodeUnpublishVolumeRequest{}
req.TargetPath = unmountPath
got, err = d.NodeUnpublishVolume(context.TODO(), req)
got, _ = d.NodeUnpublishVolume(context.TODO(), req)
wanted := &csi.NodeUnpublishVolumeResponse {}
assert.Equal(wanted, got);
}

func TestNodeGetVolumeStats(t *testing.T) {
driverName := "my.quobyte.csi.provisioner"
d := &QuobyteDriver{}
req := &csi.NodeGetVolumeStatsRequest{}
got, err := d.NodeGetVolumeStats(context.TODO(), req)
d.Name = driverName
d.disabledVolumeMetrics = true
got, err := d.NodeGetVolumeStats(context.TODO(), &csi.NodeGetVolumeStatsRequest{})
assert := assert.New(t)
assert.Nil(got);
assert.NotNil(err);
assert.Contains(err.Error(), "disabled for the Quobyte CSI Driver " + driverName)
d = &QuobyteDriver{}
req := &csi.NodeGetVolumeStatsRequest{}
got, err = d.NodeGetVolumeStats(context.TODO(), req)
assert.Nil(got)
assert.NotNil(err)
assert.True(strings.Contains(err.Error(), "volume path must not be empty"))
Expand All @@ -139,7 +147,7 @@ func TestNodeGetVolumeStats(t *testing.T) {
d.mounter = mounter
req = &csi.NodeGetVolumeStatsRequest{}
req.VolumePath = mountedPath
got, err = d.NodeGetVolumeStats(context.TODO(), req)
got, _ = d.NodeGetVolumeStats(context.TODO(), req)
wanted := &csi.NodeGetVolumeStatsResponse {
Usage: []*csi.VolumeUsage {
{
Expand Down

0 comments on commit 80f6d6c

Please sign in to comment.