@@ -95,8 +95,10 @@ func (csiCS *CSIControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
95
95
// Create copy of the requestedVolume
96
96
tempReqVol := (* requestedVolume )
97
97
// Mask VolumeEncryptionKey
98
- tempReqVol .VolumeEncryptionKey = & provider.VolumeEncryptionKey {CRN : "********" }
99
- ctxLogger .Info ("Volume request after masking encryption key" , zap .Reflect ("Volume" , tempReqVol ))
98
+ if requestedVolume .VolumeEncryptionKey != nil {
99
+ tempReqVol .VolumeEncryptionKey = & provider.VolumeEncryptionKey {CRN : "********" }
100
+ }
101
+ ctxLogger .Info ("Volume request" , zap .Reflect ("Volume" , tempReqVol ))
100
102
}
101
103
102
104
if err != nil {
@@ -145,7 +147,7 @@ func (csiCS *CSIControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
145
147
if providerError .RetrivalFailed == providerError .GetErrorType (err ) {
146
148
return nil , commonError .GetCSIError (ctxLogger , commonError .ObjectNotFound , requestID , err , "creation" )
147
149
}
148
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err , "creation" )
150
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
149
151
}
150
152
151
153
// return csi volume object
@@ -186,7 +188,7 @@ func (csiCS *CSIControllerServer) DeleteVolume(ctx context.Context, req *csi.Del
186
188
187
189
err = session .DeleteVolume (volume )
188
190
if err != nil {
189
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
191
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
190
192
}
191
193
return & csi.DeleteVolumeResponse {}, nil
192
194
}
@@ -238,7 +240,7 @@ func (csiCS *CSIControllerServer) ControllerPublishVolume(ctx context.Context, r
238
240
// Volume not found
239
241
if volDetail == nil && err == nil {
240
242
return nil , commonError .GetCSIError (ctxLogger , commonError .ObjectNotFound , requestID , nil , volumeID )
241
- } else if err != nil { // In case of other errors apart from volume not found
243
+ } else if err != nil { // In case of other errors apart from volume not found
242
244
return nil , commonError .GetCSIError (ctxLogger , commonError .InternalError , requestID , err )
243
245
}
244
246
@@ -256,7 +258,7 @@ func (csiCS *CSIControllerServer) ControllerPublishVolume(ctx context.Context, r
256
258
if providerError .GetErrorType (err ) == providerError .NodeNotFound {
257
259
return nil , commonError .GetCSIError (ctxLogger , commonError .ObjectNotFound , requestID , err )
258
260
}
259
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
261
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
260
262
}
261
263
262
264
//Pass in the VPCVolumeAttachment ID for efficient retrival in WaitForAttachVolume()
@@ -267,7 +269,7 @@ func (csiCS *CSIControllerServer) ControllerPublishVolume(ctx context.Context, r
267
269
response , err = sess .WaitForAttachVolume (volumeAttachmentReq )
268
270
if err != nil {
269
271
//retry gap is constant in the common lib i.e 10 seconds and number of retries are 4*Retry configure in the driver
270
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
272
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
271
273
}
272
274
273
275
ctxLogger .Info ("Attachment response" , zap .Reflect ("Response" , response ))
@@ -311,12 +313,12 @@ func (csiCS *CSIControllerServer) ControllerUnpublishVolume(ctx context.Context,
311
313
}
312
314
response , err := sess .DetachVolume (volumeAttachmentReq )
313
315
if err != nil {
314
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
316
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
315
317
}
316
318
err = sess .WaitForDetachVolume (volumeAttachmentReq )
317
319
if err != nil {
318
320
//retry gap is constant in the common lib i.e 10 seconds and number of retries are 4*Retry configure in the driver
319
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
321
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
320
322
}
321
323
ctxLogger .Info ("Detach response" , zap .Reflect ("response" , response ))
322
324
return & csi.ControllerUnpublishVolumeResponse {}, nil
@@ -350,7 +352,7 @@ func (csiCS *CSIControllerServer) ValidateVolumeCapabilities(ctx context.Context
350
352
if providerError .RetrivalFailed == providerError .GetErrorType (err ) {
351
353
return nil , commonError .GetCSIError (ctxLogger , commonError .ObjectNotFound , requestID , err , volumeID )
352
354
}
353
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
355
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
354
356
}
355
357
356
358
// Setup Response
@@ -389,7 +391,7 @@ func (csiCS *CSIControllerServer) ListVolumes(ctx context.Context, req *csi.List
389
391
} else if strings .Contains (errCode , "StartVolumeIDNotFound" ) {
390
392
return nil , commonError .GetCSIError (ctxLogger , commonError .StartVolumeIDNotFound , requestID , err , req .StartingToken )
391
393
}
392
- return nil , commonError .GetCSIError (ctxLogger , commonError . ListVolumesFailed , requestID , err )
394
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
393
395
}
394
396
395
397
entries := []* csi.ListVolumesResponse_Entry {}
@@ -528,7 +530,7 @@ func (csiCS *CSIControllerServer) DeleteSnapshot(ctx context.Context, req *csi.D
528
530
ctxLogger .Info ("Snapshot not found. Returning success without deletion..." )
529
531
return & csi.DeleteSnapshotResponse {}, nil
530
532
}
531
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
533
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
532
534
}
533
535
return & csi.DeleteSnapshotResponse {}, nil
534
536
}
@@ -626,7 +628,7 @@ func (csiCS *CSIControllerServer) ControllerExpandVolume(ctx context.Context, re
626
628
ctxLogger , requestID := utils .GetContextLogger (ctx , false )
627
629
// populate requestID in the context
628
630
_ = context .WithValue (ctx , provider .RequestID , requestID )
629
-
631
+ defer metrics . UpdateDurationFromStart ( ctxLogger , "ControllerExpandVolume" , time . Now ())
630
632
ctxLogger .Info ("CSIControllerServer-ControllerExpandVolume" , zap .Reflect ("Request" , req ))
631
633
volumeID := req .GetVolumeId ()
632
634
capacity := req .GetCapacityRange ().GetRequiredBytes ()
@@ -645,7 +647,7 @@ func (csiCS *CSIControllerServer) ControllerExpandVolume(ctx context.Context, re
645
647
// Volume not found
646
648
if volDetail == nil && err == nil {
647
649
return nil , commonError .GetCSIError (ctxLogger , commonError .ObjectNotFound , requestID , nil , volumeID )
648
- } else if err != nil { // In case of other errors apart from volume not found
650
+ } else if err != nil { // In case of other errors apart from volume not found
649
651
return nil , commonError .GetCSIError (ctxLogger , commonError .InternalError , requestID , err )
650
652
}
651
653
@@ -655,7 +657,7 @@ func (csiCS *CSIControllerServer) ControllerExpandVolume(ctx context.Context, re
655
657
}
656
658
_ , err = session .ExpandVolume (volumeExpansionReq )
657
659
if err != nil {
658
- return nil , commonError .GetCSIError (ctxLogger , commonError . InternalError , requestID , err )
660
+ return nil , commonError .GetCSIBackendError (ctxLogger , requestID , err )
659
661
}
660
662
return & csi.ControllerExpandVolumeResponse {CapacityBytes : capacity , NodeExpansionRequired : true }, nil
661
663
}
0 commit comments