[elbe-devel] [PATCH 06/10] initvmaction: fixup the timeout logic
Torben Hohn
torben.hohn at linutronix.de
Thu Apr 1 13:15:28 CEST 2021
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/initvmaction.py | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 246d047ca..ee943193c 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -89,11 +89,29 @@ class InitVMAction:
if not isinstance(verr.args[0], str):
raise
if verr.args[0].startswith('Failed to connect socket to'):
- print("", file=sys.stderr)
- print("Accessing libvirt provider system not possible.", file=sys.stderr)
- print("Make sure that package 'libvirt-daemon-system' is", file=sys.stderr)
- print("installed, and the service is running properly", file=sys.stderr)
- sys.exit(20)
+ retries = 18
+ while retries > 0:
+ retries -= 1
+ time.sleep(10)
+ try:
+ self.conn = libvirt.open("qemu:///system")
+ except libvirt.libvirtError as verr:
+ if not isinstance(verr.args[0], str):
+ raise
+ if verr.args[0].startswith('Failed to connect socket to'):
+ pass
+
+ if self.conn:
+ break
+
+
+ if not self.conn:
+ print("", file=sys.stderr)
+ print("Accessing libvirt provider system not possible.", file=sys.stderr)
+ print("Even after waiting 180 seconds.", file=sys.stderr)
+ print("Make sure that package 'libvirt-daemon-system' is", file=sys.stderr)
+ print("installed, and the service is running properly", file=sys.stderr)
+ sys.exit(20)
elif verr.args[0].startswith('authentication unavailable'):
print("", file=sys.stderr)
--
2.20.1
More information about the elbe-devel
mailing list