Skip to content

Commit

Permalink
rbd: skip flattening if an image in trash
Browse files Browse the repository at this point in the history
Signed-off-by: Niels de Vos <ndevos@ibm.com>
  • Loading branch information
nixpanic committed Nov 27, 2023
1 parent 4be0051 commit 97bee9f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ func (ri *rbdImage) flattenRbdImage(
_, err = ta.AddFlatten(admin.NewImageSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName))
rbdCephMgrSupported := isCephMgrSupported(ctx, ri.ClusterID, err)
if rbdCephMgrSupported {
if err != nil {
// it is not possible to flatten an image that is in trash (ErrNotFoun)
if err != nil && !errors.Is(err, librbd.ErrNotFound) {
// 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)
if strings.Contains(err.Error(), rbdFlattenNoParent) {
Expand All @@ -850,11 +851,11 @@ func (ri *rbdImage) flattenRbdImage(
log.ErrorLog(ctx, "failed to add task flatten for %s : %v", ri, err)

return err
}
if forceFlatten || depth >= hardlimit {
} else if forceFlatten || depth >= hardlimit {
return fmt.Errorf("%w: flatten is in progress for image %s", ErrFlattenInProgress, ri.RbdImageName)
} else {
log.DebugLog(ctx, "successfully added task to flatten image %q", ri)
}
log.DebugLog(ctx, "successfully added task to flatten image %q", ri)
}
if !rbdCephMgrSupported {
log.ErrorLog(
Expand Down

0 comments on commit 97bee9f

Please sign in to comment.