cleanup: destroy connections after .Copy() an other one

Everytime a connection is copied with the .Copy() function, it needs to
be destroyed once the object is not needed anymore. This was not done
consistently, a few more locations require the freeing of the connection
resources.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2024-03-29 13:32:02 +01:00
committed by mergify[bot]
parent 4aa53c823e
commit 5a6556c4d4
3 changed files with 4 additions and 0 deletions

View File

@ -669,6 +669,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
parentVol := rbdSnap.toVolume()
// as we are operating on single cluster reuse the connection
parentVol.conn = rbdVol.conn.Copy()
defer parentVol.Destroy()
// create clone image and delete snapshot
err = rbdVol.cloneRbdImageFromSnapshot(ctx, rbdSnap, parentVol)