Add a new parameter to /etc/sysconfig/ctdb
authorRonnie Sahlberg <sahlberg@samba.org>
Thu, 21 Feb 2008 22:42:52 +0000 (09:42 +1100)
committerRonnie Sahlberg <sahlberg@samba.org>
Thu, 21 Feb 2008 22:42:52 +0000 (09:42 +1100)
CTDB_START_AS_DISABLED="yes"

and command line argument
--start-as-disabled

When set, this makes the ctdb node to always start in DISABLED mode and will thus not host any public ip addresses.
The administrator must manually "ctdb enable" the node after it has started when the administrator wants the node to start hosting public ip addresses.

Using this option it is possible to start ctdb on a node without causing any reallocation of ip addresses when it is starting. The node will still merge with the cluster and there will still be a recovery phase but the ip address allocations will not change in the cluster.

(This used to be ctdb commit b93d29f43f5306c244c887b54a77bca8a061daf2)

ctdb/config/ctdb.init
ctdb/config/ctdb.sysconfig
ctdb/include/ctdb_private.h
ctdb/server/ctdb_server.c
ctdb/server/ctdbd.c
ctdb/tcp/tcp_connect.c

index b01d8ee9167924b5eb88f89a71fd318726b86149..bae52c2c8bfa2ce42c633fbe6f1ec8f2c59d7861 100755 (executable)
@@ -63,6 +63,9 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
 [ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR"
 [ -z "$CTDB_TRANSPORT" ]        || CTDB_OPTIONS="$CTDB_OPTIONS --transport $CTDB_TRANSPORT"
 [ -z "$CTDB_DEBUGLEVEL" ]       || CTDB_OPTIONS="$CTDB_OPTIONS -d $CTDB_DEBUGLEVEL"
+[ -z "$CTDB_START_AS_DISABLED" ] || [ "$CTDB_START_AS_DISABLED" != "yes" ] || {
+       CTDB_OPTIONS="$CTDB_OPTIONS --start-as-disabled"
+}
 
 if [ -x /sbin/startproc ]; then
     init_style="suse"
index 74556c0a223eb6241bc048e8eab7471ed08c9a3f..9d1e4341e0e8c396069e8b0111f2664c234f960b 100644 (file)
 # When set, this variable makes ctdb monitor the amount of free memory
 # in the system (the second number in the buffers/cache output from free -m).
 # If the amount of free memory drops below this treshold the node will become
-# unhealthy and will be marked as DISABLED.
-# Once a node is disabled it requires administrator intervention to enable the
-# node again using the "ctdb enable" command.
+# unhealthy and ctdb and all managed services will be shutdown.
+# Once this occurs, the administrator needs to find the reason for the OOM
+# situation, rectify it and restart ctdb with "service ctdb start"
 # The unit is MByte
 # CTDB_MONITOR_FREE_MEMORY=100
 
+# When set to yes, the CTDB node will start in DISABLED mode and not host
+# any public ip addresses. The administrator needs to explicitely enable
+# the node with "ctdb enable"
+# CTDB_START_AS_DISABLED="yes"
+
 # where to log messages
 # the default is /var/log/log.ctdb
 # CTDB_LOGFILE=/var/log/log.ctdb
index c34a9d994e11eb96629f55a6fea628daf45f07fb..b797028210984a4d168612554305e0eb8b43a2e8 100644 (file)
@@ -372,6 +372,7 @@ struct ctdb_context {
        const char *node_ip;
        struct ctdb_monitor_state *monitor;
        struct ctdb_log_state *log;
+       int start_as_disabled;
 };
 
 struct ctdb_db_context {
index 47a65c93ab45830bfb1836a1b980f71890baef27..ae545f90ea5c533bb3f60af5957d9fb0c7ff48de 100644 (file)
@@ -115,8 +115,14 @@ static int ctdb_add_node(struct ctdb_context *ctdb, char *nstr)
 
        if (ctdb->address.address &&
            ctdb_same_address(&ctdb->address, &node->address)) {
+               /* for automatic binding to interfaces, see tcp_connect.c */
                ctdb->pnn = node->pnn;
                node->flags &= ~NODE_FLAGS_DISCONNECTED;
+
+               /* do we start out in DISABLED mode? */
+               if (ctdb->start_as_disabled != 0) {
+                       node->flags |= NODE_FLAGS_DISABLED;
+               }
        }
 
        ctdb->num_nodes++;
index ca366fc2092edeb99ca3e52b7f40477a59b5e9dd..0686e0b8296a0e9eba1d6ed74059cb3eb8963cc9 100644 (file)
@@ -42,6 +42,7 @@ static struct {
        const char *node_ip;
        int         no_setsched;
        int         use_syslog;
+       int         start_as_disabled;
 } options = {
        .nlist = ETCDIR "/ctdb/nodes",
        .transport = "tcp",
@@ -118,6 +119,7 @@ int main(int argc, const char *argv[])
                { "reclock", 0, POPT_ARG_STRING, &options.recovery_lock_file, 0, "location of recovery lock file", "filename" },
                { "nosetsched", 0, POPT_ARG_NONE, &options.no_setsched, 0, "disable setscheduler SCHED_FIFO call", NULL },
                { "syslog", 0, POPT_ARG_NONE, &options.use_syslog, 0, "log messages to syslog", NULL },
+               { "start-as-disabled", 0, POPT_ARG_NONE, &options.start_as_disabled, 0, "Node starts in disabled state", NULL },
                POPT_TABLEEND
        };
        int opt, ret;
@@ -157,6 +159,8 @@ int main(int argc, const char *argv[])
 
        ctdb = ctdb_cmdline_init(ev);
 
+       ctdb->start_as_disabled = options.start_as_disabled;
+
        ret = ctdb_set_logfile(ctdb, options.logfile, options.use_syslog);
        if (ret == -1) {
                printf("ctdb_set_logfile to %s failed - %s\n", 
index f85e3dfdebe39e96401db65cd8ce090f9d3bf62a..0f14dec8c5e553e12a7f211e518586110a45bb6e 100644 (file)
@@ -313,7 +313,11 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                 ctdb->address.address, 
                 ctdb->address.port, 
                 ctdb->pnn));
-
+       /* do we start out in DISABLED mode? */
+       if (ctdb->start_as_disabled != 0) {
+               ctdb->nodes[i]->flags |= NODE_FLAGS_DISABLED;
+       }
+       
        if (listen(ctcp->listen_fd, 10) == -1) {
                goto failed;
        }