mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-29 17:50:23 +00:00
rbd: use librbd.OpenImageById()
if rbdVol.ImageID
is set
`librbd.OpenImageById()` works if the image is in the trash, so it makes it possible to get the parent of the image. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
b2e69069a0
commit
a228b14200
@ -505,7 +505,14 @@ func (ri *rbdImage) open() (*librbd.Image, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
image, err := librbd.OpenImage(ri.ioctx, ri.RbdImageName, librbd.NoSnapshot)
|
||||
var image *librbd.Image
|
||||
|
||||
// try to open by id, that works for images in trash too
|
||||
if ri.ImageID != "" {
|
||||
image, err = librbd.OpenImageById(ri.ioctx, ri.ImageID, librbd.NoSnapshot)
|
||||
} else {
|
||||
image, err = librbd.OpenImage(ri.ioctx, ri.RbdImageName, librbd.NoSnapshot)
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, librbd.ErrNotFound) {
|
||||
err = util.JoinErrors(ErrImageNotFound, err)
|
||||
|
Loading…
Reference in New Issue
Block a user