mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
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:
parent
4aa53c823e
commit
5a6556c4d4
@ -183,6 +183,8 @@ func (rv *rbdVolume) doSnapClone(ctx context.Context, parentVol *rbdVolume) erro
|
|||||||
|
|
||||||
// generate temp cloned volume
|
// generate temp cloned volume
|
||||||
tempClone := rv.generateTempClone()
|
tempClone := rv.generateTempClone()
|
||||||
|
defer tempClone.Destroy()
|
||||||
|
|
||||||
// snapshot name is same as temporary cloned image, This helps to
|
// snapshot name is same as temporary cloned image, This helps to
|
||||||
// flatten the temporary cloned images as we cannot have more than 510
|
// flatten the temporary cloned images as we cannot have more than 510
|
||||||
// snapshots on an rbd image
|
// snapshots on an rbd image
|
||||||
|
@ -669,6 +669,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
|
|||||||
parentVol := rbdSnap.toVolume()
|
parentVol := rbdSnap.toVolume()
|
||||||
// as we are operating on single cluster reuse the connection
|
// as we are operating on single cluster reuse the connection
|
||||||
parentVol.conn = rbdVol.conn.Copy()
|
parentVol.conn = rbdVol.conn.Copy()
|
||||||
|
defer parentVol.Destroy()
|
||||||
|
|
||||||
// create clone image and delete snapshot
|
// create clone image and delete snapshot
|
||||||
err = rbdVol.cloneRbdImageFromSnapshot(ctx, rbdSnap, parentVol)
|
err = rbdVol.cloneRbdImageFromSnapshot(ctx, rbdSnap, parentVol)
|
||||||
|
@ -1662,6 +1662,7 @@ func (ri *rbdImage) flattenParent(ctx context.Context, hardLimit, softLimit uint
|
|||||||
if parentImage == nil {
|
if parentImage == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
defer parentImage.Destroy()
|
||||||
|
|
||||||
return parentImage.flattenRbdImage(ctx, false, hardLimit, softLimit)
|
return parentImage.flattenRbdImage(ctx, false, hardLimit, softLimit)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user