Add a new tunable : DisableIPFailover that when set to non 0
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 9 Nov 2010 04:19:06 +0000 (15:19 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 10 Nov 2010 03:55:24 +0000 (14:55 +1100)
will stopp any ip reallocations at all from happening.

include/ctdb_private.h
server/ctdb_daemon.c
server/ctdb_recover.c
server/ctdb_recoverd.c
server/ctdb_takeover.c
server/ctdb_tunables.c
server/ctdbd.c

index a99b4b03381589c2c97e14262596f353a1e8b248..5fc583cb6c898ee4892147ac602e07b5c2e6bf05 100644 (file)
@@ -101,6 +101,7 @@ struct ctdb_tunable {
        uint32_t deterministic_public_ips;
        uint32_t reclock_ping_period;
        uint32_t no_ip_failback;
+       uint32_t disable_ip_failover;
        uint32_t verbose_memory_names;
        uint32_t recd_ping_timeout;
        uint32_t recd_ping_failcount;
@@ -454,7 +455,6 @@ struct ctdb_context {
        uint32_t recovery_master;
        struct ctdb_call_state *pending_calls;
        struct ctdb_client_ip *client_ip_list;
-       bool do_checkpublicip;
        struct trbt_tree *server_ids;   
        const char *event_script_dir;
        const char *notification_script;
@@ -1373,4 +1373,6 @@ int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
                                      struct ctdb_req_control *c,
                                      TDB_DATA *outdata);
 
+int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
+
 #endif
index 5eca7275c685dd5cdf3524e3abf1a3d00a7ba6d1..0fb1a8de23b6e9384b163ffdb13e43cd0c82ff83 100644 (file)
@@ -815,7 +815,9 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
        tevent_fd_set_auto_close(fde);
 
        /* release any IPs we hold from previous runs of the daemon */
-       ctdb_release_all_ips(ctdb);
+       if (ctdb->tunable.disable_ip_failover == 0) {
+               ctdb_release_all_ips(ctdb);
+       }
 
        /* start the transport going */
        ctdb_start_transport(ctdb);
index 111d7a98327f623700ab41f1b8d9610750e53ff9..fe4275c43fb31d8d186fdad630fa38221c41efa1 100644 (file)
@@ -639,6 +639,22 @@ ctdb_drop_all_ips_event(struct event_context *ev, struct timed_event *te,
        ctdb_release_all_ips(ctdb);
 }
 
+/*
+ * Set up an event to drop all public ips if we remain in recovery for too
+ * long
+ */
+int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb)
+{
+       if (ctdb->release_ips_ctx != NULL) {
+               talloc_free(ctdb->release_ips_ctx);
+       }
+       ctdb->release_ips_ctx = talloc_new(ctdb);
+       CTDB_NO_MEMORY(ctdb, ctdb->release_ips_ctx);
+
+       event_add_timed(ctdb->ev, ctdb->release_ips_ctx, timeval_current_ofs(ctdb->tunable.recovery_drop_all_ips, 0), ctdb_drop_all_ips_event, ctdb);
+       return 0;
+}
+
 /*
   set the recovery mode
  */
@@ -659,11 +675,9 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                talloc_free(ctdb->release_ips_ctx);
                ctdb->release_ips_ctx = NULL;
        } else {
-               talloc_free(ctdb->release_ips_ctx);
-               ctdb->release_ips_ctx = talloc_new(ctdb);
-               CTDB_NO_MEMORY(ctdb, ctdb->release_ips_ctx);
-
-               event_add_timed(ctdb->ev, ctdb->release_ips_ctx, timeval_current_ofs(ctdb->tunable.recovery_drop_all_ips, 0), ctdb_drop_all_ips_event, ctdb);
+               if (ctdb_deferred_drop_all_ips(ctdb) != 0) {
+                       DEBUG(DEBUG_ERR,("Failed to set up deferred drop all ips\n"));
+               }
        }
 
        if (recmode != ctdb->recovery_mode) {
index 541eb29b88155696bacf03de6de693211aad095b..4ba80eb0b98ef22216a0dda1007ff6330887e591 100644 (file)
@@ -3114,7 +3114,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
        /* verify that we have all ip addresses we should have and we dont
         * have addresses we shouldnt have.
         */ 
-       if (ctdb->do_checkpublicip) {
+       if (ctdb->tunable.disable_ip_failover != 0) {
                if (rec->ip_check_disable_ctx == NULL) {
                        if (verify_local_ip_allocation(ctdb, rec, pnn) != 0) {
                                DEBUG(DEBUG_ERR, (__location__ " Public IPs were inconsistent.\n"));
index 33fd0c2c4bd84402481a58c0dace3200afaad1f1..87a97d53db7bdbdcc59ade9b369da2dca0b0b4e7 100644 (file)
@@ -1238,6 +1238,13 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
        struct ctdb_client_control_state *state;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
 
+       /*
+        * ip failover is completely disabled, just send out the 
+        * ipreallocated event.
+        */
+       if (ctdb->tunable.disable_ip_failover != 0) {
+               goto ipreallocated;
+       }
 
        ZERO_STRUCT(ip);
 
@@ -1540,6 +1547,7 @@ finished:
                return -1;
        }
 
+ipreallocated:
        /* tell all nodes to update natwg */
        /* send the flags update natgw on all connected nodes */
        data.dptr  = discard_const("ipreallocated");
index cce78a7cd3d5d4d9ce1e0324dde1727a78b3389d..c0180054e53b831ebc58c9de7cb589073f57e09f 100644 (file)
@@ -49,6 +49,7 @@ static const struct {
        { "DeterministicIPs",     1,  offsetof(struct ctdb_tunable, deterministic_public_ips) },
        { "ReclockPingPeriod",   60,  offsetof(struct ctdb_tunable,  reclock_ping_period) },
        { "NoIPFailback",         0,  offsetof(struct ctdb_tunable, no_ip_failback) },
+       { "DisableIPFailover",    0,  offsetof(struct ctdb_tunable, disable_ip_failover) },
        { "VerboseMemoryNames",   0,  offsetof(struct ctdb_tunable, verbose_memory_names) },
        { "RecdPingTimeout",     60,  offsetof(struct ctdb_tunable, recd_ping_timeout) },
        { "RecdFailCount",       10,  offsetof(struct ctdb_tunable, recd_ping_failcount) },
index f8647f0900d3ae08837836e5a0c2323e7844955d..93a2d0823c3aba583a03d1930a7b7bd666796601 100644 (file)
@@ -207,6 +207,7 @@ int main(int argc, const char *argv[])
 
        ctdb_tunables_set_defaults(ctdb);
 
+       ctdb->tunable.disable_ip_failover = options.no_publicipcheck;
 
        ret = ctdb_set_recovery_lock_file(ctdb, options.recovery_lock_file);
        if (ret == -1) {
@@ -323,8 +324,6 @@ int main(int argc, const char *argv[])
 
        ctdb->valgrinding = options.valgrinding;
 
-       ctdb->do_checkpublicip = !options.no_publicipcheck;
-
        if (options.max_persistent_check_errors < 0) {
                ctdb->max_persistent_check_errors = 0xFFFFFFFFFFFFFFFFLL;
        } else {