mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
cephfs: getVolumeRootPathCeph and purgeVolume use new error strings
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
1f4839cb5e
commit
20c90ddfc4
@ -75,8 +75,7 @@ func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, cr *u
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf(util.Log(ctx, "failed to get the rootpath for the vol %s(%s) stdError %s"), string(volID), err, stderr)
|
klog.Errorf(util.Log(ctx, "failed to get the rootpath for the vol %s(%s) stdError %s"), string(volID), err, stderr)
|
||||||
|
if strings.Contains(stderr, ErrVolumeNotFound.Error()) {
|
||||||
if strings.HasPrefix(stderr, errNotFoundString) {
|
|
||||||
return "", util.JoinErrors(ErrVolumeNotFound, err)
|
return "", util.JoinErrors(ErrVolumeNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +196,6 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede
|
|||||||
if _, keyPresent = clusterAdditionalInfo[volOptions.ClusterID]; !keyPresent {
|
if _, keyPresent = clusterAdditionalInfo[volOptions.ClusterID]; !keyPresent {
|
||||||
clusterAdditionalInfo[volOptions.ClusterID] = &localClusterState{}
|
clusterAdditionalInfo[volOptions.ClusterID] = &localClusterState{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize subvolume when either it's supported, or when corresponding
|
// resize subvolume when either it's supported, or when corresponding
|
||||||
// clusterID key was not present.
|
// clusterID key was not present.
|
||||||
if clusterAdditionalInfo[volOptions.ClusterID].resizeSupported || !keyPresent {
|
if clusterAdditionalInfo[volOptions.ClusterID].resizeSupported || !keyPresent {
|
||||||
@ -226,7 +224,7 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Incase the error is other than invalid command return error to the caller.
|
// Incase the error is other than invalid command return error to the caller.
|
||||||
if !strings.Contains(err.Error(), inValidCommmand) {
|
if !strings.Contains(err.Error(), ErrInvalidCommand.Error()) {
|
||||||
klog.Errorf(util.Log(ctx, "failed to resize subvolume %s(%s) in fs %s"), string(volID), err, volOptions.FsName)
|
klog.Errorf(util.Log(ctx, "failed to resize subvolume %s(%s) in fs %s"), string(volID), err, volOptions.FsName)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -235,10 +233,8 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede
|
|||||||
return createVolume(ctx, volOptions, cr, volID, bytesQuota)
|
return createVolume(ctx, volOptions, cr, volID, bytesQuota)
|
||||||
}
|
}
|
||||||
|
|
||||||
func purgeVolume(ctx context.Context, volID volumeID, cr *util.Credentials, volOptions *volumeOptions) error {
|
func purgeVolume(ctx context.Context, volID volumeID, cr *util.Credentials, volOptions *volumeOptions, force bool) error {
|
||||||
err := execCommandErr(
|
arg := []string{
|
||||||
ctx,
|
|
||||||
"ceph",
|
|
||||||
"fs",
|
"fs",
|
||||||
"subvolume",
|
"subvolume",
|
||||||
"rm",
|
"rm",
|
||||||
@ -248,15 +244,19 @@ func purgeVolume(ctx context.Context, volID volumeID, cr *util.Credentials, volO
|
|||||||
volOptions.SubvolumeGroup,
|
volOptions.SubvolumeGroup,
|
||||||
"-m", volOptions.Monitors,
|
"-m", volOptions.Monitors,
|
||||||
"-c", util.CephConfigPath,
|
"-c", util.CephConfigPath,
|
||||||
"-n", cephEntityClientPrefix+cr.ID,
|
"-n", cephEntityClientPrefix + cr.ID,
|
||||||
"--keyfile="+cr.KeyFile)
|
"--keyfile=" + cr.KeyFile,
|
||||||
|
}
|
||||||
|
if force {
|
||||||
|
arg = append(arg, "--force")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := execCommandErr(ctx, "ceph", arg...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf(util.Log(ctx, "failed to purge subvolume %s(%s) in fs %s"), string(volID), err, volOptions.FsName)
|
klog.Errorf(util.Log(ctx, "failed to purge subvolume %s(%s) in fs %s"), string(volID), err, volOptions.FsName)
|
||||||
|
if strings.HasPrefix(err.Error(), ErrVolumeNotFound.Error()) {
|
||||||
if strings.HasPrefix(err.Error(), errNotFoundString) {
|
|
||||||
return util.JoinErrors(ErrVolumeNotFound, err)
|
return util.JoinErrors(ErrVolumeNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user