#1319 PR merged
: Fix for long wait in dig, when DNS servers are not set.¶
Labels: enhancement
, fixed / solved / done
gozora opened issue at 2017-04-19 15:44:¶
When no DNS server is defined in /etc/resolv.conf, every call to dig
in
990_sysreqs.sh
takes ~18 s to timeout.
In summary, this caused on my SLES12 SP1 with two configured IP
addresses to idle for 3 minutes:
...
2017-04-19 17:24:42 Including rescue/GNU/Linux/990_sysreqs.sh
2017-04-19 17:27:42 Finished running 'rescue' stage in 181 seconds
...
This fix skips call to dig
if no DNS server is defined in
/etc/resolv.conf
V.
schlomo commented at 2017-04-19 16:09:¶
Also, maybe better use has_binary
instead of hash
. And
echo "$PRODUCT $VERSION / $RELEASE_DATE"
instead of calling rear -V
(for which one could also use $SCRIPT_FILE -V
)
As DNS is an external view on the system which is also an external dependency we might want to be careful about depending on it.
BTW, why not simply reduce the timeout and retries:
dig +time=1 +tries=1
? Either we get a quick answer or we skip.
gozora commented at 2017-04-19 16:21:¶
Hi @schlomo
BTW, why not simply reduce the timeout and retries: dig +time=1 +tries=1? Either we get a quick answer or we skip.
Good catch!
With parameters proposed by you, timeout was reduced as well (surprise, surprise :-) ):
...
2017-04-19 18:15:06 Including rescue/GNU/Linux/990_sysreqs.sh
2017-04-19 18:15:17 Finished running 'rescue' stage in 13 seconds
...
Now the question is, which approach is better to implement...
I personally don't care, as both tackle wait time problems pretty good.
@gdha, @jsmeix what is your opinion on this?
V.
gozora commented at 2017-04-19 17:49:¶
I just updated check for nameserver in /etc/resolv.conf to be a bit
simpler.
This of course does not drop idea of @schlomo from
https://github.com/rear/rear/pull/1319#issuecomment-295326197.
jsmeix commented at 2017-04-20 10:57:¶
@gozora
I wonder what the rason behind is why you use
[ $(grep -c '^[[:space:]]*nameserver' /etc/resolv.conf) -gt 0 ]
and not what seems simpler
grep -q '^[[:space:]]*nameserver' /etc/resolv.conf
?
Regarding reducing timeout and retries directly in the 'dig' call:
I would perfer that because the 'grep nameserver'
test looks somewhat indirect and I always like
to avoid issues because of RFC 1925 item 6 (a):
Probably Arch Linux uses /etc/RESOLV.conf
where the current 'grep nameserver' test
would wrongfully fail ;-)
jsmeix commented at 2017-04-20 10:59:¶
For the fun of it just another case where the indirect test fails:
When there is a useless nameserver entry in /etc/resolv.conf
e.g. a nameserver that does not exist or is unaccessible.
gozora commented at 2017-04-20 11:14:¶
@jsmeix
Probably Arch Linux uses /etc/RESOLV.conf
where the current 'grep nameserver' test
would wrongfully fail ;-)
LOL!
Ok, I'll implement idea of @schlomo!
[Export of Github issue for rear/rear.]