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