From d8d37493478a26c5f1809a5f3df89ffd6e149281 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 9 Nov 2010 15:19:06 +1100 Subject: [PATCH] Add a new tunable : DisableIPFailover that when set to non 0 will stopp any ip reallocations at all from happening. --- include/ctdb_private.h | 4 +++- server/ctdb_daemon.c | 4 +++- server/ctdb_recover.c | 24 +++++++++++++++++++----- server/ctdb_recoverd.c | 2 +- server/ctdb_takeover.c | 8 ++++++++ server/ctdb_tunables.c | 1 + server/ctdbd.c | 3 +-- 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/include/ctdb_private.h b/include/ctdb_private.h index a99b4b03..5fc583cb 100644 --- a/include/ctdb_private.h +++ b/include/ctdb_private.h @@ -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 diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c index 5eca7275..0fb1a8de 100644 --- a/server/ctdb_daemon.c +++ b/server/ctdb_daemon.c @@ -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); diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c index 111d7a98..fe4275c4 100644 --- a/server/ctdb_recover.c +++ b/server/ctdb_recover.c @@ -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) { diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c index 541eb29b..4ba80eb0 100644 --- a/server/ctdb_recoverd.c +++ b/server/ctdb_recoverd.c @@ -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")); diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c index 33fd0c2c..87a97d53 100644 --- a/server/ctdb_takeover.c +++ b/server/ctdb_takeover.c @@ -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"); diff --git a/server/ctdb_tunables.c b/server/ctdb_tunables.c index cce78a7c..c0180054 100644 --- a/server/ctdb_tunables.c +++ b/server/ctdb_tunables.c @@ -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) }, diff --git a/server/ctdbd.c b/server/ctdbd.c index f8647f09..93a2d082 100644 --- a/server/ctdbd.c +++ b/server/ctdbd.c @@ -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 { -- 2.34.1