rbd: close the RBD-image after adding it to a VolumeGroup

When the image is not closed, it keeps a watch open. This prevents the
CSI Controller to delete the Volume, as there is still a user of it.

Fixes: f9ab14e826 "rbd: check if an image is part of a group before adding it"
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2024-10-30 09:47:04 +01:00 committed by mergify[bot]
parent b4592a55eb
commit 6d88e0a4c7

View File

@ -44,6 +44,7 @@ func (rv *rbdVolume) AddToGroup(ctx context.Context, vg types.VolumeGroup) error
if err != nil {
return fmt.Errorf("failed to open image %q: %w", rv, err)
}
defer image.Close()
info, err := image.GetGroup()
if err != nil {