<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small;color:#000000"><span style="color:rgb(34,34,34)">On Sun, Mar 17, 2019 at 3:51 PM Daniel Erez <<a href="mailto:derez@redhat.com">derez@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">After invoking transfer_service.finalize, check operation<br>
status by examining DiskStatus.<br>
This is done instead of failing after a predefined timeout<br>
regardless the status.<br>
<br>
* not verified *<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>
---<br>
v2v/rhv-upload-plugin.py | 18 +++++++++++++-----<br>
1 file changed, 13 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py<br>
index 2a950c5ed..6f65e034b 100644<br>
--- a/v2v/rhv-upload-plugin.py<br>
+++ b/v2v/rhv-upload-plugin.py<br>
@@ -523,15 +523,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></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">We can clean this a little bit by doing this outside of the loop.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ 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>
+ debug("transfer finalize failed for disk: %s", disk_id)<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">This should explain the failure:</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)"> "transfer failed: disk %s not found"</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
pass<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">This should be a failure now.</div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)"><span style="color:rgb(34,34,34)"> </span><br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
# Write the disk ID file. Only do this on successful completion.<br>
--<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">Waiting only for the disk is much nicer.</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>