[PATCH] v2v: -o rhv-upload: cancel disk transfer on open failure
Make sure to cancel the trasfer in RHV in case of failure during the open/creation of the disk in RHV, so it is automatically removed. --- v2v/rhv-upload-plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py index 57e90484f..51a7f381a 100644 --- a/v2v/rhv-upload-plugin.py +++ b/v2v/rhv-upload-plugin.py @@ -193,12 +193,14 @@ def open(readonly): if transfer.phase != types.ImageTransferPhase.INITIALIZING: break if time.time() > endt: + transfer_service.cancel() raise RuntimeError("timed out waiting for transfer status " "!= INITIALIZING") # Now we have permission to start the transfer. if params['rhv_direct']: if transfer.transfer_url is None: + transfer_service.cancel() raise RuntimeError("direct upload to host not supported, " "requires ovirt-engine >= 4.2 and only works " "when virt-v2v is run within the oVirt/RHV " @@ -225,6 +227,7 @@ def open(readonly): destination_url.port, ) else: + transfer_service.cancel() raise RuntimeError("unknown URL scheme (%s)" % destination_url.scheme) # The first request is to fetch the features of the server. @@ -259,6 +262,7 @@ def open(readonly): pass else: + transfer_service.cancel() raise RuntimeError("could not use OPTIONS request: %d: %s" % (r.status, r.reason)) -- 2.21.0
On Thu, Sep 19, 2019 at 12:38:39PM +0200, Pino Toscano wrote:
Make sure to cancel the trasfer in RHV in case of failure during the open/creation of the disk in RHV, so it is automatically removed. --- v2v/rhv-upload-plugin.py | 4 ++++ 1 file changed, 4 insertions(+)
Makes perfect sense, ACK.
On Thu, Sep 19, 2019 at 12:38:39PM +0200, Pino Toscano wrote:
Make sure to cancel the trasfer in RHV in case of failure during the open/creation of the disk in RHV, so it is automatically removed. --- v2v/rhv-upload-plugin.py | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py index 57e90484f..51a7f381a 100644 --- a/v2v/rhv-upload-plugin.py +++ b/v2v/rhv-upload-plugin.py @@ -193,12 +193,14 @@ def open(readonly): if transfer.phase != types.ImageTransferPhase.INITIALIZING: break if time.time() > endt: + transfer_service.cancel() raise RuntimeError("timed out waiting for transfer status " "!= INITIALIZING")
# Now we have permission to start the transfer. if params['rhv_direct']: if transfer.transfer_url is None: + transfer_service.cancel() raise RuntimeError("direct upload to host not supported, " "requires ovirt-engine >= 4.2 and only works " "when virt-v2v is run within the oVirt/RHV " @@ -225,6 +227,7 @@ def open(readonly): destination_url.port, ) else: + transfer_service.cancel() raise RuntimeError("unknown URL scheme (%s)" % destination_url.scheme)
# The first request is to fetch the features of the server. @@ -259,6 +262,7 @@ def open(readonly): pass
else: + transfer_service.cancel() raise RuntimeError("could not use OPTIONS request: %d: %s" % (r.status, r.reason))
I've no problem with the patch so ACK, but is there not a way to combine all those separate calls into one place somehow? They all seem to originate in one method (.open). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (3)
-
Martin Kletzander -
Pino Toscano -
Richard W.M. Jones