1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

ctdb-tools: Use a broadcast to connected nodes for "reloadnodes"

There is no reason to serialise these or even handle remote nodes
first.  Using a broadcast is more efficient and is less code.

Update expected test results to reflect changed order of messages.

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): Mon Mar 23 15:04:00 CET 2015 on sn-devel-104
This commit is contained in:
Martin Schwenke 2015-02-25 11:43:10 +11:00 committed by Amitay Isaacs
parent c99d2702ee
commit c8918b70b9
10 changed files with 40 additions and 42 deletions

View File

@ -16,12 +16,12 @@ Node 0 is unchanged
Node 1 is unchanged
Node 2 is unchanged
Node 3 is NEW
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 1
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 2
Reloading nodes file on node 0
Reloading nodes file on node 1
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 1
ctdb_ctrl_reload_nodes_file: node 2
EOF
simple_test <<EOF

View File

@ -14,10 +14,10 @@ required_result 0 <<EOF
Node 0 is unchanged
Node 1 is unchanged
Node 2 is DELETED
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 1
Reloading nodes file on node 0
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 1
EOF
simple_test <<EOF

View File

@ -15,8 +15,8 @@ Node 0 is DELETED
Node 1 is unchanged
Node 2 is unchanged
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 1
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 1
ctdb_ctrl_reload_nodes_file: node 2
EOF

View File

@ -14,10 +14,10 @@ required_result 0 <<EOF
Node 0 is unchanged
Node 1 is DELETED
Node 2 is unchanged
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 2
Reloading nodes file on node 0
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 2
EOF
simple_test <<EOF

View File

@ -20,12 +20,12 @@ Node 2 is unchanged
Node 3 is NEW
Node 4 is NEW
Node 5 is NEW
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 1
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 2
Reloading nodes file on node 0
Reloading nodes file on node 1
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 1
ctdb_ctrl_reload_nodes_file: node 2
EOF
simple_test <<EOF

View File

@ -18,10 +18,10 @@ Node 1 is DELETED
Node 2 is unchanged
Node 3 is NEW
Node 4 is NEW
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 2
Reloading nodes file on node 0
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 2
EOF
simple_test <<EOF

View File

@ -18,10 +18,10 @@ Node 1 is unchanged
Node 2 is DELETED
Node 3 is NEW
Node 4 is NEW
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 1
Reloading nodes file on node 0
Reloading nodes file on node 1
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 1
EOF
simple_test <<EOF

View File

@ -17,10 +17,10 @@ Node 1 is unchanged
WARNING: Node 1 is disconnected. You MUST fix this node manually!
Node 2 is unchanged
Node 3 is NEW
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 2
Reloading nodes file on node 0
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 2
EOF
simple_test <<EOF

View File

@ -14,10 +14,10 @@ ok <<EOF
Node 0 is unchanged
Node 1 is UNDELETED
Node 2 is unchanged
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 2
Reloading nodes file on node 0
Reloading nodes file on node 2
ctdb_ctrl_reload_nodes_file: node 0
ctdb_ctrl_reload_nodes_file: node 2
EOF
simple_test <<EOF

View File

@ -6338,12 +6338,22 @@ static bool sanity_check_nodes_file_changes(TALLOC_CTX *mem_ctx,
return have_changes;
}
static void reload_nodes_fail_callback(struct ctdb_context *ctdb,
uint32_t node_pnn, int32_t res,
TDB_DATA outdata, void *callback_data)
{
DEBUG(DEBUG_WARNING,
("WARNING: Node %u failed to reload nodes. You MUST fix this node manually!\n",
node_pnn));
}
static int control_reload_nodes_file(struct ctdb_context *ctdb, int argc, const char **argv)
{
int i, ret;
struct ctdb_node_map *nodemap=NULL;
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
struct ctdb_node_map *file_nodemap;
uint32_t *conn;
assert_current_node_only(ctdb);
@ -6377,29 +6387,17 @@ static int control_reload_nodes_file(struct ctdb_context *ctdb, int argc, const
}
/* Now make the changes */
/* reload the nodes file on all remote nodes */
for (i=0;i<nodemap->num;i++) {
if (nodemap->nodes[i].pnn == options.pnn) {
continue;
}
if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
continue;
}
DEBUG(DEBUG_NOTICE, ("Reloading nodes file on node %u\n", nodemap->nodes[i].pnn));
ret = ctdb_ctrl_reload_nodes_file(ctdb, TIMELIMIT(),
nodemap->nodes[i].pnn);
if (ret != 0) {
DEBUG(DEBUG_ERR, ("ERROR: Failed to reload nodes file on node %u. You MUST fix that node manually!\n", nodemap->nodes[i].pnn));
}
conn = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
for (i = 0; i < talloc_array_length(conn); i++) {
DEBUG(DEBUG_NOTICE, ("Reloading nodes file on node %u\n",
conn[i]));
}
/* reload the nodes file on the specified node */
DEBUG(DEBUG_NOTICE, ("Reloading nodes file on node %u\n", options.pnn));
ret = ctdb_ctrl_reload_nodes_file(ctdb, TIMELIMIT(), options.pnn);
if (ret != 0) {
DEBUG(DEBUG_ERR, ("ERROR: Failed to reload nodes file on node %u. You MUST fix that node manually!\n", options.pnn));
}
ret = ctdb_client_async_control(ctdb, CTDB_CONTROL_RELOAD_NODES_FILE,
conn, 0, TIMELIMIT(),
true, tdb_null,
NULL, reload_nodes_fail_callback,
NULL);
/* initiate a recovery */
control_recover(ctdb, argc, argv);