From: Martin Schwenke Date: Wed, 29 Jun 2016 06:36:28 +0000 (+1000) Subject: ctdb-ipalloc: Fix buggy short-circuit when no IPs are available X-Git-Url: http://git.samba.org/?p=obnox%2Fsamba%2Fsamba-obnox.git;a=commitdiff_plain;h=86f7c4d7f360457cdd41e456aafbf90291f5bfbb ctdb-ipalloc: Fix buggy short-circuit when no IPs are available At the moment IP is short-circuited when there are no available IP addresses. However, if some IP addresses are already allocated then "no available IP addresses" means that all the addresses should (probably) be released. The current short-circuit means that no already hosted IP addresses will be released. The short-circuit exists to avoid lots of messages saying that all IP addresses can not be assigned at startup time. So, add a check to ipalloc_can_host_ips() so that it succeeds if IP addresses are already allocated to nodes. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ipalloc.c b/ctdb/server/ipalloc.c index 868ac841bcb..295671a924f 100644 --- a/ctdb/server/ipalloc.c +++ b/ctdb/server/ipalloc.c @@ -129,9 +129,23 @@ bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state, return (ipalloc_state->all_ips != NULL); } +/* This can only return false if there are no available IPs *and* + * there are no IP addresses currently allocated. If the latter is + * true then the cluster can clearly host IPs... just not necessarily + * right now... */ bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state) { int i; + struct public_ip_list *ip_list; + + + for (ip_list = ipalloc_state->all_ips; + ip_list != NULL; + ip_list = ip_list->next) { + if (ip_list->pnn != -1) { + return true; + } + } for (i=0; i < ipalloc_state->num; i++) { if (ipalloc_state->available_public_ips[i].num != 0) {