Skip to content

Commit

Permalink
rbd: prevent panic when using rbdImage that is not connected
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nixpanic authored and mergify[bot] committed Sep 18, 2024
1 parent c2cbb25 commit 05d501a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05d501a

Please sign in to comment.