mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-03 03:30:19 +00:00
rbd: skip flattening if an image in trash
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
b872914a6e
commit
c21cba2c52
@ -841,7 +841,9 @@ func (ri *rbdImage) flattenRbdImage(
|
|||||||
_, err = ta.AddFlatten(admin.NewImageSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName))
|
_, err = ta.AddFlatten(admin.NewImageSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName))
|
||||||
rbdCephMgrSupported := isCephMgrSupported(ctx, ri.ClusterID, err)
|
rbdCephMgrSupported := isCephMgrSupported(ctx, ri.ClusterID, err)
|
||||||
if rbdCephMgrSupported {
|
if rbdCephMgrSupported {
|
||||||
if err != nil {
|
// it is not possible to flatten an image that is in trash (ErrNotFoun)
|
||||||
|
switch {
|
||||||
|
case err != nil && !errors.Is(err, librbd.ErrNotFound):
|
||||||
// discard flattening error if the image does not have any parent
|
// discard flattening error if the image does not have any parent
|
||||||
rbdFlattenNoParent := fmt.Sprintf("Image %s/%s does not have a parent", ri.Pool, ri.RbdImageName)
|
rbdFlattenNoParent := fmt.Sprintf("Image %s/%s does not have a parent", ri.Pool, ri.RbdImageName)
|
||||||
if strings.Contains(err.Error(), rbdFlattenNoParent) {
|
if strings.Contains(err.Error(), rbdFlattenNoParent) {
|
||||||
@ -850,12 +852,12 @@ func (ri *rbdImage) flattenRbdImage(
|
|||||||
log.ErrorLog(ctx, "failed to add task flatten for %s : %v", ri, err)
|
log.ErrorLog(ctx, "failed to add task flatten for %s : %v", ri, err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
case forceFlatten || depth >= hardlimit:
|
||||||
if forceFlatten || depth >= hardlimit {
|
|
||||||
return fmt.Errorf("%w: flatten is in progress for image %s", ErrFlattenInProgress, ri.RbdImageName)
|
return fmt.Errorf("%w: flatten is in progress for image %s", ErrFlattenInProgress, ri.RbdImageName)
|
||||||
}
|
default:
|
||||||
log.DebugLog(ctx, "successfully added task to flatten image %q", ri)
|
log.DebugLog(ctx, "successfully added task to flatten image %q", ri)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !rbdCephMgrSupported {
|
if !rbdCephMgrSupported {
|
||||||
log.ErrorLog(
|
log.ErrorLog(
|
||||||
ctx,
|
ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user