@@ -207,35 +207,40 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
207
207
208
208
if content .GetVolume () != nil {
209
209
volumeContentSourceVolumeID = content .GetVolume ().GetVolumeId ()
210
-
211
210
// Verify that the source VolumeID is in the correct format.
212
- project , volKey , err := common .VolumeIDToKey (volumeContentSourceVolumeID )
211
+ _ , _ , err := common .VolumeIDToKey (volumeContentSourceVolumeID )
213
212
if err != nil {
214
213
return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("CreateVolume source volume ID is invalid: %v" , err ))
215
214
}
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
- }
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 )
224
218
}
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
+ // }
225
230
// 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 )
228
- }
229
- // Verify the source disk is ready.
230
- if err == nil {
231
- ready , err := isDiskReady (diskFromSourceVolume )
232
- if err != nil {
233
- return nil , status .Error (codes .Internal , fmt .Sprintf ("CreateVolume disk from source volume %v had error checking ready status: %v" , volKey , err ))
234
- }
235
- if ! ready {
236
- return nil , status .Error (codes .Internal , fmt .Sprintf ("CreateVolume disk from source volume %v is not ready" , volKey ))
237
- }
238
- }
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
+ // // Verify the source disk is ready.
235
+ // if err == nil {
236
+ // ready, err := isDiskReady(diskFromSourceVolume)
237
+ // if err != nil {
238
+ // return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v had error checking ready status: %v", volKey, err))
239
+ // }
240
+ // if !ready {
241
+ // return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v is not ready", volKey))
242
+ // }
243
+ // }
239
244
}
240
245
}
241
246
// Create the disk
0 commit comments