@@ -324,7 +324,6 @@ func (gceCS *GCEControllerServer) createVolumeInternal(ctx context.Context, req
324
324
return nil , status .Errorf (codes .InvalidArgument , "CreateVolume Request Capacity is invalid: %v" , err .Error ())
325
325
}
326
326
327
- // Validate multiwriter
328
327
err = validateVolumeCapabilities (volumeCapabilities )
329
328
if err != nil {
330
329
return nil , status .Errorf (codes .InvalidArgument , "VolumeCapabilities is invalid: %v" , err .Error ())
@@ -368,6 +367,7 @@ func (gceCS *GCEControllerServer) createVolumeInternal(ctx context.Context, req
368
367
}
369
368
}
370
369
370
+ // Validate multiwriter
371
371
if _ , err := getMultiWriterFromCapabilities (volumeCapabilities ); err != nil {
372
372
return nil , status .Errorf (codes .InvalidArgument , "VolumeCapabilities is invalid: %v" , err .Error ())
373
373
}
@@ -778,7 +778,7 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
778
778
volumeID := req .GetVolumeId ()
779
779
klog .V (4 ).Infof ("Modifying Volume ID: %s" , volumeID )
780
780
781
- if volumeID == "" {
781
+ if len ( volumeID ) == 0 {
782
782
return nil , status .Error (codes .InvalidArgument , "volume ID must be provided" )
783
783
}
784
784
@@ -787,53 +787,60 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
787
787
enableStoragePools := metrics .DefaultEnableStoragePools
788
788
789
789
defer func () {
790
- gceCS .Metrics .RecordOperationErrorMetrics ("ModifyVolume " , err , diskType , enableConfidentialCompute , enableStoragePools )
790
+ gceCS .Metrics .RecordOperationErrorMetrics ("ControllerModifyVolume " , err , diskType , enableConfidentialCompute , enableStoragePools )
791
791
}()
792
792
793
793
project , volKey , err := common .VolumeIDToKey (volumeID )
794
-
795
794
if err != nil {
796
- return nil , status .Errorf (codes .InvalidArgument , "volume ID is invalid: %v" , err .Error ())
795
+ // Cannot find volume associated with this ID because VolumeID is not in the correct format
796
+ err = status .Errorf (codes .NotFound , "volume ID is invalid: %v" , err .Error ())
797
+ return nil , err
797
798
}
798
799
799
800
volumeModifyParams , err := common .ExtractModifyVolumeParameters (req .GetMutableParameters ())
800
801
if err != nil {
801
802
klog .Errorf ("Failed to extract parameters for volume %s: %v" , volumeID , err )
802
- return nil , status .Errorf (codes .InvalidArgument , "Invalid parameters: %v" , err )
803
+ err = status .Errorf (codes .InvalidArgument , "Invalid parameters: %v" , err )
804
+ return nil , err
803
805
}
804
806
klog .V (4 ).Infof ("Modify Volume Parameters for %s: %v" , volumeID , volumeModifyParams )
805
807
806
808
existingDisk , err := gceCS .CloudProvider .GetDisk (ctx , project , volKey , gce .GCEAPIVersionBeta )
807
809
808
810
if err != nil {
809
- return nil , fmt .Errorf ("Failed to get volume: %w" , err )
811
+ err = fmt .Errorf ("Failed to get volume: %w" , err )
812
+ return nil , err
810
813
}
811
814
812
815
if existingDisk == nil || existingDisk .GetSelfLink () == "" {
813
-
814
- return nil , status . Errorf ( codes . Internal , "failed to get volume : %s" , volumeID )
816
+ err = status . Errorf ( codes . Internal , "failed to get volume : %s" , volumeID )
817
+ return nil , err
815
818
}
816
819
diskType = existingDisk .GetPDType ()
817
820
818
821
// Check if the disk supports dynamic IOPS/Throughput provisioning
819
822
supportsIopsChange := gceCS .diskSupportsIopsChange (diskType )
820
823
supportsThroughputChange := gceCS .diskSupportsThroughputChange (diskType )
821
824
if ! supportsIopsChange && ! supportsThroughputChange {
822
- return nil , status .Errorf (codes .InvalidArgument , "Failed to modify volume: modifications not supported for disk type %s" , diskType )
825
+ err = status .Errorf (codes .InvalidArgument , "Failed to modify volume: modifications not supported for disk type %s" , diskType )
826
+ return nil , err
823
827
}
824
828
if ! supportsIopsChange && volumeModifyParams .IOPS != nil {
825
- return nil , status .Errorf (codes .InvalidArgument , "Cannot specify IOPS for disk type %s" , diskType )
829
+ err = status .Errorf (codes .InvalidArgument , "Cannot specify IOPS for disk type %s" , diskType )
830
+ return nil , err
826
831
}
827
832
if ! supportsThroughputChange && volumeModifyParams .Throughput != nil {
828
- return nil , status .Errorf (codes .InvalidArgument , "Cannot specify throughput for disk type %s" , diskType )
833
+ err = status .Errorf (codes .InvalidArgument , "Cannot specify throughput for disk type %s" , diskType )
834
+ return nil , err
829
835
}
830
836
831
837
enableStoragePools = strconv .FormatBool (existingDisk .GetEnableStoragePools ())
832
838
833
839
err = gceCS .CloudProvider .UpdateDisk (ctx , project , volKey , existingDisk , volumeModifyParams )
834
840
if err != nil {
835
841
klog .Errorf ("Failed to modify volume %s: %v" , volumeID , err )
836
- return nil , fmt .Errorf ("Failed to modify volume %s: %w" , volumeID , err )
842
+ err = fmt .Errorf ("Failed to modify volume %s: %w" , volumeID , err )
843
+ return nil , err
837
844
}
838
845
839
846
return & csi.ControllerModifyVolumeResponse {}, nil
0 commit comments