@@ -224,14 +224,14 @@ func (gceCS *GCEControllerServer) DeleteVolume(ctx context.Context, req *csi.Del
224
224
225
225
volKey , err := common .VolumeIDToKey (volumeID )
226
226
if err != nil {
227
- // Cannot find volume associated with this ID because can't even get the name or zone
228
- // This is a success according to the spec
227
+ klog .Warningf ("Treating volume as deleted because volume id %s is invalid: %v" , volumeID , err )
229
228
return & csi.DeleteVolumeResponse {}, nil
230
229
}
231
230
232
231
volKey , err = gceCS .CloudProvider .RepairUnderspecifiedVolumeKey (ctx , volKey )
233
232
if err != nil {
234
- return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find volume with ID %v: %v" , volumeID , err ))
233
+ klog .Warningf ("Treating volume as deleted because cannot find volume %v: %v" , volKey .String (), err )
234
+ return & csi.DeleteVolumeResponse {}, nil
235
235
}
236
236
237
237
if acquired := gceCS .volumeLocks .TryAcquire (volumeID ); ! acquired {
@@ -267,7 +267,7 @@ func (gceCS *GCEControllerServer) ControllerPublishVolume(ctx context.Context, r
267
267
268
268
volKey , err := common .VolumeIDToKey (volumeID )
269
269
if err != nil {
270
- return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find volume with ID %v : %v" , volumeID , err ))
270
+ return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("ControllerPublishVolume volume ID is invalid : %v" , err ))
271
271
}
272
272
273
273
volKey , err = gceCS .CloudProvider .RepairUnderspecifiedVolumeKey (ctx , volKey )
@@ -294,7 +294,7 @@ func (gceCS *GCEControllerServer) ControllerPublishVolume(ctx context.Context, r
294
294
295
295
_ , err = gceCS .CloudProvider .GetDisk (ctx , volKey )
296
296
if err != nil {
297
- if gce .IsGCEError (err , "notFound" ) {
297
+ if gce .IsGCENotFoundError (err ) {
298
298
return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find disk %v: %v" , volKey .String (), err ))
299
299
}
300
300
return nil , status .Error (codes .Internal , fmt .Sprintf ("Unknown get disk error: %v" , err ))
@@ -305,7 +305,7 @@ func (gceCS *GCEControllerServer) ControllerPublishVolume(ctx context.Context, r
305
305
}
306
306
instance , err := gceCS .CloudProvider .GetInstanceOrError (ctx , instanceZone , instanceName )
307
307
if err != nil {
308
- if gce .IsGCEError (err , "notFound" ) {
308
+ if gce .IsGCENotFoundError (err ) {
309
309
return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find instance %v: %v" , nodeID , err ))
310
310
}
311
311
return nil , status .Error (codes .Internal , fmt .Sprintf ("Unknown get instance error: %v" , err ))
@@ -365,7 +365,7 @@ func (gceCS *GCEControllerServer) ControllerUnpublishVolume(ctx context.Context,
365
365
366
366
volKey , err := common .VolumeIDToKey (volumeID )
367
367
if err != nil {
368
- return nil , err
368
+ return nil , status . Error ( codes . InvalidArgument , fmt . Sprintf ( "ControllerUnpublishVolume Volume ID is invalid: %v" , err ))
369
369
}
370
370
371
371
// Acquires the lock for the volume on that node only, because we need to support the ability
@@ -382,7 +382,12 @@ func (gceCS *GCEControllerServer) ControllerUnpublishVolume(ctx context.Context,
382
382
}
383
383
instance , err := gceCS .CloudProvider .GetInstanceOrError (ctx , instanceZone , instanceName )
384
384
if err != nil {
385
- return nil , err
385
+ if gce .IsGCENotFoundError (err ) {
386
+ // Node not existing on GCE means that disk has been detached
387
+ klog .Warningf ("Treating volume %v as unpublished because node %v could not be found" , volKey .String (), instanceName )
388
+ return & csi.ControllerUnpublishVolumeResponse {}, nil
389
+ }
390
+ return nil , status .Error (codes .Internal , fmt .Sprintf ("error getting instance: %v" , err ))
386
391
}
387
392
388
393
deviceName , err := common .GetDeviceName (volKey )
@@ -420,7 +425,7 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
420
425
}
421
426
volKey , err := common .VolumeIDToKey (volumeID )
422
427
if err != nil {
423
- return nil , status .Error (codes .NotFound , fmt .Sprintf ("Volume ID is of improper format, got %v" , volumeID ))
428
+ return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("ValidateVolumeCapabilities Volume ID is invalid: %v" , err ))
424
429
}
425
430
426
431
if acquired := gceCS .volumeLocks .TryAcquire (volumeID ); ! acquired {
@@ -430,7 +435,7 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
430
435
431
436
_ , err = gceCS .CloudProvider .GetDisk (ctx , volKey )
432
437
if err != nil {
433
- if gce .IsGCEError (err , "notFound" ) {
438
+ if gce .IsGCENotFoundError (err ) {
434
439
return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find disk %v: %v" , volKey .Name , err ))
435
440
}
436
441
return nil , status .Error (codes .Internal , fmt .Sprintf ("Unknown get disk error: %v" , err ))
@@ -532,7 +537,7 @@ func (gceCS *GCEControllerServer) CreateSnapshot(ctx context.Context, req *csi.C
532
537
}
533
538
volKey , err := common .VolumeIDToKey (volumeID )
534
539
if err != nil {
535
- return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find volume with ID %v : %v" , volumeID , err ))
540
+ return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("CreateSnapshot Volume ID is invalid : %v" , err ))
536
541
}
537
542
538
543
if acquired := gceCS .volumeLocks .TryAcquire (volumeID ); ! acquired {
@@ -670,7 +675,7 @@ func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, re
670
675
671
676
volKey , err := common .VolumeIDToKey (volumeID )
672
677
if err != nil {
673
- return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("ControllerExpandVolume volume ID is invalid: %v" , err ))
678
+ return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("ControllerExpandVolume Volume ID is invalid: %v" , err ))
674
679
}
675
680
676
681
resizedGb , err := gceCS .CloudProvider .ResizeDisk (ctx , volKey , reqBytes )
0 commit comments