@@ -208,29 +208,24 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
208
208
if content .GetVolume () != nil {
209
209
volumeContentSourceVolumeID = content .GetVolume ().GetVolumeId ()
210
210
// Verify that the source VolumeID is in the correct format.
211
- _ , _ , err := common .VolumeIDToKey (volumeContentSourceVolumeID )
211
+ project , volKey , err := common .VolumeIDToKey (volumeContentSourceVolumeID )
212
212
if err != nil {
213
213
return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("CreateVolume source volume ID is invalid: %v" , err ))
214
214
}
215
- // Verify the volume in VolumeContentSource exists.
216
- if acquired := gceCS .volumeLocks .TryAcquire (volumeContentSourceVolumeID ); acquired {
217
- return nil , status .Errorf (codes .NotFound , "CreateVolume source volume %s does not exist" , volumeContentSourceVolumeID )
215
+
216
+ // Verify that the volume in VolumeContentSource exists.
217
+ diskFromSourceVolume , err := gceCS .CloudProvider .GetDisk (ctx , project , volKey , gceAPIVersion )
218
+ if err != nil {
219
+ if gce .IsGCEError (err , "notFound" ) {
220
+ return nil , status .Errorf (codes .NotFound , "CreateVolume source volume %s does not exist" , volumeContentSourceVolumeID )
221
+ } else {
222
+ return nil , status .Error (codes .Internal , fmt .Sprintf ("CreateVolume unknown get disk error when validating: %v" , err ))
223
+ }
224
+ }
225
+ // Verify the zone, region, and disk type of the clone must be the same as that of the source disk.
226
+ if err := gce .ValidateDiskParameters (diskFromSourceVolume , params ); err != nil {
227
+ return nil , status .Errorf (codes .InvalidArgument , `CreateVolume source volume parameters do not match CreateVolumeRequest Parameters: %v` , err )
218
228
}
219
- defer gceCS .volumeLocks .Release (volumeContentSourceVolumeID )
220
-
221
- // // Verify that the volume in VolumeContentSource exists.
222
- // diskFromSourceVolume, err := gceCS.CloudProvider.GetDisk(ctx, project, volKey, gceAPIVersion)
223
- // if err != nil {
224
- // if gce.IsGCEError(err, "notFound") {
225
- // return nil, status.Errorf(codes.NotFound, "CreateVolume source volume %s does not exist", volumeContentSourceVolumeID)
226
- // } else {
227
- // return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume unknown get disk error when validating: %v", err))
228
- // }
229
- // }
230
- // Verify the zone, region, and disk type of the clone must be the same as that of the source disk.
231
- // if err := gce.ValidateDiskParameters(diskFromSourceVolume, params); err != nil {
232
- // return nil, status.Errorf(codes.InvalidArgument, `CreateVolume source volume parameters do not match CreateVolumeRequest Parameters: %v`, err)
233
- // }
234
229
// // Verify the source disk is ready.
235
230
// if err == nil {
236
231
// ready, err := isDiskReady(diskFromSourceVolume)
@@ -276,7 +271,6 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
276
271
277
272
klog .V (4 ).Infof ("CreateVolume succeeded for disk %v" , volKey )
278
273
return generateCreateVolumeResponse (disk , zones ), nil
279
-
280
274
}
281
275
282
276
func (gceCS * GCEControllerServer ) DeleteVolume (ctx context.Context , req * csi.DeleteVolumeRequest ) (* csi.DeleteVolumeResponse , error ) {
0 commit comments