From bfd9cb8655188b6179bd810c050ea2491081b4a7 Mon Sep 17 00:00:00 2001 From: Chris Wedgwood Date: Thu, 31 Aug 2017 17:24:47 +0000 Subject: [PATCH] Wait for libvirtd socket to be available There is a race where the libvirtd.pid file appears but the socket has not (yet) been created; this adds a timeout-loop waiting specifically for the socket. Change-Id: Ib2ede3b8d5c49bc650bf8a64cbffc03444bb2dd0 --- libvirt/templates/bin/_ceph-secret-define.sh.tpl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libvirt/templates/bin/_ceph-secret-define.sh.tpl b/libvirt/templates/bin/_ceph-secret-define.sh.tpl index 783da519dd..b35ef2bd02 100644 --- a/libvirt/templates/bin/_ceph-secret-define.sh.tpl +++ b/libvirt/templates/bin/_ceph-secret-define.sh.tpl @@ -31,7 +31,20 @@ while [[ ! -f /var/run/libvirtd.pid ]]; do let TIMEOUT-=1 sleep 1 else - echo "ERROR: Libvirt did not start in time" + echo "ERROR: Libvirt did not start in time (pid file missing)" + exit 1 + fi +done + +# Even though we see the pid file the socket immediately (this is +# needed for virsh) +TIMEOUT=10 +while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do + if [[ ${TIMEOUT} -gt 0 ]]; then + let TIMEOUT-=1 + sleep 1 + else + echo "ERROR: Libvirt did not start in time (socket missing)" exit 1 fi done