cleanup: use util.MountOptionsAdd() in CephFS volumemounter

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-17 11:13:47 +02:00 committed by mergify[bot]
parent cdbc56de7d
commit efd9b31043

View File

@ -285,17 +285,13 @@ func mountKernel(ctx context.Context, mountPoint string, cr *util.Credentials, v
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath), fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
mountPoint, mountPoint,
} }
optionsStr := fmt.Sprintf("name=%s,secretfile=%s", cr.ID, cr.KeyFile)
if volOptions.FsName != "" {
optionsStr += fmt.Sprintf(",mds_namespace=%s", volOptions.FsName)
}
if volOptions.KernelMountOptions != "" {
optionsStr += fmt.Sprintf(",%s", volOptions.KernelMountOptions)
}
if !strings.Contains(volOptions.KernelMountOptions, netDev) { optionsStr := fmt.Sprintf("name=%s,secretfile=%s", cr.ID, cr.KeyFile)
optionsStr += fmt.Sprintf(",%s", netDev) mdsNamespace := ""
if volOptions.FsName != "" {
mdsNamespace = fmt.Sprintf("mds_namespace=%s", volOptions.FsName)
} }
optionsStr = util.MountOptionsAdd(optionsStr, mdsNamespace, volOptions.KernelMountOptions, netDev)
args = append(args, "-o", optionsStr) args = append(args, "-o", optionsStr)
@ -319,7 +315,7 @@ func bindMount(ctx context.Context, from, to string, readOnly bool, mntOptions [
} }
if readOnly { if readOnly {
mntOptionSli += ",remount" mntOptionSli = util.MountOptionsAdd(mntOptionSli, "remount")
if err := execCommandErr(ctx, "mount", "-o", mntOptionSli, to); err != nil { if err := execCommandErr(ctx, "mount", "-o", mntOptionSli, to); err != nil {
return fmt.Errorf("failed read-only remount of %s: %v", to, err) return fmt.Errorf("failed read-only remount of %s: %v", to, err)
} }