rbd: flatten image if the depth is not zero

flatten the image if the deep-flatten feature
is present on the images in the chain or if the
images in chain is not zero, as we cannot check
the deep-flatten feature the images which are
in trash.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 67d73cd6e9)
This commit is contained in:
Madhu Rajanna 2021-05-03 16:32:40 +05:30 committed by mergify[bot]
parent 38bd4e613e
commit 5e9f007ffd

View File

@ -238,6 +238,7 @@ func (ns *NodeServer) stageTransaction(ctx context.Context, req *csi.NodeStageVo
var err error var err error
var readOnly bool var readOnly bool
var feature bool var feature bool
var depth uint
var cr *util.Credentials var cr *util.Credentials
cr, err = util.NewUserCredentials(req.GetSecrets()) cr, err = util.NewUserCredentials(req.GetSecrets())
@ -272,7 +273,11 @@ func (ns *NodeServer) stageTransaction(ctx context.Context, req *csi.NodeStageVo
if err != nil { if err != nil {
return transaction, err return transaction, err
} }
if feature { depth, err = volOptions.getCloneDepth(ctx)
if err != nil {
return transaction, err
}
if feature || depth != 0 {
err = volOptions.flattenRbdImage(ctx, cr, true, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth) err = volOptions.flattenRbdImage(ctx, cr, true, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
if err != nil { if err != nil {
return transaction, err return transaction, err