1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-daemon: Deletion of IPs is deferred until the next takeover run

This drastically simplifies the code.  "ctdb reloadips" behaves the
same, since it causes a takeover run immediately after IPs are
deleted.  "ctdb delip" now needs to be followed with an explicit "ctdb
ipreallocate".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2014-01-22 17:12:09 +11:00 committed by Stefan Metzmacher
parent 0a759bc3ff
commit 87b49c913f
9 changed files with 25 additions and 73 deletions

View File

@ -1044,12 +1044,19 @@ DB Statistics: locking.tdb
<refsect2>
<title>delip <parameter>IPADDR</parameter></title>
<para>
This command is used to remove a public ip from a node during runtime.
If this public ip is currently hosted by the node it being removed from, the ip will first be failed over to another node, if possible, before it is removed.
This command flags IPADDR for deletion from a node at runtime.
It should be followed by a <command>ctdb
ipreallocate</command>. If IPADDR is currently hosted by the
node it is being removed from, this ensures that the IP will
first be failed over to another node, if possible, and that it
is then actually removed.
</para>
<para>
Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
If you want this change to be permanent you must also update the public addresses file manually.
Note that this only updates the runtime instance of CTDB. Any
changes will be lost next time CTDB is restarted and the
public addresses file is re-read. If you want this change to
be permanent you must also update the public addresses file
manually.
</para>
</refsect2>

View File

@ -953,8 +953,7 @@ int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb,
int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb,
TDB_DATA indata);
int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
struct ctdb_req_control_old *c,
TDB_DATA recdata, bool *async_reply);
TDB_DATA recdata);
int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb,
struct ctdb_req_control_old *c,

View File

@ -467,8 +467,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
return ctdb_control_add_public_address(ctdb, indata);
case CTDB_CONTROL_DEL_PUBLIC_IP:
return ctdb_control_del_public_address(ctdb, c, indata,
async_reply);
return ctdb_control_del_public_address(ctdb, indata);
case CTDB_CONTROL_GET_CAPABILITIES:
return ctdb_control_get_capabilities(ctdb, outdata);

View File

@ -2718,29 +2718,7 @@ int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA inda
return 0;
}
struct delete_ip_callback_state {
struct ctdb_req_control_old *c;
};
/*
called when releaseip event finishes for del_public_address
*/
static void delete_ip_callback(struct ctdb_context *ctdb,
int32_t status, TDB_DATA data,
const char *errormsg,
void *private_data)
{
struct delete_ip_callback_state *state =
talloc_get_type(private_data, struct delete_ip_callback_state);
/* If release failed then fail. */
ctdb_request_control_reply(ctdb, state->c, NULL, status, errormsg);
talloc_free(private_data);
}
int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
struct ctdb_req_control_old *c,
TDB_DATA indata, bool *async_reply)
int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA indata)
{
struct ctdb_addr_info_old *pub = (struct ctdb_addr_info_old *)indata.dptr;
struct ctdb_vnn *vnn;
@ -2767,49 +2745,13 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
for (vnn=ctdb->vnn;vnn;vnn=vnn->next) {
if (ctdb_same_ip(&vnn->public_address, &pub->addr)) {
if (vnn->pnn == ctdb->pnn) {
struct delete_ip_callback_state *state;
struct ctdb_public_ip *ip;
TDB_DATA data;
int ret;
/* This IP is currently being hosted.
* Defer the deletion until the next
* takeover run. "ctdb reloadips" will
* always cause a takeover run. "ctdb
* delip" will now need an explicit
* "ctdb ipreallocated" afterwards. */
vnn->delete_pending = true;
state = talloc(ctdb,
struct delete_ip_callback_state);
CTDB_NO_MEMORY(ctdb, state);
state->c = c;
ip = talloc(state, struct ctdb_public_ip);
if (ip == NULL) {
DEBUG(DEBUG_ERR,
(__location__ " Out of memory\n"));
talloc_free(state);
return -1;
}
ip->pnn = -1;
ip->addr = pub->addr;
data.dsize = sizeof(struct ctdb_public_ip);
data.dptr = (unsigned char *)ip;
ret = ctdb_daemon_send_control(ctdb,
ctdb_get_pnn(ctdb),
0,
CTDB_CONTROL_RELEASE_IP,
0, 0,
data,
delete_ip_callback,
state);
if (ret == -1) {
DEBUG(DEBUG_ERR,
(__location__ "Unable to send "
"CTDB_CONTROL_RELEASE_IP\n"));
talloc_free(state);
return -1;
}
state->c = talloc_steal(state, c);
*async_reply = true;
} else {
/* This IP is not hosted on the
* current node so just delete it

View File

@ -30,6 +30,7 @@ try_command_on_node $test_node "ip addr show dev $iface | grep -E 'inet6?[[:spac
echo "Attempting to remove ${test_ip} from node ${test_node}."
try_command_on_node $test_node $CTDB delip $test_ip
try_command_on_node $test_node $CTDB ipreallocate
wait_until_ips_are_on_node '!' $test_node $test_ip
timeout=60

View File

@ -26,6 +26,7 @@ get_test_ip_mask_and_iface
echo "Deleting IP $test_ip from all nodes"
delete_ip_from_all_nodes $test_ip
try_command_on_node -v $test_node $CTDB ipreallocate
wait_until_ips_are_on_node '!' $test_node $test_ip
# Debugging...

View File

@ -25,4 +25,5 @@ select_test_node_and_ips
echo "Deleting IP ${test_ip} from node ${test_node}"
try_command_on_node $test_node $CTDB delip $test_ip
try_command_on_node $test_node $CTDB ipreallocate
wait_until_ips_are_on_node '!' $test_node $test_ip

View File

@ -48,6 +48,7 @@ for i in $ifaces ; do
echo " $ip"
try_command_on_node $test_node "$CTDB delip $ip"
done
try_command_on_node $test_node "$CTDB ipreallocate"
try_command_on_node $test_node "$CTDB ifaces -X"
info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out")

View File

@ -31,6 +31,7 @@ get_test_ip_mask_and_iface
echo "Deleting IP $test_ip from all nodes"
delete_ip_from_all_nodes $test_ip
try_command_on_node -v $test_node $CTDB ipreallocate
wait_until_ips_are_on_node ! $test_node $test_ip
try_command_on_node -v all $CTDB ip