cephfs: make getVolumeRootPathCeph as a method

getVolumeRootPathCeph is a method of volumeOptions

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-11-30 15:00:01 +05:30 committed by mergify[bot]
parent e4713bc9ed
commit b40d561228
3 changed files with 5 additions and 5 deletions

View File

@ -132,7 +132,7 @@ func checkVolExists(ctx context.Context,
return nil, fmt.Errorf("clone is not in complete state for %s", vid.FsSubvolName)
}
} else {
_, err = getVolumeRootPathCeph(ctx, volOptions, volumeID(vid.FsSubvolName))
_, err = volOptions.getVolumeRootPathCeph(ctx, volumeID(vid.FsSubvolName))
if err != nil {
if errors.Is(err, ErrVolumeNotFound) {
err = j.UndoReservation(ctx, volOptions.MetadataPool,

View File

@ -56,13 +56,13 @@ func getVolumeRootPathCephDeprecated(volID volumeID) string {
return path.Join("/", "csi-volumes", string(volID))
}
func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, volID volumeID) (string, error) {
fsa, err := volOptions.conn.GetFSAdmin()
func (vo *volumeOptions) getVolumeRootPathCeph(ctx context.Context, volID volumeID) (string, error) {
fsa, err := vo.conn.GetFSAdmin()
if err != nil {
util.ErrorLog(ctx, "could not get FSAdmin err %s", err)
return "", err
}
svPath, err := fsa.SubVolumePath(volOptions.FsName, volOptions.SubvolumeGroup, string(volID))
svPath, err := fsa.SubVolumePath(vo.FsName, vo.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) {

View File

@ -347,7 +347,7 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
}
if errors.Is(err, ErrInvalidCommand) {
volOptions.RootPath, err = getVolumeRootPathCeph(ctx, &volOptions, volumeID(vid.FsSubvolName))
volOptions.RootPath, err = volOptions.getVolumeRootPathCeph(ctx, volumeID(vid.FsSubvolName))
}
return &volOptions, &vid, err