Skip to content

Commit

Permalink
rbd: add ParentInTrash parameter in rbdImage struct
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Rakshith-R authored and mergify[bot] committed Apr 23, 2024
1 parent 058426d commit c34b31e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit c34b31e

Please sign in to comment.