@@ -207,7 +207,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
207
207
208
208
volumeID , err := common .KeyToVolumeID (volKey , gceCS .CloudProvider .GetDefaultProject ())
209
209
if err != nil {
210
- return nil , status . Errorf ( codes . Internal , "Failed to convert volume key to volume ID: %v " , err )
210
+ return nil , LoggedError ( "Failed to convert volume key to volume ID: " , err )
211
211
}
212
212
if acquired := gceCS .volumeLocks .TryAcquire (volumeID ); ! acquired {
213
213
return nil , status .Errorf (codes .Aborted , common .VolumeOperationAlreadyExistsFmt , volumeID )
@@ -218,7 +218,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
218
218
existingDisk , err := gceCS .CloudProvider .GetDisk (ctx , gceCS .CloudProvider .GetDefaultProject (), volKey , gceAPIVersion )
219
219
if err != nil {
220
220
if ! gce .IsGCEError (err , "notFound" ) {
221
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateVolume unknown get disk error when validating: %v " , err ) )
221
+ return nil , LoggedError ( "CreateVolume unknown get disk error when validating: " , err )
222
222
}
223
223
}
224
224
if err == nil {
@@ -233,7 +233,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
233
233
234
234
ready , err := isDiskReady (existingDisk )
235
235
if err != nil {
236
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateVolume disk %v had error checking ready status: %v " , volKey , err ) )
236
+ return nil , LoggedError ( "CreateVolume disk " + volKey . String () + " had error checking ready status: " , err )
237
237
}
238
238
if ! ready {
239
239
return nil , status .Error (codes .Internal , fmt .Sprintf ("CreateVolume existing disk %v is not ready" , volKey ))
@@ -254,7 +254,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
254
254
// Verify that snapshot exists
255
255
sl , err := gceCS .getSnapshotByID (ctx , snapshotID )
256
256
if err != nil {
257
- return nil , status . Errorf ( codes . Internal , "CreateVolume failed to get snapshot %s: %v" , snapshotID , err )
257
+ return nil , LoggedError ( "CreateVolume failed to get snapshot " + snapshotID + ": " , err )
258
258
} else if len (sl .Entries ) == 0 {
259
259
return nil , status .Errorf (codes .NotFound , "CreateVolume source snapshot %s does not exist" , snapshotID )
260
260
}
@@ -274,7 +274,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
274
274
if gce .IsGCEError (err , "notFound" ) {
275
275
return nil , status .Errorf (codes .NotFound , "CreateVolume source volume %s does not exist" , volumeContentSourceVolumeID )
276
276
} else {
277
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateVolume unknown get disk error when validating: %v " , err ) )
277
+ return nil , LoggedError ( "CreateVolume unknown get disk error when validating: " , err )
278
278
}
279
279
}
280
280
@@ -312,7 +312,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
312
312
// Verify the source disk is ready.
313
313
ready , err := isDiskReady (diskFromSourceVolume )
314
314
if err != nil {
315
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateVolume disk from source volume %v had error checking ready status: %v " , sourceVolKey , err ) )
315
+ return nil , LoggedError ( "CreateVolume disk from source volume " + sourceVolKey . String () + " had error checking ready status: " , err )
316
316
}
317
317
if ! ready {
318
318
return nil , status .Error (codes .Internal , fmt .Sprintf ("CreateVolume disk from source volume %v is not ready" , sourceVolKey ))
@@ -333,15 +333,15 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
333
333
}
334
334
disk , err = createSingleZoneDisk (ctx , gceCS .CloudProvider , name , zones , params , capacityRange , capBytes , snapshotID , volumeContentSourceVolumeID , multiWriter )
335
335
if err != nil {
336
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateVolume failed to create single zonal disk %#v: %v " , name , err ) )
336
+ return nil , LoggedError ( "CreateVolume failed to create single zonal disk " + name + ": " , err )
337
337
}
338
338
case replicationTypeRegionalPD :
339
339
if len (zones ) != 2 {
340
340
return nil , status .Errorf (codes .Internal , fmt .Sprintf ("CreateVolume failed to get a 2 zones for creating regional disk, instead got: %v" , zones ))
341
341
}
342
342
disk , err = createRegionalDisk (ctx , gceCS .CloudProvider , name , zones , params , capacityRange , capBytes , snapshotID , volumeContentSourceVolumeID , multiWriter )
343
343
if err != nil {
344
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateVolume failed to create regional disk %#v: %v " , name , err ) )
344
+ return nil , LoggedError ( "CreateVolume failed to create regional disk " + name + ": " , err )
345
345
}
346
346
default :
347
347
return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("CreateVolume replication type '%s' is not supported" , params .ReplicationType ))
@@ -381,7 +381,7 @@ func (gceCS *GCEControllerServer) DeleteVolume(ctx context.Context, req *csi.Del
381
381
klog .Warningf ("DeleteVolume treating volume as deleted because cannot find volume %v: %w" , volumeID , err )
382
382
return & csi.DeleteVolumeResponse {}, nil
383
383
}
384
- return nil , status . Errorf ( codes . Internal , "DeleteVolume error repairing underspecified volume key: %v " , err )
384
+ return nil , LoggedError ( "DeleteVolume error repairing underspecified volume key: " , err )
385
385
}
386
386
387
387
if acquired := gceCS .volumeLocks .TryAcquire (volumeID ); ! acquired {
@@ -391,7 +391,7 @@ func (gceCS *GCEControllerServer) DeleteVolume(ctx context.Context, req *csi.Del
391
391
392
392
err = gceCS .CloudProvider .DeleteDisk (ctx , project , volKey )
393
393
if err != nil {
394
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "unknown Delete disk error: %v " , err ) )
394
+ return nil , LoggedError ( "unknown Delete disk error: " , err )
395
395
}
396
396
397
397
klog .V (4 ).Infof ("DeleteVolume succeeded for disk %v" , volKey )
@@ -470,7 +470,7 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
470
470
if gce .IsGCENotFoundError (err ) {
471
471
return nil , status .Errorf (codes .NotFound , "ControllerPublishVolume could not find volume with ID %v: %v" , volumeID , err )
472
472
}
473
- return nil , status . Errorf ( codes . Internal , "ControllerPublishVolume error repairing underspecified volume key: %v " , err )
473
+ return nil , LoggedError ( "ControllerPublishVolume error repairing underspecified volume key: " , err )
474
474
}
475
475
476
476
// Acquires the lock for the volume on that node only, because we need to support the ability
@@ -592,7 +592,7 @@ func (gceCS *GCEControllerServer) executeControllerUnpublishVolume(ctx context.C
592
592
if gce .IsGCENotFoundError (err ) {
593
593
return nil , status .Errorf (codes .NotFound , "ControllerUnpublishVolume could not find volume with ID %v: %v" , volumeID , err )
594
594
}
595
- return nil , status . Errorf ( codes . Internal , "ControllerUnpublishVolume error repairing underspecified volume key: %v " , err )
595
+ return nil , LoggedError ( "ControllerUnpublishVolume error repairing underspecified volume key: " , err )
596
596
}
597
597
598
598
// Acquires the lock for the volume on that node only, because we need to support the ability
@@ -632,7 +632,7 @@ func (gceCS *GCEControllerServer) executeControllerUnpublishVolume(ctx context.C
632
632
633
633
err = gceCS .CloudProvider .DetachDisk (ctx , project , deviceName , instanceZone , instanceName )
634
634
if err != nil {
635
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "unknown detach error: %v " , err ) )
635
+ return nil , LoggedError ( "unknown detach error: " , err )
636
636
}
637
637
638
638
klog .V (4 ).Infof ("ControllerUnpublishVolume succeeded for disk %v from node %v" , volKey , nodeID )
@@ -657,7 +657,7 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
657
657
if gce .IsGCENotFoundError (err ) {
658
658
return nil , status .Errorf (codes .NotFound , "ValidateVolumeCapabilities could not find volume with ID %v: %v" , volumeID , err )
659
659
}
660
- return nil , status . Errorf ( codes . Internal , "ValidateVolumeCapabilities error repairing underspecified volume key: %v " , err )
660
+ return nil , LoggedError ( "ValidateVolumeCapabilities error repairing underspecified volume key: " , err )
661
661
}
662
662
663
663
if acquired := gceCS .volumeLocks .TryAcquire (volumeID ); ! acquired {
@@ -670,7 +670,7 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
670
670
if gce .IsGCENotFoundError (err ) {
671
671
return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find disk %v: %v" , volKey .Name , err ))
672
672
}
673
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown get disk error: %v " , err ) )
673
+ return nil , LoggedError ( "Unknown get disk error: " , err )
674
674
}
675
675
676
676
// Check Volume Context is Empty
@@ -733,7 +733,7 @@ func (gceCS *GCEControllerServer) ListVolumes(ctx context.Context, req *csi.List
733
733
if gce .IsGCEInvalidError (err ) {
734
734
return nil , status .Error (codes .Aborted , fmt .Sprintf ("ListVolumes error with invalid request: %v" , err ))
735
735
}
736
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown list disk error: %v " , err ) )
736
+ return nil , LoggedError ( "Unknown list disk error: " , err )
737
737
}
738
738
gceCS .disks = diskList
739
739
gceCS .seen = map [string ]int {}
@@ -816,7 +816,7 @@ func (gceCS *GCEControllerServer) CreateSnapshot(ctx context.Context, req *csi.C
816
816
if gce .IsGCENotFoundError (err ) {
817
817
return nil , status .Error (codes .NotFound , fmt .Sprintf ("CreateSnapshot could not find disk %v: %v" , volKey .String (), err ))
818
818
}
819
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "CreateSnapshot unknown get disk error: %v " , err ) )
819
+ return nil , LoggedError ( "CreateSnapshot unknown get disk error: " , err )
820
820
}
821
821
822
822
snapshotParams , err := common .ExtractAndDefaultSnapshotParameters (req .GetParameters (), gceCS .Driver .name )
@@ -863,7 +863,7 @@ func (gceCS *GCEControllerServer) createPDSnapshot(ctx context.Context, project
863
863
if gce .IsGCEError (err , "notFound" ) {
864
864
return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find volume with ID %v: %v" , volKey .String (), err ))
865
865
}
866
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown create snapshot error: %v " , err ) )
866
+ return nil , LoggedError ( "Unknown create snapshot error: " , err )
867
867
}
868
868
}
869
869
@@ -902,15 +902,15 @@ func (gceCS *GCEControllerServer) createImage(ctx context.Context, project strin
902
902
image , err = gceCS .CloudProvider .GetImage (ctx , project , imageName )
903
903
if err != nil {
904
904
if ! gce .IsGCEError (err , "notFound" ) {
905
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown get image error: %v " , err ) )
905
+ return nil , LoggedError ( "Unknown get image error: " , err )
906
906
}
907
907
// create a new image
908
908
image , err = gceCS .CloudProvider .CreateImage (ctx , project , volKey , imageName , snapshotParams )
909
909
if err != nil {
910
910
if gce .IsGCEError (err , "notFound" ) {
911
911
return nil , status .Error (codes .NotFound , fmt .Sprintf ("Could not find volume with ID %v: %v" , volKey .String (), err ))
912
912
}
913
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown create image error: %v " , err ) )
913
+ return nil , LoggedError ( "Unknown create image error: " , err )
914
914
}
915
915
}
916
916
@@ -1040,12 +1040,12 @@ func (gceCS *GCEControllerServer) DeleteSnapshot(ctx context.Context, req *csi.D
1040
1040
case common .DiskSnapshotType :
1041
1041
err = gceCS .CloudProvider .DeleteSnapshot (ctx , project , key )
1042
1042
if err != nil {
1043
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "unknown Delete snapshot error: %v " , err ) )
1043
+ return nil , LoggedError ( "unknown Delete snapshot error: " , err )
1044
1044
}
1045
1045
case common .DiskImageType :
1046
1046
err = gceCS .CloudProvider .DeleteImage (ctx , project , key )
1047
1047
if err != nil {
1048
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "unknown Delete image error: %v " , err ) )
1048
+ return nil , LoggedError ( "unknown Delete image error: " , err )
1049
1049
}
1050
1050
default :
1051
1051
return nil , status .Error (codes .InvalidArgument , fmt .Sprintf ("unknown snapshot type %s" , snapshotType ))
@@ -1077,7 +1077,7 @@ func (gceCS *GCEControllerServer) ListSnapshots(ctx context.Context, req *csi.Li
1077
1077
if gce .IsGCEInvalidError (err ) {
1078
1078
return nil , status .Error (codes .Aborted , fmt .Sprintf ("ListSnapshots error with invalid request: %v" , err ))
1079
1079
}
1080
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown list snapshots error: %v " , err ) )
1080
+ return nil , LoggedError ( "Unknown list snapshots error: " , err )
1081
1081
}
1082
1082
gceCS .snapshots = snapshotList
1083
1083
gceCS .snapshotTokens = map [string ]int {}
@@ -1126,12 +1126,12 @@ func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, re
1126
1126
if gce .IsGCENotFoundError (err ) {
1127
1127
return nil , status .Errorf (codes .NotFound , "ControllerExpandVolume could not find volume with ID %v: %v" , volumeID , err )
1128
1128
}
1129
- return nil , status . Errorf ( codes . Internal , "ControllerExpandVolume error repairing underspecified volume key: %v " , err )
1129
+ return nil , LoggedError ( "ControllerExpandVolume error repairing underspecified volume key: " , err )
1130
1130
}
1131
1131
1132
1132
resizedGb , err := gceCS .CloudProvider .ResizeDisk (ctx , project , volKey , reqBytes )
1133
1133
if err != nil {
1134
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "ControllerExpandVolume failed to resize disk: %v " , err ) )
1134
+ return nil , LoggedError ( "ControllerExpandVolume failed to resize disk: " , err )
1135
1135
}
1136
1136
1137
1137
klog .V (4 ).Infof ("ControllerExpandVolume succeeded for disk %v to size %v" , volKey , resizedGb )
@@ -1154,15 +1154,15 @@ func (gceCS *GCEControllerServer) getSnapshots(ctx context.Context, req *csi.Lis
1154
1154
if gce .IsGCEError (err , "invalid" ) {
1155
1155
return nil , status .Error (codes .Aborted , fmt .Sprintf ("Invalid error: %v" , err ))
1156
1156
}
1157
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown list snapshot error: %v " , err ) )
1157
+ return nil , LoggedError ( "Unknown list snapshot error: " , err )
1158
1158
}
1159
1159
1160
1160
images , _ , err = gceCS .CloudProvider .ListImages (ctx , filter )
1161
1161
if err != nil {
1162
1162
if gce .IsGCEError (err , "invalid" ) {
1163
1163
return nil , status .Error (codes .Aborted , fmt .Sprintf ("Invalid error: %v" , err ))
1164
1164
}
1165
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown list image error: %v " , err ) )
1165
+ return nil , LoggedError ( "Unknown list image error: " , err )
1166
1166
}
1167
1167
1168
1168
entries := []* csi.ListSnapshotsResponse_Entry {}
@@ -1203,7 +1203,7 @@ func (gceCS *GCEControllerServer) getSnapshotByID(ctx context.Context, snapshotI
1203
1203
// return empty list if no snapshot is found
1204
1204
return & csi.ListSnapshotsResponse {}, nil
1205
1205
}
1206
- return nil , status . Error ( codes . Internal , fmt . Sprintf ( "Unknown list snapshot error: %v " , err ) )
1206
+ return nil , LoggedError ( "Unknown list snapshot error: " , err )
1207
1207
}
1208
1208
e , err := generateDiskSnapshotEntry (snapshot )
1209
1209
if err != nil {
0 commit comments