summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2015-01-28 11:54:39 +1100
committerAmitay Isaacs <amitay@samba.org>2015-03-23 12:23:12 +0100
commit8e12e112f8fe14716f6a1a0f07783c7df03db3b9 (patch)
tree26196a0cbd51451cf5b33202063de61a7486f6ac /ctdb
parent77e879253b2e2a7b5ec630daad3a7709abd67953 (diff)
downloadsamba-8e12e112f8fe14716f6a1a0f07783c7df03db3b9.tar.gz
ctdb-tools: "reloadnodes" should only run against current node
It should not be possible to specify "-n <othernode>", unless <othernode> is the current node. To support this, add new function assert_current_node_only(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/tools/ctdb.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 23cfc9d977f..c3984b068ee 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -125,6 +125,15 @@ static void assert_single_node_only(void)
}
}
+static void assert_current_node_only(struct ctdb_context *ctdb)
+{
+ if (options.pnn != ctdb_get_pnn(ctdb)) {
+ DEBUG(DEBUG_ERR,
+ ("This control can only be applied to the current node\n"));
+ exit(1);
+ }
+}
+
/* Pretty print the flags to a static buffer in human-readable format.
* This never returns NULL!
*/
@@ -6144,12 +6153,9 @@ static int control_listnodes(struct ctdb_context *ctdb, int argc, const char **a
static int control_reload_nodes_file(struct ctdb_context *ctdb, int argc, const char **argv)
{
int i, ret;
- int mypnn;
struct ctdb_node_map *nodemap=NULL;
- assert_single_node_only();
-
- mypnn = ctdb_get_pnn(ctdb);
+ assert_current_node_only(ctdb);
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap);
if (ret != 0) {
@@ -6159,7 +6165,7 @@ static int control_reload_nodes_file(struct ctdb_context *ctdb, int argc, const
/* reload the nodes file on all remote nodes */
for (i=0;i<nodemap->num;i++) {
- if (nodemap->nodes[i].pnn == mypnn) {
+ if (nodemap->nodes[i].pnn == options.pnn) {
continue;
}
DEBUG(DEBUG_NOTICE, ("Reloading nodes file on node %u\n", nodemap->nodes[i].pnn));
@@ -6170,11 +6176,11 @@ static int control_reload_nodes_file(struct ctdb_context *ctdb, int argc, const
}
}
- /* reload the nodes file on the local node */
- DEBUG(DEBUG_NOTICE, ("Reloading nodes file on node %u\n", mypnn));
- ret = ctdb_ctrl_reload_nodes_file(ctdb, TIMELIMIT(), mypnn);
+ /* 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", mypnn));
+ DEBUG(DEBUG_ERR, ("ERROR: Failed to reload nodes file on node %u. You MUST fix that node manually!\n", options.pnn));
}
/* initiate a recovery */