From 248f9b51bec47c29ce5009150de6381d676d0cde Mon Sep 17 00:00:00 2001 From: Sergey Berezansky Date: Thu, 8 Feb 2024 19:37:42 +0200 Subject: [PATCH] fix(WEKAPP-365056): move the server mount option addition inside volume.Mount --- pkg/wekafs/controllerserver.go | 5 ++--- pkg/wekafs/volume.go | 5 ++--- pkg/wekafs/volumeconstructors.go | 5 +++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/wekafs/controllerserver.go b/pkg/wekafs/controllerserver.go index 2b623deb4..4f31c8289 100644 --- a/pkg/wekafs/controllerserver.go +++ b/pkg/wekafs/controllerserver.go @@ -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 { diff --git a/pkg/wekafs/volume.go b/pkg/wekafs/volume.go index 44135f543..fdc609cde 100644 --- a/pkg/wekafs/volume.go +++ b/pkg/wekafs/volume.go @@ -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) } @@ -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 { diff --git a/pkg/wekafs/volumeconstructors.go b/pkg/wekafs/volumeconstructors.go index b74eeb62c..6f60654a5 100644 --- a/pkg/wekafs/volumeconstructors.go +++ b/pkg/wekafs/volumeconstructors.go @@ -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 } @@ -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") }