[elbe-devel] [PATCH 06/10] initvmaction: fixup the timeout logic

Bastian Germann bage at linutronix.de
Thu Apr 1 18:23:00 CEST 2021


Am 01.04.21 um 13:15 schrieb Torben Hohn:
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

Reviewed-by: Bastian Germann <bage 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)
> 


More information about the elbe-devel mailing list