mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cleanup: use rbdImage.Destroy() for temporary volumes
rbdVolumes can have several resources that get allocated during its usage. Only destroying the IOContext may not be suffiecient and can cause resource leaks. Use rbdVolume.Destroy() when the rbdVolume is not used anymore. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
5c26fbb0d7
commit
bbd24e52f3
@ -493,6 +493,8 @@ func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) er
|
|||||||
func (rv *rbdVolume) getCloneDepth(ctx context.Context) (uint, error) {
|
func (rv *rbdVolume) getCloneDepth(ctx context.Context) (uint, error) {
|
||||||
var depth uint
|
var depth uint
|
||||||
vol := rbdVolume{}
|
vol := rbdVolume{}
|
||||||
|
defer vol.Destroy()
|
||||||
|
|
||||||
vol.Pool = rv.Pool
|
vol.Pool = rv.Pool
|
||||||
vol.Monitors = rv.Monitors
|
vol.Monitors = rv.Monitors
|
||||||
vol.RbdImageName = rv.RbdImageName
|
vol.RbdImageName = rv.RbdImageName
|
||||||
@ -503,9 +505,6 @@ func (rv *rbdVolume) getCloneDepth(ctx context.Context) (uint, error) {
|
|||||||
return depth, err
|
return depth, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
|
||||||
vol.ioctx.Destroy()
|
|
||||||
}()
|
|
||||||
for {
|
for {
|
||||||
if vol.RbdImageName == "" {
|
if vol.RbdImageName == "" {
|
||||||
return depth, nil
|
return depth, nil
|
||||||
@ -662,6 +661,8 @@ func (rv *rbdVolume) hasFeature(feature uint64) bool {
|
|||||||
|
|
||||||
func (rv *rbdVolume) checkImageChainHasFeature(ctx context.Context, feature uint64) (bool, error) {
|
func (rv *rbdVolume) checkImageChainHasFeature(ctx context.Context, feature uint64) (bool, error) {
|
||||||
vol := rbdVolume{}
|
vol := rbdVolume{}
|
||||||
|
defer vol.Destroy()
|
||||||
|
|
||||||
vol.Pool = rv.Pool
|
vol.Pool = rv.Pool
|
||||||
vol.RadosNamespace = rv.RadosNamespace
|
vol.RadosNamespace = rv.RadosNamespace
|
||||||
vol.Monitors = rv.Monitors
|
vol.Monitors = rv.Monitors
|
||||||
@ -672,7 +673,6 @@ func (rv *rbdVolume) checkImageChainHasFeature(ctx context.Context, feature uint
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
defer vol.ioctx.Destroy()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if vol.RbdImageName == "" {
|
if vol.RbdImageName == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user