From c34b31ee05d56e7fcf0597f42b7ed5e2913a3cfd Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Fri, 29 Mar 2024 15:26:02 +0530 Subject: [PATCH] rbd: add ParentInTrash parameter in rbdImage struct This commit adds ParentInTrash parameter in rbdImage struct and makes use of it in getParent() function in order to avoid error in case the parent is present but in trash. Signed-off-by: Rakshith R --- internal/rbd/rbd_util.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index fa3f68a77..c8bacc48a 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -116,6 +116,8 @@ type rbdImage struct { ParentName string // Parent Pool is the pool that contains the parent image. ParentPool string + // ParentInTrash indicates the parent image is in trash. + ParentInTrash bool // Cluster name ClusterName string @@ -1615,6 +1617,7 @@ func (ri *rbdImage) getImageInfo() error { } else { ri.ParentName = parentInfo.Image.ImageName ri.ParentPool = parentInfo.Image.PoolName + ri.ParentInTrash = parentInfo.Image.Trash } // Get image creation time tm, err := image.GetCreateTimestamp() @@ -1633,7 +1636,9 @@ func (ri *rbdImage) getParent() (*rbdImage, error) { if err != nil { return nil, err } - if ri.ParentName == "" { + // The image may not have a parent or the parent maybe in trash. + // Return nil in both the cases. + if ri.ParentName == "" || ri.ParentInTrash { return nil, nil }