#387 make sure qcow2 inventory removes termporary files
Merged 4 years ago by astepano. Opened 4 years ago by bgoncalv.
bgoncalv/standard-test-roles fix-standard-inventory-qcow2  into  master

@@ -141,6 +141,11 @@ 

              logger.info("Closing and removing temporary sparse file '%s'", fullname)

              if os.path.isfile(fullname):

                  drive_file.close()

+                 # just close the file doesn't make sure it gets deleted

+                 try:

+                     os.remove(fullname)

+                 except OSError:

+                     pass

  

  

  def print_bad_inventory():

no initial comment

Commit 966c65d fixes this pull-request

Pull-Request has been merged by astepano

4 years ago

Pull-Request has been merged by astepano

4 years ago

tested using build from https://download.copr.fedorainfracloud.org/results/@osci/standard-test-roles/fedora-31-x86_64/01540353-standard-test-roles/

The provision.fmf is:

standard-inventory-qcow2:
qemu:
    drive:
    - size: 10737418240
    - size: 10737418240
    - size: 10737418240

No temporary file existed after playbook finished.

Running with TEST_DEBUG=1 files got removed after killing the process as informed by the role:

[INFO ] standard-inventory-qcow2: kill 14163 # when finished to debug VM

# kill 14163 
[INFO ] standard-inventory-qcow2: Diagnose ending.
[INFO ] standard-inventory-qcow2: Closing and removing temporary sparse file '/tmp/tmpmmv2hd7y'
[INFO ] standard-inventory-qcow2: Closing and removing temporary sparse file '/tmp/tmpfx52rjz0'
[INFO ] standard-inventory-qcow2: Closing and removing temporary sparse file '/tmp/tmp9ux31jyb'