createhdds: use temp file correctly when uploading
ClosedPublic

Authored by adamwill on Mar 19 2016, 12:11 AM.

Details

Summary

With the previous code, the temporary file wasn't closed before
we try to upload its contents to the disk image. This seems to
cause problems when run in Python 2; the file is truncated on
upload. So rejig things a bit so we use tempfile.mkstemp, close
the file after writing to it, then remove it ourselves after
doing the upload. Tested with Python 2 and Python 3 that this
creates a correct image.

If something goes wrong at the wrong time the temp file will
be left around, but hey, it's a temp file - they get cleaned
up on system shutdown. So doesn't seem like a big deal.

Test Plan

Check building the two images that involve a file
upload in both Python 2 and Python 3, make sure the file is
complete and correct in all cases.

Diff Detail

Repository
rOPENQA fedora_openqa
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
adamwill retitled this revision from to createhdds: use temp file correctly when uploading.Mar 19 2016, 12:11 AM
adamwill updated this object.
adamwill edited the test plan for this revision. (Show Details)
adamwill added reviewers: jskladan, garretraziel.
adamwill updated this revision to Diff 2007.Mar 19 2016, 9:26 PM

call gfs.shutdown() as well as gfs.close() (per rwmj)

see https://bugzilla.redhat.com/show_bug.cgi?id=1319347#c6

garretraziel accepted this revision.Mar 21 2016, 1:49 PM

Works OK.

This revision is now accepted and ready to land.Mar 21 2016, 1:49 PM
This revision was automatically updated to reflect the committed changes.