Fix loop in redis-reconfigure.sh
Fix loop to poll redis nodes.
The following xargs
command was failing due to its input being
a space-delimited string rather than newline-delimited.
echo $hosts | xargs -n1 -I{} ssh "{}.c.${gitlab_project}.internal" ...
Assigning the output of seq
to the $hosts
variable implicitly
flattens its newlines into spaces.
So xargs
passed the whole space-delimited string at once to
ssh
as the target hostname, which of course is invalid.
Resulting error:
kex_exchange_identification: Connection closed by remote host
xargs: ssh: exited with status 255; aborting
This issue may have been an incompatibility between xargs
behavior
on a Mac versus Linux, but at least when run on Linux (specifically
tested with Ubuntu's xargs
4.7.0 from the findutils
package),
by default it expects input to be newline delimited, not space-delimited:
msmiley@neri:~$ xargs --version | head -n1
xargs (GNU findutils) 4.7.0
msmiley@neri:~$ echo 1 2 3 | xargs -I{} -n1 echo "Val: {}"
Val: 1 2 3
msmiley@neri:~$ seq 3 | xargs -I{} -n1 echo "Val: {}"
Val: 1
Val: 2
Val: 3
In this MR, I replaced xargs
with a for
loop.
That is sufficient to avoid the bug, since for
splits words on either
spaces or newlines.
Also, since the $hosts
variable was not used elsewhere, I went ahead and
got rid of it, moving its subcommand directly to the for loop.