Fix file descriptors leak which as result disk usage leak
produced by wrong use of python tempfile.mkstemp Change-Id: Ia5e015c4d7a838f7e7701e078204e7e9d0d363bb Closes-Bug: 1771928
This commit is contained in:
parent
bd4378a74f
commit
9c411c8828
|
@ -255,8 +255,8 @@ def _sync_glance_image_to_lxd(client, context, image_ref):
|
|||
raise
|
||||
|
||||
try:
|
||||
image_file = tempfile.mkstemp()[1]
|
||||
manifest_file = tempfile.mkstemp()[1]
|
||||
ifd, image_file = tempfile.mkstemp()
|
||||
mfd, manifest_file = tempfile.mkstemp()
|
||||
|
||||
image = IMAGE_API.get(context, image_ref)
|
||||
if image.get('disk_format') not in ACCEPTABLE_IMAGE_FORMATS:
|
||||
|
@ -353,6 +353,8 @@ def _sync_glance_image_to_lxd(client, context, image_ref):
|
|||
image.add_alias(image_ref, '')
|
||||
|
||||
finally:
|
||||
os.close(ifd)
|
||||
os.close(mfd)
|
||||
os.unlink(image_file)
|
||||
os.unlink(manifest_file)
|
||||
|
||||
|
|
Loading…
Reference in New Issue