mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-18 02:39:30 +00:00
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 <rar@redhat.com>
(cherry picked from commit c34b31ee05
)
This commit is contained in:
parent
739afa2e67
commit
50639b9dd5
@ -146,6 +146,8 @@ type rbdImage struct {
|
|||||||
|
|
||||||
// Set metadata on volume
|
// Set metadata on volume
|
||||||
EnableMetadata bool
|
EnableMetadata bool
|
||||||
|
// ParentInTrash indicates the parent image is in trash.
|
||||||
|
ParentInTrash bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// rbdVolume represents a CSI volume and its RBD image specifics.
|
// rbdVolume represents a CSI volume and its RBD image specifics.
|
||||||
@ -1613,6 +1615,7 @@ func (ri *rbdImage) getImageInfo() error {
|
|||||||
} else {
|
} else {
|
||||||
ri.ParentName = parentInfo.Image.ImageName
|
ri.ParentName = parentInfo.Image.ImageName
|
||||||
ri.ParentPool = parentInfo.Image.PoolName
|
ri.ParentPool = parentInfo.Image.PoolName
|
||||||
|
ri.ParentInTrash = parentInfo.Image.Trash
|
||||||
}
|
}
|
||||||
// Get image creation time
|
// Get image creation time
|
||||||
tm, err := image.GetCreateTimestamp()
|
tm, err := image.GetCreateTimestamp()
|
||||||
@ -1631,7 +1634,9 @@ func (ri *rbdImage) getParent() (*rbdImage, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user