rbd: prevent panic when using rbdImage that is not connected

When an `rbdVolume` or `rbdSnapshot` is not connected with credentials
to the Ceph cluster, operations may try to get the IOContext which then
causes a panic.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2024-09-16 18:24:58 +02:00 committed by mergify[bot]
parent c2cbb25489
commit 05d501a728

View File

@ -468,6 +468,10 @@ func (ri *rbdImage) openIoctx() error {
return nil
}
if ri.conn == nil {
return fmt.Errorf("can not get IOContext of unconnected image %q", ri)
}
ioctx, err := ri.conn.GetIoctx(ri.Pool)
if err != nil {
// GetIoctx() can return util.ErrPoolNotFound