From b6f3ba885eaf952a7e9269561d75f61b9bcd1b07 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 26 Nov 2020 13:55:48 +0530 Subject: [PATCH] cephfs: implement getVolumeRootPathCeph with go-ceph instead of ceph fs CLI commands using go-ceph library to get subvolume path. Signed-off-by: Madhu Rajanna --- internal/cephfs/volume.go | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index fd6ff8144..4f3ebe468 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -57,30 +57,20 @@ func getVolumeRootPathCephDeprecated(volID volumeID) string { } func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, volID volumeID) (string, error) { - stdout, stderr, err := util.ExecCommand( - ctx, - "ceph", - "fs", - "subvolume", - "getpath", - volOptions.FsName, - string(volID), - "--group_name", - volOptions.SubvolumeGroup, - "-m", volOptions.Monitors, - "-c", util.CephConfigPath, - "-n", cephEntityClientPrefix+cr.ID, - "--keyfile="+cr.KeyFile) - + fsa, err := volOptions.conn.GetFSAdmin() if err != nil { - util.ErrorLog(ctx, "failed to get the rootpath for the vol %s: %s (stdError: %s)", string(volID), err, stderr) - if strings.Contains(stderr, volumeNotFound) { - return "", util.JoinErrors(ErrVolumeNotFound, err) - } - + util.ErrorLog(ctx, "could not get FSAdmin err %s", err) return "", err } - return strings.TrimSuffix(stdout, "\n"), nil + svPath, err := fsa.SubVolumePath(volOptions.FsName, volOptions.SubvolumeGroup, string(volID)) + if err != nil { + util.ErrorLog(ctx, "failed to get the rootpath for the vol %s: %s", string(volID), err) + if strings.Contains(err.Error(), volumeNotFound) { + return "", util.JoinErrors(ErrVolumeNotFound, err) + } + return "", err + } + return svPath, nil } func (vo *volumeOptions) getSubVolumeInfo(ctx context.Context, volID volumeID) (*Subvolume, error) {