diff options
author | Martin Schwenke <martin@meltin.net> | 2014-05-23 21:58:55 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2014-05-29 05:59:37 +0200 |
commit | 4dd382296d3e78000713ab0ac1f8e531e25857cc (patch) | |
tree | 30f8b27375004c4c28bfbecdb341c4d713ecd3eb /ctdb/tests/src | |
parent | f2ef23cd5f227d2da2f032a2a56fbdd4d105b137 (diff) | |
download | samba-4dd382296d3e78000713ab0ac1f8e531e25857cc.tar.gz samba-4dd382296d3e78000713ab0ac1f8e531e25857cc.tar.xz samba-4dd382296d3e78000713ab0ac1f8e531e25857cc.zip |
ctdb-tools-ctdb: Make natgwlist and lvsmaster more resilient
Recent changes have caused these commands to attempt to get
capabilities from all nodes before doing further filtering. This
means that capabilities are unnecessarily fetched from nodes that are
unlikely to be the master. If such a node does not answer the control
then many nodes can fail to calculate the master node. In the case of
natgwlist this will cause "monitor" events to fail resulting in
unhealthy nodes.
Restore the behaviour where capabilities are only fetched for a node
that will be the master if it has the desired flags.
Although this masks a problem where a connected node is not replying,
it can help to avoid an outage in some cases.
Add supporting tests and infrastructure. Infrastructure just lets a
timeout be faked - just for ctdb_ctrl_getcapabilities_stub() so far.
First test checks that this infrastructure works if the first node
times out in natgwlist. Second test checks the case worked around by
the above fix - that is, no failure when a node with PNN beyond the
NATGW master can time out.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu May 29 05:59:37 CEST 2014 on sn-devel-104
Diffstat (limited to 'ctdb/tests/src')
-rw-r--r-- | ctdb/tests/src/ctdb_test_stubs.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ctdb/tests/src/ctdb_test_stubs.c b/ctdb/tests/src/ctdb_test_stubs.c index 6149b3d334..d36fe81567 100644 --- a/ctdb/tests/src/ctdb_test_stubs.c +++ b/ctdb/tests/src/ctdb_test_stubs.c @@ -30,6 +30,10 @@ static struct ctdb_context *ctdb_global; * -CTDB_CAP_RECMASTER. LVS can be faked on by adding * CTDB_CAP_LVS. */ + +/* A fake flag that is only supported by some functions */ +#define NODE_FLAGS_FAKE_TIMEOUT 0x80000000 + void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb) { char line[1024]; @@ -95,6 +99,12 @@ void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb) capabilities &= ~CTDB_CAP_NATGW; } else if (strcmp(tok, "CTDB_CAP_LVS") == 0) { capabilities |= CTDB_CAP_LVS; + } else if (strcmp(tok, "TIMEOUT") == 0) { + /* This can be done with just a flag + * value but it is probably clearer + * and less error-prone to fake this + * with an explicit token */ + flags |= NODE_FLAGS_FAKE_TIMEOUT; } tok = strtok(NULL, " \t"); } @@ -550,6 +560,19 @@ int ctdb_ctrl_getcapabilities_stub(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities) { + + if (ctdb->nodes[destnode]->flags & NODE_FLAGS_FAKE_TIMEOUT) { + /* Placeholder for line#, instead of __location__ */ + DEBUG(DEBUG_ERR, + ("__LOCATION__ control timed out." + " reqid:1234567890 opcode:80 dstnode:%d\n", destnode)); + DEBUG(DEBUG_ERR, + ("__LOCATION__ ctdb_control_recv failed\n")); + DEBUG(DEBUG_ERR, + ("__LOCATION__ ctdb_ctrl_getcapabilities_recv failed\n")); + return -1; + } + if (ctdb->nodes[destnode]->flags & NODE_FLAGS_DISCONNECTED) { DEBUG(DEBUG_ERR, ("ctdb_control error: 'ctdb_control to disconnected node\n")); |