<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small;color:#000000"><span style="color:rgb(34,34,34)">On Mon, Sep 9, 2019 at 7:02 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Daniel Erez <<a href="mailto:derez@redhat.com" target="_blank">derez@redhat.com</a>><br>
<br>
After invoking transfer_service.finalize, check operation status by<br>
examining DiskStatus. This is done instead of failing after a<br>
predefined timeout regardless the status.<br>
<br>
Bug-Url: <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1680361" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=1680361</a><br>
Signed-off-by: Richard W.M. Jones <<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>><br>
Tested-by: Ilanit Stein <<a href="mailto:istein@redhat.com" target="_blank">istein@redhat.com</a>><br>
---<br>
v2v/rhv-upload-plugin.py | 19 +++++++++++++------<br>
1 file changed, 13 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py<br>
index 9e71021..8f13ce1 100644<br>
--- a/v2v/rhv-upload-plugin.py<br>
+++ b/v2v/rhv-upload-plugin.py<br>
@@ -549,16 +549,23 @@ def close(h):<br>
# waiting for the transfer object to cease to exist, which<br>
# falls through to the exception case and then we can<br>
# continue.<br>
- endt = time.time() + timeout<br>
+ disk_id = <a href="http://disk.id" rel="noreferrer" target="_blank">disk.id</a><br>
+ start = time.time()<br>
try:<br>
while True:<br>
time.sleep(1)<br>
- tmp = transfer_service.get()<br>
- if time.time() > endt:<br>
- raise RuntimeError("timed out waiting for transfer "<br>
- "to finalize")<br>
+ disk_service = h['disk_service']<br>
+ disk = disk_service.get()<br>
+ if disk.status == types.DiskStatus.LOCKED:<br>
+ if time.time() > start + timeout:<br>
+ raise RuntimeError("timed out waiting for transfer "<br>
+ "to finalize")<br>
+ continue<br>
+ if disk.status == types.DiskStatus.OK:<br>
+ debug("finalized after %s seconds" % (time.time() - start))<br>
+ break<br>
except sdk.NotFoundError:<br>
- pass<br>
+ raise RuntimeError("transfer failed: disk %s not found" % disk_id)<br>
<br>
# Write the disk ID file. Only do this on successful completion.<br>
with builtin_open(params['diskid_file'], 'w') as fp:<br>
-- <br>
1.8.3.1<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">Looks good.</div></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">Nir</div></div></div>