@@ -163,7 +163,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
163163 return nil , status .Error (codes .InvalidArgument , err .Error ())
164164 }
165165
166- var volCap * csi. VolumeCapability
166+ volCap := getVolumeCapabilityFromSecret ( name , req . GetSecrets ())
167167 if len (req .GetVolumeCapabilities ()) > 0 {
168168 volCap = req .GetVolumeCapabilities ()[0 ]
169169 }
@@ -220,19 +220,6 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
220220 return & csi.DeleteVolumeResponse {}, nil
221221 }
222222
223- var volCap * csi.VolumeCapability
224- mountOptions := getMountOptions (req .GetSecrets ())
225- if mountOptions != "" {
226- klog .V (2 ).Infof ("DeleteVolume: found mountOptions(%s) for volume(%s)" , mountOptions , volumeID )
227- volCap = & csi.VolumeCapability {
228- AccessType : & csi.VolumeCapability_Mount {
229- Mount : & csi.VolumeCapability_MountVolume {
230- MountFlags : []string {mountOptions },
231- },
232- },
233- }
234- }
235-
236223 if nfsVol .onDelete == "" {
237224 nfsVol .onDelete = cs .Driver .defaultOnDeletePolicy
238225 }
@@ -253,6 +240,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
253240 return & csi.DeleteVolumeResponse {}, nil
254241 }
255242 // mount nfs base share so we can delete the subdirectory
243+ volCap := getVolumeCapabilityFromSecret (volumeID , req .GetSecrets ())
256244 if err = cs .internalMount (ctx , nfsVol , nil , volCap ); err != nil {
257245 return nil , status .Errorf (codes .Internal , "failed to mount nfs server: %v" , err )
258246 }
@@ -376,7 +364,8 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
376364 return nil , status .Errorf (codes .NotFound , "failed to create nfsSnapshot: %v" , err )
377365 }
378366 snapVol := volumeFromSnapshot (snapshot )
379- if err = cs .internalMount (ctx , snapVol , req .GetParameters (), nil ); err != nil {
367+ volCap := getVolumeCapabilityFromSecret (req .GetSourceVolumeId (), req .GetSecrets ())
368+ if err = cs .internalMount (ctx , snapVol , req .GetParameters (), volCap ); err != nil {
380369 return nil , status .Errorf (codes .Internal , "failed to mount snapshot nfs server: %v" , err )
381370 }
382371 defer func () {
@@ -392,7 +381,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
392381 return nil , err
393382 }
394383
395- if err = cs .internalMount (ctx , srcVol , req .GetParameters (), nil ); err != nil {
384+ if err = cs .internalMount (ctx , srcVol , req .GetParameters (), volCap ); err != nil {
396385 return nil , status .Errorf (codes .Internal , "failed to mount src nfs server: %v" , err )
397386 }
398387 defer func () {
@@ -445,18 +434,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
445434 return & csi.DeleteSnapshotResponse {}, nil
446435 }
447436
448- var volCap * csi.VolumeCapability
449- mountOptions := getMountOptions (req .GetSecrets ())
450- if mountOptions != "" {
451- klog .V (2 ).Infof ("DeleteSnapshot: found mountOptions(%s) for snapshot(%s)" , mountOptions , req .GetSnapshotId ())
452- volCap = & csi.VolumeCapability {
453- AccessType : & csi.VolumeCapability_Mount {
454- Mount : & csi.VolumeCapability_MountVolume {
455- MountFlags : []string {mountOptions },
456- },
457- },
458- }
459- }
437+ volCap := getVolumeCapabilityFromSecret (req .SnapshotId , req .GetSecrets ())
460438 vol := volumeFromSnapshot (snap )
461439 if err = cs .internalMount (ctx , vol , nil , volCap ); err != nil {
462440 return nil , status .Errorf (codes .Internal , "failed to mount nfs server for snapshot deletion: %v" , err )
0 commit comments