Skip to content

Commit

Permalink
fix(WEKAPP-365056): move the server mount option addition inside volu…
Browse files Browse the repository at this point in the history
…me.Mount
  • Loading branch information
sergeyberezansky committed Feb 8, 2024
1 parent a0569a9 commit 248f9b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions pkg/wekafs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
// IDEMPOTENCE FLOW: If directory already exists, return the createResponse if size matches, or error
volExists, volMatchesCapacity, err := volumeExistsAndMatchesCapacity(ctx, volume, capacity)

// set params to have all relevant mount options (default + those received in params - default controller opts) to be passed as part of volumeContext
mountOpts := volume.getMountOptions(ctx).RemoveOption(MountOptionAcl)
params["mountOptions"] = mountOpts.String()
// set params to have all relevant mount options (global default + those received in params) to be passed as part of volumeContext
params["mountOptions"] = volume.getMountOptions(ctx).String()

if err != nil {
if !volExists {
Expand Down
5 changes: 2 additions & 3 deletions pkg/wekafs/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ func (v *Volume) getCsiContentSource(ctx context.Context) *csi.VolumeContentSour
return nil
}

func (v *Volume) initMountOptions(ctx context.Context) {
v.mountOptions = v.server.getDefaultMountOptions()
func (v *Volume) sanitizeMountOptions(ctx context.Context) {
v.pruneUnsupportedMountOptions(ctx)
}

Expand Down Expand Up @@ -824,7 +823,7 @@ func (v *Volume) MountUnderlyingFS(ctx context.Context) (error, UnmountFunc) {
return errors.New("could not mount volume, mounter not in context"), func() {}
}

mountOpts := v.getMountOptions(ctx)
mountOpts := v.getMountOptions(ctx).MergedWith(v.server.getDefaultMountOptions(), v.server.getConfig().mutuallyExclusiveOptions)
mount, err, unmountFunc := v.server.getMounter().mountWithOptions(ctx, v.FilesystemName, mountOpts, v.apiClient)
retUmountFunc := func() {}
if err == nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/wekafs/volumeconstructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ func NewVolumeFromId(ctx context.Context, volumeId string, apiClient *apiclient.
permissions: DefaultVolumePermissions,
mountPath: "",
server: server,
mountOptions: getDefaultMountOptions(),
}
v.initMountOptions(ctx)
v.sanitizeMountOptions(ctx)
return v, nil
}

Expand Down Expand Up @@ -91,9 +92,9 @@ func NewVolumeFromControllerCreateRequest(ctx context.Context, req *csi.CreateVo
return nil, err
}
}
volume.initMountOptions(ctx)
params := req.GetParameters()
err = volume.ObtainRequestParams(ctx, params)
volume.sanitizeMountOptions(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not obtain volume parameters from request")
}
Expand Down

0 comments on commit 248f9b5

Please sign in to comment.