mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
cephfs: add subvolume struct and getSubvolumeInfo calls
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
31e9288f8f
commit
1f4839cb5e
@ -40,6 +40,19 @@ const (
|
||||
cephEntityClientPrefix = "client."
|
||||
)
|
||||
|
||||
// Subvolume holds subvolume information.
|
||||
type Subvolume struct {
|
||||
BytesQuota int `json:"bytes_quota"`
|
||||
DataPool string `json:"data_pool"`
|
||||
GID int `json:"gid"`
|
||||
Mode int `json:"mode"`
|
||||
MonAddrs []string `json:"mon_addrs"`
|
||||
Path string `json:"path"`
|
||||
PoolNamespace string `json:"pool_namespace"`
|
||||
Type string `json:"type"`
|
||||
UID int `json:"uid"`
|
||||
}
|
||||
|
||||
func getVolumeRootPathCephDeprecated(volID volumeID) string {
|
||||
return path.Join("/", "csi-volumes", string(volID))
|
||||
}
|
||||
@ -72,6 +85,38 @@ func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, cr *u
|
||||
return strings.TrimSuffix(stdout, "\n"), nil
|
||||
}
|
||||
|
||||
func getSubVolumeInfo(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, volID volumeID) (Subvolume, error) {
|
||||
info := Subvolume{}
|
||||
err := execCommandJSON(
|
||||
ctx,
|
||||
&info,
|
||||
"ceph",
|
||||
"fs",
|
||||
"subvolume",
|
||||
"info",
|
||||
volOptions.FsName,
|
||||
string(volID),
|
||||
"--group_name",
|
||||
volOptions.SubvolumeGroup,
|
||||
"-m", volOptions.Monitors,
|
||||
"-c", util.CephConfigPath,
|
||||
"-n", cephEntityClientPrefix+cr.ID,
|
||||
"--keyfile="+cr.KeyFile)
|
||||
if err != nil {
|
||||
klog.Errorf(util.Log(ctx, "failed to get subvolume info for the vol %s(%s)"), string(volID), err)
|
||||
if strings.HasPrefix(err.Error(), ErrVolumeNotFound.Error()) {
|
||||
return info, ErrVolumeNotFound
|
||||
}
|
||||
// Incase the error is other than invalid command return error to the caller.
|
||||
if !strings.Contains(err.Error(), ErrInvalidCommand.Error()) {
|
||||
return info, ErrInvalidCommand
|
||||
}
|
||||
|
||||
return info, err
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
type localClusterState struct {
|
||||
// set true if cluster supports resize functionality.
|
||||
resizeSupported bool
|
||||
|
Loading…
Reference in New Issue
Block a user