From ff341481eb397d700c346d27c8a23f9732028e03 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sat, 6 Apr 2024 00:21:19 +0300 Subject: [PATCH] -o rhv-upload: Improve host id logging This log[1] is proved confusing for developers: cannot read /etc/vdsm/vdsm.id, using any host: [Errno 2] No such file or directory: '/etc/vdsm/vdsm.id' This is actually a debug message, that can help RHV developers to understand where virt-v2v was running. To make this more clear, in the expected case when running on non-oVirt host, we log now: not an oVirt host, using non-oVirt host For any other error, we can degrade to remote transfer, but we want to warn the user about this, so we log: warning: cannot read host id, using non-oVirt host: [Errno 2] No such file or directory: '/etc/vdsm/vdsm.id' [1] https://github.com/libguestfs/virt-v2v/issues/46#issuecomment-2039604719 RWMJ: Changed "any host" to "non-oVirt host" to make it clearer. --- output/rhv-upload-transfer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/output/rhv-upload-transfer.py b/output/rhv-upload-transfer.py index 349e0f59..ed96153b 100644 --- a/output/rhv-upload-transfer.py +++ b/output/rhv-upload-transfer.py @@ -43,9 +43,13 @@ def find_host(connection): try: with open("/etc/vdsm/vdsm.id") as f: vdsm_id = f.readline().strip() + except FileNotFoundError: + # Expected condition when running on non-oVirt host. + debug("not an oVirt host, using non-oVirt host") + return None except Exception as e: - # This is most likely not an oVirt host. - debug("cannot read /etc/vdsm/vdsm.id, not running on an ovirt host [this is not an error]: original exception: %s" % e) + # Unexpected but we can degrade to remote transfer. + debug(f"warning: cannot read host id, using non-oVirt host: {e}") return None debug("hw_id = %r" % vdsm_id)