|
|
97ae69 |
From 7ed4c98bd7ee8148ce48b0fbc2af3a64de1aaae9 Mon Sep 17 00:00:00 2001
|
|
|
97ae69 |
From: Nir Soffer <nirsof@gmail.com>
|
|
|
97ae69 |
Date: Sat, 30 Jun 2018 01:21:50 +0300
|
|
|
97ae69 |
Subject: [PATCH] v2v: rhv-upload-plugin: Improve error handling
|
|
|
97ae69 |
|
|
|
97ae69 |
When optimizing the connection using unix socket, we handle these cases:
|
|
|
97ae69 |
|
|
|
97ae69 |
- The local host is not an oVirt host (no /etc/vdsm/vdsm.id).
|
|
|
97ae69 |
- The local host is an oVirt host, but is not registered with engine.
|
|
|
97ae69 |
- Creating UnixHTTPConnection() fails. Unlikely and probably a bug in
|
|
|
97ae69 |
the plugin, but we can recover by using the https connection.
|
|
|
97ae69 |
|
|
|
97ae69 |
The current code handle these cases silently, making it harder to
|
|
|
97ae69 |
understand why the unix socket optimization did no happen. Add debug
|
|
|
97ae69 |
message to make this clear.
|
|
|
97ae69 |
|
|
|
97ae69 |
Also comment in the error handler why we take this path instead of
|
|
|
97ae69 |
failing the operation.
|
|
|
97ae69 |
|
|
|
97ae69 |
(cherry picked from commit f5442d2f044b398efc992fb4d56c8d3096c781e6)
|
|
|
97ae69 |
---
|
|
|
97ae69 |
v2v/rhv-upload-plugin.py | 12 ++++++++++--
|
|
|
97ae69 |
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
97ae69 |
|
|
|
97ae69 |
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
|
|
|
97ae69 |
index f404bd758..8e4052048 100644
|
|
|
97ae69 |
--- a/v2v/rhv-upload-plugin.py
|
|
|
97ae69 |
+++ b/v2v/rhv-upload-plugin.py
|
|
|
97ae69 |
@@ -63,7 +63,10 @@ def find_host(connection):
|
|
|
97ae69 |
with builtins.open("/etc/vdsm/vdsm.id") as f:
|
|
|
97ae69 |
vdsm_id = f.readline().strip()
|
|
|
97ae69 |
except Exception as e:
|
|
|
97ae69 |
+ # This is most likely not an oVirt host.
|
|
|
97ae69 |
+ debug("cannot read /etc/vdsm/vdsm.id, using any host: %s" % e)
|
|
|
97ae69 |
return None
|
|
|
97ae69 |
+
|
|
|
97ae69 |
debug("hw_id = %r" % vdsm_id)
|
|
|
97ae69 |
|
|
|
97ae69 |
hosts_service = connection.system_service().hosts_service()
|
|
|
97ae69 |
@@ -72,6 +75,8 @@ def find_host(connection):
|
|
|
97ae69 |
case_sensitive=False,
|
|
|
97ae69 |
)
|
|
|
97ae69 |
if len(hosts) == 0:
|
|
|
97ae69 |
+ # This oVirt host is not registered with engine.
|
|
|
97ae69 |
+ debug("cannot find host with hw_id=%r, using any host" % vdsm_id)
|
|
|
97ae69 |
return None
|
|
|
97ae69 |
|
|
|
97ae69 |
host = hosts[0]
|
|
|
97ae69 |
@@ -233,9 +238,12 @@ def open(readonly):
|
|
|
97ae69 |
if host is not None and unix_socket is not None:
|
|
|
97ae69 |
try:
|
|
|
97ae69 |
http = UnixHTTPConnection(unix_socket)
|
|
|
97ae69 |
+ except Exception as e:
|
|
|
97ae69 |
+ # Very unlikely failure, but we can recover by using the https
|
|
|
97ae69 |
+ # connection.
|
|
|
97ae69 |
+ debug("cannot create unix socket connection, using https: %s" % e)
|
|
|
97ae69 |
+ else:
|
|
|
97ae69 |
debug("optimizing connection using unix socket %r" % unix_socket)
|
|
|
97ae69 |
- except:
|
|
|
97ae69 |
- pass
|
|
|
97ae69 |
|
|
|
97ae69 |
# Save everything we need to make requests in the handle.
|
|
|
97ae69 |
return {
|
|
|
97ae69 |
--
|
|
|
c71420 |
2.20.1
|
|
|
97ae69 |
|