v2v: rhv-upload-plugin - improve wait logic after finalize (RHBZ#1680361)

After invoking transfer_service.finalize, check operation status by
examining DiskStatus.  This is done instead of failing after a
predefined timeout regardless the status.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1680361
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Ilanit Stein <istein@redhat.com>
This commit is contained in:
Daniel Erez
2019-03-18 18:51:26 +02:00
committed by Richard W.M. Jones
parent d58c4e79d8
commit eeabb3fdc7

View File

@@ -523,16 +523,23 @@ def close(h):
# waiting for the transfer object to cease to exist, which
# falls through to the exception case and then we can
# continue.
endt = time.time() + timeout
disk_id = disk.id
start = time.time()
try:
while True:
time.sleep(1)
tmp = transfer_service.get()
if time.time() > endt:
raise RuntimeError("timed out waiting for transfer "
"to finalize")
disk_service = h['disk_service']
disk = disk_service.get()
if disk.status == types.DiskStatus.LOCKED:
if time.time() > start + timeout:
raise RuntimeError("timed out waiting for transfer "
"to finalize")
continue
if disk.status == types.DiskStatus.OK:
debug("finalized after %s seconds" % (time.time() - start))
break
except sdk.NotFoundError:
pass
raise RuntimeError("transfer failed: disk %s not found" % disk_id)
# Write the disk ID file. Only do this on successful completion.
with builtins.open(params['diskid_file'], 'w') as fp: