|
|
da373f |
From 1a601b248f347b2237ff458376a010eeb46d005d Mon Sep 17 00:00:00 2001
|
|
|
3efd08 |
From: Daniel Erez <derez@redhat.com>
|
|
|
3efd08 |
Date: Mon, 18 Mar 2019 18:51:26 +0200
|
|
|
3efd08 |
Subject: [PATCH] v2v: rhv-upload-plugin - improve wait logic after finalize
|
|
|
3efd08 |
(RHBZ#1680361)
|
|
|
3efd08 |
|
|
|
3efd08 |
After invoking transfer_service.finalize, check operation status by
|
|
|
3efd08 |
examining DiskStatus. This is done instead of failing after a
|
|
|
3efd08 |
predefined timeout regardless the status.
|
|
|
3efd08 |
|
|
|
3efd08 |
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1680361
|
|
|
3efd08 |
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
3efd08 |
Tested-by: Ilanit Stein <istein@redhat.com>
|
|
|
3efd08 |
(cherry picked from commit eeabb3fdc7756887b53106f455a7b54309130637)
|
|
|
3efd08 |
---
|
|
|
3efd08 |
v2v/rhv-upload-plugin.py | 19 +++++++++++++------
|
|
|
3efd08 |
1 file changed, 13 insertions(+), 6 deletions(-)
|
|
|
3efd08 |
|
|
|
3efd08 |
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
|
|
|
3efd08 |
index 2a950c5ed..4d61a089b 100644
|
|
|
3efd08 |
--- a/v2v/rhv-upload-plugin.py
|
|
|
3efd08 |
+++ b/v2v/rhv-upload-plugin.py
|
|
|
3efd08 |
@@ -523,16 +523,23 @@ def close(h):
|
|
|
3efd08 |
# waiting for the transfer object to cease to exist, which
|
|
|
3efd08 |
# falls through to the exception case and then we can
|
|
|
3efd08 |
# continue.
|
|
|
3efd08 |
- endt = time.time() + timeout
|
|
|
3efd08 |
+ disk_id = disk.id
|
|
|
3efd08 |
+ start = time.time()
|
|
|
3efd08 |
try:
|
|
|
3efd08 |
while True:
|
|
|
3efd08 |
time.sleep(1)
|
|
|
3efd08 |
- tmp = transfer_service.get()
|
|
|
3efd08 |
- if time.time() > endt:
|
|
|
3efd08 |
- raise RuntimeError("timed out waiting for transfer "
|
|
|
3efd08 |
- "to finalize")
|
|
|
3efd08 |
+ disk_service = h['disk_service']
|
|
|
3efd08 |
+ disk = disk_service.get()
|
|
|
3efd08 |
+ if disk.status == types.DiskStatus.LOCKED:
|
|
|
3efd08 |
+ if time.time() > start + timeout:
|
|
|
3efd08 |
+ raise RuntimeError("timed out waiting for transfer "
|
|
|
3efd08 |
+ "to finalize")
|
|
|
3efd08 |
+ continue
|
|
|
3efd08 |
+ if disk.status == types.DiskStatus.OK:
|
|
|
3efd08 |
+ debug("finalized after %s seconds" % (time.time() - start))
|
|
|
3efd08 |
+ break
|
|
|
3efd08 |
except sdk.NotFoundError:
|
|
|
3efd08 |
- pass
|
|
|
3efd08 |
+ raise RuntimeError("transfer failed: disk %s not found" % disk_id)
|
|
|
3efd08 |
|
|
|
3efd08 |
# Write the disk ID file. Only do this on successful completion.
|
|
|
3efd08 |
with builtins.open(params['diskid_file'], 'w') as fp:
|
|
|
3efd08 |
--
|
|
|
da373f |
2.18.4
|
|
|
3efd08 |
|