mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ctdb-ipalloc: New function ipalloc_can_host_ips()
Abstracts out code involving internals of IP allocation state. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
695da518de
commit
c5d85a071b
@ -1543,7 +1543,7 @@ static void takeover_run_process_failures(struct ctdb_context *ctdb,
|
||||
* values can be faked in unit testing)
|
||||
* - Use ipalloc_set_public_ips() to set known and available IP
|
||||
addresses for allocation
|
||||
* - If no available IP addresses then early exit
|
||||
* - If cluster can't host IP addresses then early exit
|
||||
* - Populate list of nodes to force rebalance - internal structure,
|
||||
* currently no way to fetch, only used by LCP2 for nodes that have
|
||||
* had new IP addresses added
|
||||
@ -1567,7 +1567,6 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
|
||||
struct ipalloc_state *ipalloc_state;
|
||||
struct ctdb_public_ip_list *known_ips, *available_ips;
|
||||
struct takeover_callback_data *takeover_data;
|
||||
bool can_host_ips;
|
||||
|
||||
/* Initialise fail callback data to be used with
|
||||
* takeover_run_fail_callback(). A failure in any of the
|
||||
@ -1624,14 +1623,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Short-circuit IP allocation if no node has available IPs */
|
||||
can_host_ips = false;
|
||||
for (i=0; i < ipalloc_state->num; i++) {
|
||||
if (ipalloc_state->available_public_ips[i].num != 0) {
|
||||
can_host_ips = true;
|
||||
}
|
||||
}
|
||||
if (!can_host_ips) {
|
||||
if (! ipalloc_can_host_ips(ipalloc_state)) {
|
||||
DEBUG(DEBUG_WARNING,("No nodes available to host public IPs yet\n"));
|
||||
goto ipreallocated;
|
||||
}
|
||||
|
@ -129,6 +129,19 @@ bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
|
||||
return (ipalloc_state->all_ips != NULL);
|
||||
}
|
||||
|
||||
bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < ipalloc_state->num; i++) {
|
||||
if (ipalloc_state->available_public_ips[i].num != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The calculation part of the IP allocation algorithm. */
|
||||
bool ipalloc(struct ipalloc_state *ipalloc_state)
|
||||
{
|
||||
|
@ -59,6 +59,8 @@ bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
|
||||
struct ctdb_public_ip_list *known_ips,
|
||||
struct ctdb_public_ip_list *available_ips);
|
||||
|
||||
bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state);
|
||||
|
||||
bool ipalloc(struct ipalloc_state *ipalloc_state);
|
||||
|
||||
#endif /* __CTDB_IPALLOC_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user