Skip to content

Commit 799ca64

Browse files
committed
ensure mutable params are not applied to pd- disk types
1 parent 38715f3 commit 799ca64

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/gce-pd-csi-driver/controller.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,16 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
321321
// https://github.com/container-storage-interface/spec/blob/master/spec.md#createvolume
322322
// mutable_parameters MUST take precedence over the values from parameters.
323323
mutableParams := req.GetMutableParameters()
324-
if mutableParams != nil {
324+
// If the disk type is pd-*, the IOPS and Throughput parameters are ignored.
325+
if mutableParams != nil && !strings.HasPrefix(params.DiskType, "pd") {
325326
p, err := common.ExtractModifyVolumeParameters(mutableParams)
326327
if err != nil {
327328
return nil, status.Errorf(codes.InvalidArgument, "Invalid mutable parameters: %v", err)
328329
}
329330
params.ProvisionedIOPSOnCreate = p.IOPS
330331
params.ProvisionedThroughputOnCreate = p.Throughput
332+
} else {
333+
klog.V(4).Infof("Ignoring IOPS and throughput parameters for unsupported disk type %s", params.DiskType)
331334
}
332335

333336
// Determine multiWriter
@@ -550,12 +553,12 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
550553
return nil, status.Error(codes.InvalidArgument, "volume ID must be provided")
551554
}
552555

553-
diskTypeForMetric := metrics.DefaultDiskTypeForMetric
556+
diskType := metrics.DefaultDiskTypeForMetric
554557
enableConfidentialCompute := metrics.DefaultEnableConfidentialCompute
555558
enableStoragePools := metrics.DefaultEnableStoragePools
556559

557560
defer func() {
558-
gceCS.Metrics.RecordOperationErrorMetrics("ModifyVolume", err, diskTypeForMetric, enableConfidentialCompute, enableStoragePools)
561+
gceCS.Metrics.RecordOperationErrorMetrics("ModifyVolume", err, diskType, enableConfidentialCompute, enableStoragePools)
559562
}()
560563

561564
project, volKey, err := common.VolumeIDToKey(volumeID)
@@ -581,7 +584,8 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
581584

582585
return nil, status.Errorf(codes.Internal, "failed to get volume : %s", volumeID)
583586
}
584-
diskTypeForMetric = existingDisk.GetPDType()
587+
diskType = existingDisk.GetPDType()
588+
// TODO : not sure how this metric should be reported
585589
if existingDisk.GetEnableStoragePools() {
586590
enableStoragePools = "enabled"
587591
} else {

0 commit comments

Comments
 (0)