I changed the way to check for the master IP on the master node to fping -S
127.0.0.1, and if the master IP is not configured, now there's a check
which looks for the master IP on another node. If it is configured on a
different node, an error is produced.

Interdiff:

diff --git a/tools/master-ip-setup b/tools/master-ip-setup
index d40b4c3..463def6 100755
--- a/tools/master-ip-setup
+++ b/tools/master-ip-setup
@@ -62,10 +62,17 @@ start() {

 # Stop the master IP
 stop() {
-  if ! ip addr show dev $MASTER_NETDEV | \
-        grep -F " $MASTER_IP/$MASTER_NETMASK"  >/dev/null 2>&1; then
-    echo "Master IP address not configured on this machine. Doing nothing."
-    exit 0
+  # Check if the master IP address is still configured on this machine
+  if ! fping -S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
+    # Check if the master IP address is configured on another machine
+    if fping $MASTER_IP >/dev/null 2>&1; then
+      echo "Error: master IP address configured on another machine," \
+           "can't shut it down." >&2
+      exit 1
+    else
+      echo "Master IP address not configured on this machine. Doing
nothing."
+      exit 0
+    fi
   fi

   if ! ip addr del $MASTER_IP/$MASTER_NETMASK dev $MASTER_NETDEV; then


On Wed, May 15, 2013 at 6:40 PM, Guido Trotter <[email protected]> wrote:

>
>
>
> On Wed, May 15, 2013 at 3:46 PM, Bernardo Dal Seno <[email protected]>wrote:
>
>> On 15 May 2013 16:31, Guido Trotter <[email protected]> wrote:
>> >
>> >
>> >
>> > On Wed, May 15, 2013 at 3:19 PM, Thomas Thrainer <[email protected]>
>> > wrote:
>> >>
>> >> Interdiff:
>> >>
>> >> diff --git a/tools/master-ip-setup b/tools/master-ip-setup
>> >> index 1be9fc4..d40b4c3 100755
>> >> --- a/tools/master-ip-setup
>> >> +++ b/tools/master-ip-setup
>> >> @@ -63,7 +63,7 @@ start() {
>> >>  # Stop the master IP
>> >>  stop() {
>> >>    if ! ip addr show dev $MASTER_NETDEV | \
>> >> -        grep "$MASTER_IP/$MASTER_NETMASK"  >/dev/null 2>&1; then
>> >> +        grep -F " $MASTER_IP/$MASTER_NETMASK"  >/dev/null 2>&1; then
>> >>      echo "Master IP address not configured on this machine. Doing
>> >> nothing."
>> >>      exit 0
>> >
>> >
>> > I would like to *also* do the ping, and if the ping succeeds error out
>> (that
>> > is, if it is active on another device, and we can't switch it off).
>>
>> The ping could also succeed if another machine has got the IP address.
>> For that it's better to check all the network interfaces.
>>
>>
> We have a ping with source address 127.0.0.1 that can only succeed
> locally, and one that can detect remote usage too.
> I meant the local-only one.
>
> Thanks,
>
> Guido
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Katherine Stephens

Reply via email to