Wait for ironic-neutron-agent bridge_mappings before provide

When provide is immediately run after import, it sometimes stalls
indefinitely due to port creation failure.

This fix avoids this issue by polling the ironic neutron agent
associated with the host until:
1. the agent entry exists for that host
2. the agent configuration has something populated for bridge_mappings

Change-Id: I7eb90fb0b532942825e32c43ebd057a28005c8ec
Closes-Bug: #1866204
This commit is contained in:
Steve Baker 2020-03-25 03:23:52 +00:00
parent a70139e5b9
commit 1bc900c749
2 changed files with 24 additions and 0 deletions

View File

@ -66,6 +66,12 @@ options:
- Don't wait for other nodes to provide if at least one failed
type: bool
default: True
wait_for_bridge_mappings:
description:
- Whether to poll neutron agents for an agent with populated mappings
before doing the provide
type: bool
default: False
requirements: ["openstacksdk"]
'''
@ -329,6 +335,7 @@ EXAMPLES = '''
'''
import yaml
from openstack.exceptions import ResourceFailure, ResourceTimeout
from openstack.utils import iterate_timeout
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.openstack import openstack_full_argument_spec
@ -362,13 +369,29 @@ def get_info_nodes(nodes_wait, msg, result, client):
return result, msg
def wait_for_bridge_mapping(conn, node):
client = conn.network
timeout_msg = ('Timeout waiting for node %(node) to have bridge_mappings '
'set in the ironic-neutron-agent entry')
# default agent polling period is 30s, so wait 60s
timeout = 60
for count in iterate_timeout(timeout, timeout_msg):
agents = list(client.agents(host=node, binary='ironic-neutron-agent'))
if agents:
if agents[0].configuration.get('bridge_mappings'):
return
def parallel_nodes_providing(conn, module):
client = conn.baremetal
node_timeout = module.params['timeout']
wait_for_bridge_mappings = module.params['wait_for_bridge_mappings']
nodes = list(set(module.params['node_uuid'] + module.params['node_name']))
result = {}
nodes_wait = nodes[:]
for node in nodes:
if wait_for_bridge_mappings:
wait_for_bridge_mapping(conn, node)
try:
client.set_node_provision_state(
node,

View File

@ -51,6 +51,7 @@
cloud: undercloud
node_uuid: "{{ node_uuids_provide }}"
timeout: 1200
wait_for_bridge_mappings: true
# Run cellv2 discovery of hosts
- name: Run cell_v2 host discovery