Skip to content

Commit

Permalink
cephfs: use subvolume info if available
Browse files Browse the repository at this point in the history
Use subvolume info to fetch the subvolume path.
If `subvolume info` command is not available,
use `getpath` command instead.

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 365eb58)
  • Loading branch information
Yuggupta27 authored and mergify[bot] committed Sep 11, 2020
1 parent 0f51df9 commit b32569b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions internal/cephfs/volumeoptions.go
Expand Up @@ -47,6 +47,7 @@ type volumeOptions struct {
KernelMountOptions string `json:"kernelMountOptions"`
FuseMountOptions string `json:"fuseMountOptions"`
SubvolumeGroup string
Features []string
}

func validateNonEmptyField(field, fieldName string) error {
Expand Down Expand Up @@ -224,6 +225,7 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
vi util.CSIIdentifier
volOptions volumeOptions
vid volumeIdentifier
info Subvolume
)

// Decode the VolID first, to detect older volumes or pre-provisioned volumes
Expand Down Expand Up @@ -299,11 +301,18 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
}

volOptions.ProvisionVolume = true
volOptions.RootPath, err = getVolumeRootPathCeph(ctx, &volOptions, cr, volumeID(vid.FsSubvolName))
if err != nil {
return &volOptions, &vid, err

info, err = getSubVolumeInfo(ctx, &volOptions, cr, volumeID(vid.FsSubvolName))
if err == nil {
volOptions.RootPath = info.Path
volOptions.Features = info.Features
}
return &volOptions, &vid, nil

if errors.Is(err, ErrInvalidCommand) {
volOptions.RootPath, err = getVolumeRootPathCeph(ctx, &volOptions, cr, volumeID(vid.FsSubvolName))
}

return &volOptions, &vid, err
}

// newVolumeOptionsFromMonitorList generates a new instance of volumeOptions and
Expand Down

0 comments on commit b32569b

Please sign in to comment.