Merge "Wait for node to be unlocked before provide"

This commit is contained in:
Zuul 2020-08-18 15:38:23 +00:00 committed by Gerrit Code Review
commit 23e25d9e15
1 changed files with 14 additions and 2 deletions

View File

@ -365,10 +365,21 @@ def get_info_nodes(nodes_wait, msg, result, client):
return result, msg return result, msg
def wait_for_unlocked(client, node, timeout):
timeout_msg = 'Timeout waiting for node %s to be unlocked' % node
for count in iterate_timeout(timeout, timeout_msg):
node_info = client.get_node(
node,
fields=['reservation']
).to_dict()
if node_info['reservation'] is None:
return
def wait_for_bridge_mapping(conn, node): def wait_for_bridge_mapping(conn, node):
client = conn.network client = conn.network
timeout_msg = ('Timeout waiting for node %(node) to have bridge_mappings ' timeout_msg = ('Timeout waiting for node %s to have bridge_mappings '
'set in the ironic-neutron-agent entry') 'set in the ironic-neutron-agent entry' % node)
# default agent polling period is 30s, so wait 60s # default agent polling period is 30s, so wait 60s
timeout = 60 timeout = 60
for count in iterate_timeout(timeout, timeout_msg): for count in iterate_timeout(timeout, timeout_msg):
@ -386,6 +397,7 @@ def parallel_nodes_providing(conn, module):
result = {} result = {}
nodes_wait = nodes[:] nodes_wait = nodes[:]
for node in nodes: for node in nodes:
wait_for_unlocked(client, node, node_timeout)
if wait_for_bridge_mappings: if wait_for_bridge_mappings:
wait_for_bridge_mapping(conn, node) wait_for_bridge_mapping(conn, node)
try: try: