Re: [libvirt] [PATCH v2 1/1] tools: do not loop in libvirt-guests test_connect
On Mon, Dec 16, 2019 at 08:20:59AM +0100, Christian Ehrhardt wrote: > These days libvirt is pretty reliable and even remote connections > (not the default for libvirt-guests anyway) either work or fail but are > uncommon to be flaky. > > On the other hand users might have disabled the service and while we are > After=libvirtd for ordering we are not Requiring it. Adding that or any > harder dependency might break our ordering. But if people have disabled > libvirt they will do a full retry loop until timeout. > > Lets drop the loop to be much faster if a remote is not reachable. > > Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1854653 I extended this to add: This reverts commit 4e7fc8305a53676ba2362bfaa8ca05c4851b7e12 Author: Michal Prívozník Date: Fri Feb 21 12:46:08 2014 +0100 libvirt-guests: Wait for libvirtd to initialize The race described in that commit no longer exists using systemd as we now have socket activation. If not using systemd, then it is also safe if using the libvirtd --daemon flag, since the parent process won't return to the caller until the child is accepting connections. and have now pushed this fix. > > Reported-by: Doug Smythies > Signed-off-by: Christian Ehrhardt > --- > tools/libvirt-guests.sh.in | 21 ++--- > 1 file changed, 6 insertions(+), 15 deletions(-) Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/1] tools: do not loop in libvirt-guests test_connect
These days libvirt is pretty reliable and even remote connections (not the default for libvirt-guests anyway) either work or fail but are uncommon to be flaky. On the other hand users might have disabled the service and while we are After=libvirtd for ordering we are not Requiring it. Adding that or any harder dependency might break our ordering. But if people have disabled libvirt they will do a full retry loop until timeout. Lets drop the loop to be much faster if a remote is not reachable. Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1854653 Reported-by: Doug Smythies Signed-off-by: Christian Ehrhardt --- tools/libvirt-guests.sh.in | 21 ++--- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index 4bc6e866f0..a881f6266e 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -37,8 +37,6 @@ SHUTDOWN_TIMEOUT=300 PARALLEL_SHUTDOWN=0 START_DELAY=0 BYPASS_CACHE=0 -CONNECT_RETRIES=10 -RETRIES_SLEEP=1 SYNC_TIME=0 test -f "$sysconfdir"/sysconfig/libvirt-guests && @@ -90,19 +88,12 @@ test_connect() { uri=$1 -i=${CONNECT_RETRIES} -while [ $i -gt 0 ]; do -run_virsh "$uri" connect 2>/dev/null -if [ $? -eq 0 ]; then -return 0; -fi -sleep ${RETRIES_SLEEP} -eval_gettext "Unable to connect to libvirt currently. Retrying .. \$i" -i=$(($i-1)) -done -eval_gettext "Can't connect to \$uri. Skipping." -echo -return 1 +if run_virsh "$uri" connect 2>/dev/null; then +return 0; +else +eval_gettext "Can't connect to \$uri. Skipping." +return 1 +fi } # list_guests URI PERSISTENT -- 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list