Skip to content

Commit

Permalink
rbd: free snapshot resources after allocation
Browse files Browse the repository at this point in the history
Not all snapshot objects are free'd correctly after they were allocated.
It is possible that some connections to the Ceph cluster were never
closed. This does not need to be a noticeable problem, as connections
are re-used where possible, but it isn't clean either.

Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic committed Mar 21, 2024
1 parent b09f947 commit 069cc10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ func (cs *ControllerServer) CreateVolume(
if err != nil {
return nil, err
}
if parentVol != nil {
defer parentVol.Destroy()
}
if rbdSnap != nil {
defer rbdSnap.Destroy()
}

found, err := rbdVol.Exists(ctx, parentVol)
if err != nil {
Expand Down Expand Up @@ -642,6 +648,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot(

return status.Error(codes.Internal, err.Error())
}
defer rbdSnap.Destroy()

// update parent name(rbd image name in snapshot)
rbdSnap.RbdImageName = rbdSnap.RbdSnapName
Expand Down Expand Up @@ -1445,6 +1452,7 @@ func (cs *ControllerServer) DeleteSnapshot(

return nil, status.Error(codes.Internal, err.Error())
}
defer rbdSnap.Destroy()

// safeguard against parallel create or delete requests against the same
// name
Expand Down

0 comments on commit 069cc10

Please sign in to comment.