diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index e834f9631fe..3298106d629 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -88,6 +88,7 @@ struct ctdb_tunable { uint32_t database_hash_size; uint32_t rerecovery_timeout; uint32_t enable_bans; + uint32_t deterministic_public_ips; }; /* diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 9986714a17b..ec3455e4c04 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -675,6 +675,17 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap) */ all_ips = create_merged_ip_list(ctdb, tmp_ctx); + /* If we want deterministic ip allocations, i.e. that the ip addresses + will always be allocated the same way for a specific set of + available/unavailable nodes. + */ + if (1 == ctdb->tunable.deterministic_public_ips) { + DEBUG(0,("Deterministic IPs enabled. Resetting all ip allocations\n")); + for (i=0,tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next,i++) { + tmp_ip->pnn = i%nodemap->num; + } + } + /* mark all public addresses with a masked node as being served by node -1 @@ -759,6 +770,13 @@ try_again: continue; } + /* If we want deterministic IPs then dont try to reallocate + them to spread out the load. + */ + if (1 == ctdb->tunable.deterministic_public_ips) { + continue; + } + /* if the spread between the smallest and largest coverage by a node is >=2 we steal one of the ips from the node with most coverage to even things out a bit. diff --git a/ctdb/server/ctdb_tunables.c b/ctdb/server/ctdb_tunables.c index 7c5aac98007..da1f6e6ba77 100644 --- a/ctdb/server/ctdb_tunables.c +++ b/ctdb/server/ctdb_tunables.c @@ -44,6 +44,7 @@ static const struct { { "DatabaseHashSize", 10000, offsetof(struct ctdb_tunable, database_hash_size) }, { "RerecoveryTimeout", 10, offsetof(struct ctdb_tunable, rerecovery_timeout) }, { "EnableBans", 1, offsetof(struct ctdb_tunable, enable_bans) }, + { "DeterministicIPs", 0, offsetof(struct ctdb_tunable, deterministic_public_ips) }, }; /*