rbd: use ListChildrenAttributes() instead of ListChildren()

This commit modifies listSnapAndChildren() to make use of
ListChildrenAttributes() instead of ListChildren() which
allows us to filter out images in trash.
This commit also order the alive images so that temp clone
images are followed by images backing volume snapshots so
that temp clone images are flattened first.

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R
2025-03-10 15:15:45 +05:30
committed by mergify[bot]
parent 355a8fab9f
commit 796e6b6c44
12 changed files with 163 additions and 40 deletions

View File

@ -590,7 +590,7 @@ func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.C
// are more than the `minSnapshotOnImage` Add a task to flatten all the
// temporary cloned images.
func flattenTemporaryClonedImages(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) error {
snaps, children, err := rbdVol.listSnapAndChildren()
snapAndChildrenInfo, err := rbdVol.listSnapAndChildren()
if err != nil {
if errors.Is(err, util.ErrImageNotFound) {
return status.Error(codes.InvalidArgument, err.Error())
@ -598,6 +598,17 @@ func flattenTemporaryClonedImages(ctx context.Context, rbdVol *rbdVolume, cr *ut
return status.Error(codes.Internal, err.Error())
}
children := make([]string, 0)
// order the temp clone images first followed by the volume snapshot
// images so that the temp clone images are flattened first.
// This is done in order to:
// - increase number of snapshots which can be supported for
// changed block tracking(rbd snap diff).
// - favor scalability since multiple PVCs can be restored from same
// volumesnapshot versus just one PVC-PVC clone.
children = append(children, snapAndChildrenInfo.TempCloneChildren...)
children = append(children, snapAndChildrenInfo.VolumeSnapshotChildren...)
snaps := snapAndChildrenInfo.SnapInfoList
if len(snaps) > int(maxSnapshotsOnImage) {
log.DebugLog(