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