mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-takeover: NoIPTakeover is global across cluster
Instead of gathering the value from all nodes, just use the value on the recovery master and have it affect all nodes. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
c4eab456ab
commit
9b456bc730
@ -1373,16 +1373,9 @@ static bool set_ipflags(struct ctdb_context *ctdb,
|
||||
struct ipalloc_state *ipalloc_state,
|
||||
struct ctdb_node_map_old *nodemap)
|
||||
{
|
||||
uint32_t *tval_noiptakeover;
|
||||
uint32_t *tval_noiphostonalldisabled;
|
||||
struct ctdb_node_map *new;
|
||||
|
||||
tval_noiptakeover = get_tunable_from_nodes(ctdb, ipalloc_state, nodemap,
|
||||
"NoIPTakeover", 0);
|
||||
if (tval_noiptakeover == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tval_noiphostonalldisabled =
|
||||
get_tunable_from_nodes(ctdb, ipalloc_state, nodemap,
|
||||
"NoIPHostOnAllDisabled", 0);
|
||||
@ -1397,10 +1390,8 @@ static bool set_ipflags(struct ctdb_context *ctdb,
|
||||
}
|
||||
|
||||
ipalloc_set_node_flags(ipalloc_state, new,
|
||||
tval_noiptakeover,
|
||||
tval_noiphostonalldisabled);
|
||||
|
||||
talloc_free(tval_noiptakeover);
|
||||
talloc_free(tval_noiphostonalldisabled);
|
||||
talloc_free(new);
|
||||
|
||||
@ -1573,6 +1564,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
|
||||
|
||||
ipalloc_state = ipalloc_state_init(tmp_ctx, ctdb->num_nodes,
|
||||
determine_algorithm(&ctdb->tunable),
|
||||
(ctdb->tunable.no_ip_takeover != 0),
|
||||
(ctdb->tunable.no_ip_failback != 0),
|
||||
force_rebalance_nodes);
|
||||
if (ipalloc_state == NULL) {
|
||||
|
@ -38,6 +38,7 @@ struct ipalloc_state *
|
||||
ipalloc_state_init(TALLOC_CTX *mem_ctx,
|
||||
uint32_t num_nodes,
|
||||
enum ipalloc_algorithm algorithm,
|
||||
bool no_ip_takeover,
|
||||
bool no_ip_failback,
|
||||
uint32_t *force_rebalance_nodes)
|
||||
{
|
||||
@ -50,14 +51,6 @@ ipalloc_state_init(TALLOC_CTX *mem_ctx,
|
||||
|
||||
ipalloc_state->num = num_nodes;
|
||||
|
||||
ipalloc_state->noiptakeover =
|
||||
talloc_zero_array(ipalloc_state,
|
||||
bool,
|
||||
ipalloc_state->num);
|
||||
if (ipalloc_state->noiptakeover == NULL) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
|
||||
goto fail;
|
||||
}
|
||||
ipalloc_state->noiphost =
|
||||
talloc_zero_array(ipalloc_state,
|
||||
bool,
|
||||
@ -68,6 +61,7 @@ ipalloc_state_init(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
ipalloc_state->algorithm = algorithm;
|
||||
ipalloc_state->no_ip_takeover = no_ip_takeover;
|
||||
ipalloc_state->no_ip_failback = no_ip_failback;
|
||||
ipalloc_state->force_rebalance_nodes = force_rebalance_nodes;
|
||||
|
||||
@ -210,7 +204,6 @@ static bool all_nodes_are_disabled(struct ctdb_node_map *nodemap)
|
||||
|
||||
/* Set internal flags for IP allocation:
|
||||
* Clear ip flags
|
||||
* Set NOIPTAKOVER ip flags from per-node NoIPTakeover tunable
|
||||
* Set NOIPHOST ip flag for each INACTIVE node
|
||||
* if all nodes are disabled:
|
||||
* Set NOIPHOST ip flags from per-node NoIPHostOnAllDisabled tunable
|
||||
@ -219,17 +212,11 @@ static bool all_nodes_are_disabled(struct ctdb_node_map *nodemap)
|
||||
*/
|
||||
void ipalloc_set_node_flags(struct ipalloc_state *ipalloc_state,
|
||||
struct ctdb_node_map *nodemap,
|
||||
uint32_t *tval_noiptakeover,
|
||||
uint32_t *tval_noiphostonalldisabled)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<nodemap->num;i++) {
|
||||
/* Can not take IPs on node with NoIPTakeover set */
|
||||
if (tval_noiptakeover[i] != 0) {
|
||||
ipalloc_state->noiptakeover[i] = true;
|
||||
}
|
||||
|
||||
/* Can not host IPs on INACTIVE node */
|
||||
if (nodemap->node[i].flags & NODE_FLAGS_INACTIVE) {
|
||||
ipalloc_state->noiphost[i] = true;
|
||||
|
@ -49,12 +49,12 @@ struct ipalloc_state;
|
||||
struct ipalloc_state * ipalloc_state_init(TALLOC_CTX *mem_ctx,
|
||||
uint32_t num_nodes,
|
||||
enum ipalloc_algorithm algorithm,
|
||||
bool no_ip_takeover,
|
||||
bool no_ip_failback,
|
||||
uint32_t *force_rebalance_nodes);
|
||||
|
||||
void ipalloc_set_node_flags(struct ipalloc_state *ipalloc_state,
|
||||
struct ctdb_node_map *nodemap,
|
||||
uint32_t *tval_noiptakeover,
|
||||
uint32_t *tval_noiphostonalldisabled);
|
||||
|
||||
void ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
|
||||
|
@ -72,7 +72,7 @@ bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
|
||||
int32_t pnn,
|
||||
struct public_ip_list *ip)
|
||||
{
|
||||
if (ipalloc_state->noiptakeover[pnn]) {
|
||||
if (ipalloc_state->no_ip_takeover) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ struct ipalloc_state {
|
||||
/* Arrays with data for each node */
|
||||
struct ctdb_public_ip_list *available_public_ips;
|
||||
struct ctdb_public_ip_list *known_public_ips;
|
||||
bool *noiptakeover;
|
||||
bool *noiphost;
|
||||
|
||||
struct public_ip_list *all_ips;
|
||||
enum ipalloc_algorithm algorithm;
|
||||
bool no_ip_failback;
|
||||
bool no_ip_takeover;
|
||||
uint32_t *force_rebalance_nodes;
|
||||
};
|
||||
|
||||
|
@ -51,8 +51,8 @@ num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
|
||||
echo "Number of addresses on node 1 : $num"
|
||||
|
||||
|
||||
echo "Turning on NoIPTakeover on node 1"
|
||||
try_command_on_node 1 "$CTDB setvar NoIPTakeover 1"
|
||||
echo "Turning on NoIPTakeover on all nodes"
|
||||
try_command_on_node all "$CTDB setvar NoIPTakeover 1"
|
||||
try_command_on_node 1 "$CTDB ipreallocate"
|
||||
|
||||
echo Disable node 1
|
||||
|
@ -154,9 +154,10 @@ static void ctdb_test_init(TALLOC_CTX *mem_ctx,
|
||||
{
|
||||
struct ctdb_public_ip_list *known;
|
||||
struct ctdb_public_ip_list *avail;
|
||||
char *tok, *ns, *t;
|
||||
char *tok, *ns;
|
||||
const char *t;
|
||||
struct ctdb_node_map *nodemap;
|
||||
uint32_t *tval_noiptakeover;
|
||||
uint32_t noiptakeover;
|
||||
uint32_t *tval_noiptakeoverondisabled;
|
||||
ctdb_sock_addr sa_zero = { .ip = { 0 } };
|
||||
enum ipalloc_algorithm algorithm;
|
||||
@ -194,8 +195,16 @@ static void ctdb_test_init(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
t = getenv("CTDB_SET_NoIPTakeover");
|
||||
if (t != NULL) {
|
||||
noiptakeover = (uint32_t) strtol(t, NULL, 0);
|
||||
} else {
|
||||
noiptakeover = 0;
|
||||
}
|
||||
|
||||
*ipalloc_state = ipalloc_state_init(mem_ctx, nodemap->num,
|
||||
algorithm,
|
||||
(noiptakeover != 0),
|
||||
false, NULL);
|
||||
assert(*ipalloc_state != NULL);
|
||||
|
||||
@ -205,16 +214,12 @@ static void ctdb_test_init(TALLOC_CTX *mem_ctx,
|
||||
|
||||
ipalloc_set_public_ips(*ipalloc_state, known, avail);
|
||||
|
||||
tval_noiptakeover = get_tunable_values(mem_ctx, nodemap->num,
|
||||
"CTDB_SET_NoIPTakeover");
|
||||
assert(tval_noiptakeover != NULL);
|
||||
tval_noiptakeoverondisabled =
|
||||
get_tunable_values(mem_ctx, nodemap->num,
|
||||
"CTDB_SET_NoIPHostOnAllDisabled");
|
||||
assert(tval_noiptakeoverondisabled != NULL);
|
||||
|
||||
ipalloc_set_node_flags(*ipalloc_state, nodemap,
|
||||
tval_noiptakeover,
|
||||
tval_noiptakeoverondisabled);
|
||||
}
|
||||
|
||||
|
@ -2,23 +2,23 @@
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "Node with NODE_FLAGS_NOIPTAKEOVER doesn't gain IPs"
|
||||
define_test "NoIPTakeover - nodes don't gain IPs"
|
||||
|
||||
export CTDB_TEST_LOGLEVEL=ERR
|
||||
|
||||
required_result <<EOF
|
||||
192.168.21.254 1
|
||||
192.168.21.253 2
|
||||
192.168.21.253 1
|
||||
192.168.21.252 1
|
||||
192.168.20.254 2
|
||||
192.168.20.253 2
|
||||
192.168.20.254 1
|
||||
192.168.20.253 1
|
||||
192.168.20.252 1
|
||||
192.168.20.251 2
|
||||
192.168.20.251 1
|
||||
192.168.20.250 1
|
||||
192.168.20.249 1
|
||||
EOF
|
||||
|
||||
export CTDB_SET_NoIPTakeover="1,0,0"
|
||||
export CTDB_SET_NoIPTakeover=1
|
||||
|
||||
simple_test 0,0,0 <<EOF
|
||||
192.168.20.249 1
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "Node with NODE_FLAGS_NOIPTAKEOVER doesn't lose IPs"
|
||||
define_test "NoIPTakeover: nodes don't lose IPs"
|
||||
|
||||
export CTDB_TEST_LOGLEVEL=ERR
|
||||
|
||||
@ -18,7 +18,7 @@ required_result <<EOF
|
||||
192.168.20.249 0
|
||||
EOF
|
||||
|
||||
export CTDB_SET_NoIPTakeover="1,0,0"
|
||||
export CTDB_SET_NoIPTakeover=1
|
||||
|
||||
simple_test 0,0,0 <<EOF
|
||||
192.168.20.249 0
|
||||
|
@ -2,25 +2,26 @@
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "3 nodes, 2->3 unhealthy, all IPs assigned, split NoIPTakeover"
|
||||
define_test "3 nodes, 2->3 unhealthy, all IPs assigned, NoIPTakeover"
|
||||
|
||||
export CTDB_TEST_LOGLEVEL=ERR
|
||||
|
||||
# We expect 1/2 the IPs to move, but the rest to stay (as opposed to
|
||||
# NoIPHostOnAllDisabled)
|
||||
# We expect the IPs stay where they are (as opposed to
|
||||
# NoIPHostOnAllDisabled). IPs are hosted when all nodes are disabled,
|
||||
# but they have nowhere else to go because of NoIPTakeover.
|
||||
required_result <<EOF
|
||||
192.168.21.254 2
|
||||
192.168.21.253 0
|
||||
192.168.21.253 2
|
||||
192.168.21.252 2
|
||||
192.168.20.254 0
|
||||
192.168.20.253 0
|
||||
192.168.20.254 2
|
||||
192.168.20.253 2
|
||||
192.168.20.252 2
|
||||
192.168.20.251 0
|
||||
192.168.20.251 2
|
||||
192.168.20.250 2
|
||||
192.168.20.249 2
|
||||
EOF
|
||||
|
||||
export CTDB_SET_NoIPTakeover=0,1,1
|
||||
export CTDB_SET_NoIPTakeover=1
|
||||
|
||||
simple_test 2,2,2 <<EOF
|
||||
192.168.21.254 2
|
||||
|
Loading…
Reference in New Issue
Block a user