Skip to content

Commit

Permalink
cephfs: upgrading mount syntax
Browse files Browse the repository at this point in the history
The old syntax is almost deprecated,and there are reasons to upgrade it
- old syntax is lack of fsid(critical for debugging and observability)
- mds_namespace is deprecated, it might be inappropriate to continue using it
- kernel will try new syntax first and then the old one, it's a waste

Signed-off-by: mageekchiu <[email protected]>
  • Loading branch information
MageekChiu authored and nixpanic committed Feb 13, 2025
1 parent 4d1548c commit 83cea81
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
21 changes: 10 additions & 11 deletions internal/cephfs/mounter/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,24 @@ func (m *kernelMounter) mountKernel(
m.needsModprobe = false
}

fsID, err := volOptions.GetFSID()
if err != nil {
return fmt.Errorf("failed to get fsID, stop mounting: %w", err)
}

args := []string{
"-t", "ceph",
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
fmt.Sprintf("%s@%s.%s=%s", cr.ID, fsID, volOptions.FsName, volOptions.RootPath),
mountPoint,
}

optionsStr := fmt.Sprintf("name=%s,secretfile=%s", cr.ID, cr.KeyFile)
mdsNamespace := ""
if volOptions.FsName != "" {
mdsNamespace = "mds_namespace=" + volOptions.FsName
}
optionsStr = util.MountOptionsAdd(optionsStr, mdsNamespace, volOptions.KernelMountOptions, netDev)
optionsStr := fmt.Sprintf("mon_addr=%s,secretfile=%s", strings.ReplaceAll(volOptions.Monitors, ",", "/"), cr.KeyFile)

optionsStr = util.MountOptionsAdd(optionsStr, volOptions.KernelMountOptions, netDev)

args = append(args, "-o", optionsStr)

var (
stderr string
err error
)
var stderr string

if volOptions.NetNamespaceFilePath != "" {
_, stderr, err = util.ExecuteCommandWithNSEnter(ctx, volOptions.NetNamespaceFilePath, "mount", args[:]...)
Expand Down
13 changes: 13 additions & 0 deletions internal/cephfs/store/volumeoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ func (vo *VolumeOptions) Destroy() {
}
}

func (vo *VolumeOptions) GetFSID() (string, error) {
if vo.conn == nil {
return "", errors.New("cluster not connected yet")
}

fsID, err := vo.conn.GetFSID()
if err != nil {
return "", err
}

return fsID, nil
}

func validateNonEmptyField(field, fieldName string) error {
if field == "" {
return fmt.Errorf("parameter '%s' cannot be empty", fieldName)
Expand Down

0 comments on commit 83cea81

Please sign in to comment.