ctdb-eventscripts: Deleting IPs should use the promote_secondaries option
authorMartin Schwenke <martin@meltin.net>
Tue, 28 Jan 2014 03:41:25 +0000 (14:41 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 13 Feb 2014 01:03:24 +0000 (02:03 +0100)
commit176ae6c704528c021fcc34a41878584f43a00119
tree032f04cae1715a581138d305b2988574e07c2097
parent6a7c420a79cc1258528f152f4de9a0608767729f
ctdb-eventscripts: Deleting IPs should use the promote_secondaries option

If a primary IP address is being deleted from an interface, the
secondaries are remembered and added back after the primary is
deleted.  This is done under a lock shared by the add/del script code.
It is necessary because, by default, Linux deletes secondaries when
the corresponding primary is deleted.

There is a race here between ctdbd and the scripts, since ctdbd
doesn't know about the lock.  If ctdbd receives a release IP control
and the IP address is not on an interface then it is regarded as a
"Redundant release of IP" so no "releaseip" event is generated.  This
can occur if the IP address in question is a secondary that has been
temporarily dropped.  It is more likely if the number of secondaries
is large.

Since Linux 2.6.12 (i.e. 2005) Linux has supported a
promote_secondaries option on interfaces.  This option is currently
undocumented but that will change in Linux 3.14.  With
promote_secondaries enabled the kernel will not drop secondaries but
will promote a corresponding secondary instead.  The kernel does all
necessary locking.

Use promote_secondaries to simplify the code, avoid re-adding
secondaries, avoid re-adding routes and provide improved performance.

This could be done conditionally, with a fallback to legacy
secondary-re-adding code, but no supported Linux distribution is
running a pre-2.6.12 kernel so this is unnecessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events.d/10.interface
ctdb/config/functions