mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-10 00:10:20 +00:00
cephfs: make getCloneState() a method of volumeOptions
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
66aa595e77
commit
476ad18d2e
@ -93,7 +93,7 @@ func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volO
|
|||||||
return cloneErr
|
return cloneErr
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneState, cloneErr := getCloneState(ctx, volOpt, cr, cloneID)
|
cloneState, cloneErr := volOpt.getCloneState(ctx, cr, cloneID)
|
||||||
if cloneErr != nil {
|
if cloneErr != nil {
|
||||||
return cloneErr
|
return cloneErr
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volu
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
cloneState, err := getCloneState(ctx, volOptions, cr, volumeID(vID.FsSubvolName))
|
cloneState, err := volOptions.getCloneState(ctx, cr, volumeID(vID.FsSubvolName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volu
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCloneState(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, volID volumeID) (cephFSCloneState, error) {
|
func (vo *volumeOptions) getCloneState(ctx context.Context, cr *util.Credentials, volID volumeID) (cephFSCloneState, error) {
|
||||||
type cloneStatus struct {
|
type cloneStatus struct {
|
||||||
Status struct {
|
Status struct {
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
@ -220,11 +220,11 @@ func getCloneState(ctx context.Context, volOptions *volumeOptions, cr *util.Cred
|
|||||||
"fs",
|
"fs",
|
||||||
"clone",
|
"clone",
|
||||||
"status",
|
"status",
|
||||||
volOptions.FsName,
|
vo.FsName,
|
||||||
string(volID),
|
string(volID),
|
||||||
"--group_name",
|
"--group_name",
|
||||||
volOptions.SubvolumeGroup,
|
vo.SubvolumeGroup,
|
||||||
"-m", volOptions.Monitors,
|
"-m", vo.Monitors,
|
||||||
"-c", util.CephConfigPath,
|
"-c", util.CephConfigPath,
|
||||||
"-n", cephEntityClientPrefix + cr.ID,
|
"-n", cephEntityClientPrefix + cr.ID,
|
||||||
"--keyfile=" + cr.KeyFile,
|
"--keyfile=" + cr.KeyFile,
|
||||||
@ -236,7 +236,7 @@ func getCloneState(ctx context.Context, volOptions *volumeOptions, cr *util.Cred
|
|||||||
"ceph",
|
"ceph",
|
||||||
args[:]...)
|
args[:]...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.ErrorLog(ctx, "failed to get subvolume clone info %s(%s) in fs %s", string(volID), err, volOptions.FsName)
|
util.ErrorLog(ctx, "failed to get subvolume clone info %s(%s) in fs %s", string(volID), err, vo.FsName)
|
||||||
return cephFSCloneError, err
|
return cephFSCloneError, err
|
||||||
}
|
}
|
||||||
return cephFSCloneState(cs.Status.State), nil
|
return cephFSCloneState(cs.Status.State), nil
|
||||||
|
@ -83,9 +83,9 @@ func checkVolExists(ctx context.Context,
|
|||||||
vid.FsSubvolName = imageData.ImageAttributes.ImageName
|
vid.FsSubvolName = imageData.ImageAttributes.ImageName
|
||||||
|
|
||||||
if sID != nil || pvID != nil {
|
if sID != nil || pvID != nil {
|
||||||
cloneState, cloneInfoErr := getCloneState(ctx, volOptions, cr, volumeID(vid.FsSubvolName))
|
cloneState, cloneStateErr := volOptions.getCloneState(ctx, cr, volumeID(vid.FsSubvolName))
|
||||||
if cloneInfoErr != nil {
|
if cloneStateErr != nil {
|
||||||
if errors.Is(cloneInfoErr, ErrVolumeNotFound) {
|
if errors.Is(cloneStateErr, ErrVolumeNotFound) {
|
||||||
if pvID != nil {
|
if pvID != nil {
|
||||||
err = cleanupCloneFromSubvolumeSnapshot(
|
err = cleanupCloneFromSubvolumeSnapshot(
|
||||||
ctx, volumeID(pvID.FsSubvolName),
|
ctx, volumeID(pvID.FsSubvolName),
|
||||||
|
Loading…
Reference in New Issue
Block a user