Merge "Fix file descriptors leak which as result disk usage leak produced by wrong use of python tempfile.mkstemp"

This commit is contained in:
Zuul 2018-06-05 12:19:45 +00:00 committed by Gerrit Code Review
commit b3b4555b09
1 changed files with 4 additions and 2 deletions

View File

@ -273,8 +273,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:
@ -371,6 +371,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)