as a rule, when we issue at least one warning, we pause for 10s to give time to the user to read said warning
if we can ping varnish, proceed
if we can't ping:
if -n was given: warn then proceed
if there's no -n:
without any candidate, warn then proceed
there's only one candidate, and we can ping it: override, warn then proceed
there's only one candidate but we can't ping: error out
more than one candidate: list and error our
Read on for example outputs.
If varnishadm ping is successful with the current NAME argument, no
question asked, go for it:
Info: Working directory: /tmp/varnishgather.Z1LTcYva/varnishgather-flamp-20241106-214646
Info: Complete varnishadm command line deduced to:
Task: 1: varnishd -V
...
If pinging failed, there are a few cases:
If NAME was given, or if NAME wasn't given but there's no varnishd
detected, issue a warning, pause a bit, then proceed:
Info: Working directory: /tmp/varnishgather.BBE414gf/varnishgather-flamp-20241106-221201
#######################################################
using: varnishadm ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?
#######################################################
Info: Complete varnishadm command line deduced to:
<PAUSE 10s>
Task: 1: varnishd -V
...
if no NAME was given but there's exactly one candidate, and it's
pingable, override NAME, warn about it, pause then proceed:
Info: Working directory: /tmp/varnishgather.ZeUDcfg7/varnishgather-flamp-20241106-222151
#######################################################
using: varnishadm ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?
There's only one varnishd running and it's pingable.
Overriding -n argument to /tmp/beepboop
#######################################################
<PAUSE 10s>
Info: Complete varnishadm command line deduced to: -n /tmp/beepboop
Task: 1: varnishd -V
...
If no NAME is given, and there's only one candidate but it's not
pingable, just error out:
Info: Working directory: /tmp/varnishgather.eZSa78VU/varnishgather-flamp-20241106-224856
#######################################################
using: varnishadm ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?
#######################################################
<EXIT>
Finally, if there are no given NAME, and we have more than one
candidate, we just propose a list of candidates and error out:
Info: Working directory: /tmp/varnishgather.dkGgfqHe/varnishgather-flamp-20241106-223210
#######################################################
using: varnishadm ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?
We've also detected one or more varnishd that
could possibly be pinged with these -n arguments:
-n /tmp/beepboop
-n /tmp/beepboop2
#######################################################
<EXIT>
@hermunn and @zackmay, tagging you in as you were part of the original discussion.
One Karnaugh map later and I realized that https://github.com/varnish/varnishgather/pull/116#discussion_r1809252878 could have been expressed more simply:
-n
was given: warn then proceed-n
:Read on for example outputs.
If
varnishadm ping
is successful with the current NAME argument, no question asked, go for it:If pinging failed, there are a few cases:
If NAME was given, or if NAME wasn't given but there's no varnishd detected, issue a warning, pause a bit, then proceed:
if no NAME was given but there's exactly one candidate, and it's pingable, override NAME, warn about it, pause then proceed:
If no NAME is given, and there's only one candidate but it's not pingable, just error out:
Finally, if there are no given NAME, and we have more than one candidate, we just propose a list of candidates and error out:
@hermunn and @zackmay, tagging you in as you were part of the original discussion.