@@ -144,11 +144,11 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
144144 if v != "" {
145145 var err error
146146 if mountPermissions , err = strconv .ParseUint (v , 8 , 32 ); err != nil {
147- return nil , status .Errorf (codes .InvalidArgument , fmt . Sprintf ( "invalid mountPermissions %s in storage class" , v ) )
147+ return nil , status .Errorf (codes .InvalidArgument , "invalid mountPermissions %s in storage class" , v )
148148 }
149149 }
150150 default :
151- return nil , status .Errorf (codes .InvalidArgument , fmt . Sprintf ( "invalid parameter %q in storage class" , k ) )
151+ return nil , status .Errorf (codes .InvalidArgument , "invalid parameter %q in storage class" , k )
152152 }
153153 }
154154
@@ -168,24 +168,24 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
168168 }
169169 // Mount nfs base share so we can create a subdirectory
170170 if err = cs .internalMount (ctx , nfsVol , parameters , volCap ); err != nil {
171- return nil , status .Errorf (codes .Internal , "failed to mount nfs server: %v" , err . Error () )
171+ return nil , status .Errorf (codes .Internal , "failed to mount nfs server: %v" , err )
172172 }
173173 defer func () {
174174 if err = cs .internalUnmount (ctx , nfsVol ); err != nil {
175- klog .Warningf ("failed to unmount nfs server: %v" , err . Error () )
175+ klog .Warningf ("failed to unmount nfs server: %v" , err )
176176 }
177177 }()
178178
179179 // Create subdirectory under base-dir
180180 internalVolumePath := getInternalVolumePath (cs .Driver .workingMountDir , nfsVol )
181181 if err = os .MkdirAll (internalVolumePath , 0777 ); err != nil {
182- return nil , status .Errorf (codes .Internal , "failed to make subdirectory: %v" , err . Error () )
182+ return nil , status .Errorf (codes .Internal , "failed to make subdirectory: %v" , err )
183183 }
184184
185185 if mountPermissions > 0 {
186186 // Reset directory permissions because of umask problems
187187 if err = os .Chmod (internalVolumePath , os .FileMode (mountPermissions )); err != nil {
188- klog .Warningf ("failed to chmod subdirectory: %v" , err . Error () )
188+ klog .Warningf ("failed to chmod subdirectory: %v" , err )
189189 }
190190 }
191191
@@ -245,19 +245,19 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
245245 // check whether volumeID is in the cache
246246 cache , err := cs .Driver .volDeletionCache .Get (volumeID , azcache .CacheReadTypeDefault )
247247 if err != nil {
248- return nil , status .Errorf (codes .Internal , err . Error () )
248+ return nil , status .Errorf (codes .Internal , "%v" , err )
249249 }
250250 if cache != nil {
251251 klog .V (2 ).Infof ("DeleteVolume: volume %s is already deleted" , volumeID )
252252 return & csi.DeleteVolumeResponse {}, nil
253253 }
254254 // mount nfs base share so we can delete the subdirectory
255255 if err = cs .internalMount (ctx , nfsVol , nil , volCap ); err != nil {
256- return nil , status .Errorf (codes .Internal , "failed to mount nfs server: %v" , err . Error () )
256+ return nil , status .Errorf (codes .Internal , "failed to mount nfs server: %v" , err )
257257 }
258258 defer func () {
259259 if err = cs .internalUnmount (ctx , nfsVol ); err != nil {
260- klog .Warningf ("failed to unmount nfs server: %v" , err . Error () )
260+ klog .Warningf ("failed to unmount nfs server: %v" , err )
261261 }
262262 }()
263263
@@ -269,7 +269,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
269269 parentDir := filepath .Dir (archivedInternalVolumePath )
270270 klog .V (2 ).Infof ("DeleteVolume: subdirectory(%s) contains '/', make sure the parent directory(%s) exists" , nfsVol .subDir , parentDir )
271271 if err = os .MkdirAll (parentDir , 0777 ); err != nil {
272- return nil , status .Errorf (codes .Internal , "create parent directory(%s) of %s failed with %v" , parentDir , archivedInternalVolumePath , err . Error () )
272+ return nil , status .Errorf (codes .Internal , "create parent directory(%s) of %s failed with %v" , parentDir , archivedInternalVolumePath , err )
273273 }
274274 }
275275
@@ -278,12 +278,12 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
278278 if cs .Driver .removeArchivedVolumePath {
279279 klog .V (2 ).Infof ("removing archived subdirectory at %v" , archivedInternalVolumePath )
280280 if err = os .RemoveAll (archivedInternalVolumePath ); err != nil {
281- return nil , status .Errorf (codes .Internal , "failed to delete archived subdirectory %s: %v" , archivedInternalVolumePath , err . Error () )
281+ return nil , status .Errorf (codes .Internal , "failed to delete archived subdirectory %s: %v" , archivedInternalVolumePath , err )
282282 }
283283 klog .V (2 ).Infof ("removed archived subdirectory at %v" , archivedInternalVolumePath )
284284 }
285285 if err = os .Rename (internalVolumePath , archivedInternalVolumePath ); err != nil {
286- return nil , status .Errorf (codes .Internal , "archive subdirectory(%s, %s) failed with %v" , internalVolumePath , archivedInternalVolumePath , err . Error () )
286+ return nil , status .Errorf (codes .Internal , "archive subdirectory(%s, %s) failed with %v" , internalVolumePath , archivedInternalVolumePath , err )
287287 }
288288 // make sure internalVolumePath does not exist with 1 minute timeout
289289 if err = waitForPathNotExistWithTimeout (internalVolumePath , time .Minute ); err != nil {
@@ -294,7 +294,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
294294 // delete subdirectory under base-dir
295295 klog .V (2 ).Infof ("removing subdirectory at %v" , internalVolumePath )
296296 if err = os .RemoveAll (internalVolumePath ); err != nil {
297- return nil , status .Errorf (codes .Internal , "delete subdirectory(%s) failed with %v" , internalVolumePath , err . Error () )
297+ return nil , status .Errorf (codes .Internal , "delete subdirectory(%s) failed with %v" , internalVolumePath , err )
298298 }
299299 }
300300 } else {
@@ -455,7 +455,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
455455 internalVolumePath := getInternalVolumePath (cs .Driver .workingMountDir , vol )
456456 klog .V (2 ).Infof ("Removing snapshot archive at %v" , internalVolumePath )
457457 if err = os .RemoveAll (internalVolumePath ); err != nil {
458- return nil , status .Errorf (codes .Internal , "failed to delete subdirectory: %v" , err . Error () )
458+ return nil , status .Errorf (codes .Internal , "failed to delete subdirectory: %v" , err )
459459 }
460460
461461 return & csi.DeleteSnapshotResponse {}, nil
@@ -620,7 +620,7 @@ func newNFSSnapshot(name string, params map[string]string, vol *nfsVolume) (*nfs
620620 case paramShare :
621621 baseDir = v
622622 default :
623- return nil , status .Errorf (codes .InvalidArgument , fmt . Sprintf ( "invalid parameter %q in snapshot storage class" , k ) )
623+ return nil , status .Errorf (codes .InvalidArgument , "invalid parameter %q in snapshot storage class" , k )
624624 }
625625 }
626626
0 commit comments