Commit 9d7e8218 authored by Petr Pudlak's avatar Petr Pudlak

master-up-setup: Ping multiple times with a shorter interval

In the case of network problems, one ping packet can possibly get lost.
Sending multiple packets is safer. The interval between packets is set
to 200ms so that the check finishes faster.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 71b75e7a
......@@ -23,7 +23,8 @@ set -e -u
USAGE_MSG="Usage: $0 {start|stop}"
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
FPING_PACKET_COUNT=1
FPING_PACKET_COUNT=5
FPING_PACKET_INTERVAL_MS=200
# Start the master IP
start() {
......@@ -41,13 +42,15 @@ start() {
esac
# Check if the master IP address is already configured on this machine
if fping -c $FPING_PACKET_COUNT -S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
if fping -c $FPING_PACKET_COUNT -p $FPING_PACKET_INTERVAL_MS \
-S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
echo "Master IP address already configured on this machine. Doing nothing."
exit 0
fi
# Check if the master IP address is already configured on another machine
if fping -c $FPING_PACKET_COUNT $MASTER_IP >/dev/null 2>&1; then
if fping -c $FPING_PACKET_COUNT -p $FPING_PACKET_INTERVAL_MS \
$MASTER_IP >/dev/null 2>&1; then
echo "Error: master IP address configured on another machine." >&2
exit 1
fi
......@@ -68,7 +71,8 @@ stop() {
if ! ip addr show dev $MASTER_NETDEV | \
grep -F " $MASTER_IP/$MASTER_NETMASK" >/dev/null 2>&1; then
# Check if the master IP address is configured on a wrong device
if fping -c $FPING_PACKET_COUNT -S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
if fping -c $FPING_PACKET_COUNT -p $FPING_PACKET_INTERVAL_MS \
-S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
echo "Error: master IP address configured on wrong device," \
"can't shut it down." >&2
exit 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment