@@ -320,7 +320,6 @@ func (gceCS *GCEControllerServer) createVolumeInternal(ctx context.Context, req
320
320
return nil , status .Errorf (codes .InvalidArgument , "CreateVolume Request Capacity is invalid: %v" , err .Error ())
321
321
}
322
322
323
- // Validate multiwriter
324
323
err = validateVolumeCapabilities (volumeCapabilities )
325
324
if err != nil {
326
325
return nil , status .Errorf (codes .InvalidArgument , "VolumeCapabilities is invalid: %v" , err .Error ())
@@ -364,6 +363,7 @@ func (gceCS *GCEControllerServer) createVolumeInternal(ctx context.Context, req
364
363
}
365
364
}
366
365
366
+ // Validate multiwriter
367
367
if _ , err := getMultiWriterFromCapabilities (volumeCapabilities ); err != nil {
368
368
return nil , status .Errorf (codes .InvalidArgument , "VolumeCapabilities is invalid: %v" , err .Error ())
369
369
}
@@ -774,7 +774,7 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
774
774
volumeID := req .GetVolumeId ()
775
775
klog .V (4 ).Infof ("Modifying Volume ID: %s" , volumeID )
776
776
777
- if volumeID == "" {
777
+ if len ( volumeID ) == 0 {
778
778
return nil , status .Error (codes .InvalidArgument , "volume ID must be provided" )
779
779
}
780
780
@@ -783,45 +783,51 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
783
783
enableStoragePools := metrics .DefaultEnableStoragePools
784
784
785
785
defer func () {
786
- gceCS .Metrics .RecordOperationErrorMetrics ("ModifyVolume " , err , diskType , enableConfidentialCompute , enableStoragePools )
786
+ gceCS .Metrics .RecordOperationErrorMetrics ("ControllerModifyVolume " , err , diskType , enableConfidentialCompute , enableStoragePools )
787
787
}()
788
788
789
789
project , volKey , err := common .VolumeIDToKey (volumeID )
790
-
791
790
if err != nil {
792
- return nil , status .Errorf (codes .InvalidArgument , "volume ID is invalid: %v" , err .Error ())
791
+ // Cannot find volume associated with this ID because VolumeID is not in the correct format
792
+ err = status .Errorf (codes .NotFound , "volume ID is invalid: %v" , err .Error ())
793
+ return nil , err
793
794
}
794
795
795
796
volumeModifyParams , err := common .ExtractModifyVolumeParameters (req .GetMutableParameters ())
796
797
if err != nil {
797
798
klog .Errorf ("Failed to extract parameters for volume %s: %v" , volumeID , err )
798
- return nil , status .Errorf (codes .InvalidArgument , "Invalid parameters: %v" , err )
799
+ err = status .Errorf (codes .InvalidArgument , "Invalid parameters: %v" , err )
800
+ return nil , err
799
801
}
800
802
klog .V (4 ).Infof ("Modify Volume Parameters for %s: %v" , volumeID , volumeModifyParams )
801
803
802
804
existingDisk , err := gceCS .CloudProvider .GetDisk (ctx , project , volKey , gce .GCEAPIVersionBeta )
803
805
804
806
if err != nil {
805
- return nil , fmt .Errorf ("Failed to get volume: %w" , err )
807
+ err = fmt .Errorf ("Failed to get volume: %w" , err )
808
+ return nil , err
806
809
}
807
810
808
811
if existingDisk == nil || existingDisk .GetSelfLink () == "" {
809
-
810
- return nil , status . Errorf ( codes . Internal , "failed to get volume : %s" , volumeID )
812
+ err = status . Errorf ( codes . Internal , "failed to get volume : %s" , volumeID )
813
+ return nil , err
811
814
}
812
815
diskType = existingDisk .GetPDType ()
813
816
814
817
// Check if the disk supports dynamic IOPS/Throughput provisioning
815
818
supportsIopsChange := gceCS .diskSupportsIopsChange (diskType )
816
819
supportsThroughputChange := gceCS .diskSupportsThroughputChange (diskType )
817
820
if ! supportsIopsChange && ! supportsThroughputChange {
818
- return nil , status .Errorf (codes .InvalidArgument , "Failed to modify volume: modifications not supported for disk type %s" , diskType )
821
+ err = status .Errorf (codes .InvalidArgument , "Failed to modify volume: modifications not supported for disk type %s" , diskType )
822
+ return nil , err
819
823
}
820
824
if ! supportsIopsChange && volumeModifyParams .IOPS != nil {
821
- return nil , status .Errorf (codes .InvalidArgument , "Cannot specify IOPS for disk type %s" , diskType )
825
+ err = status .Errorf (codes .InvalidArgument , "Cannot specify IOPS for disk type %s" , diskType )
826
+ return nil , err
822
827
}
823
828
if ! supportsThroughputChange && volumeModifyParams .Throughput != nil {
824
- return nil , status .Errorf (codes .InvalidArgument , "Cannot specify throughput for disk type %s" , diskType )
829
+ err = status .Errorf (codes .InvalidArgument , "Cannot specify throughput for disk type %s" , diskType )
830
+ return nil , err
825
831
}
826
832
827
833
if existingDisk .GetEnableStoragePools () {
@@ -833,7 +839,8 @@ func (gceCS *GCEControllerServer) ControllerModifyVolume(ctx context.Context, re
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