Wait for ironic-neutron-agent to report state

Wait for the agent to finish reporting state, bridge_mappings
must be reported prior to any cleaning attempts.

Change-Id: I041761dd896c9d89dc6cf7bafc991a0697ded05b
Related-Bug: #1658964
This commit is contained in:
Harald Jensas 2018-01-08 03:42:53 +01:00
parent d0d78a86de
commit d2da4150ea
1 changed files with 42 additions and 0 deletions

View File

@ -492,6 +492,12 @@ IRONIC_CLEANING_TIMEOUT=${IRONIC_CLEANING_TIMEOUT:-1200}
IRONIC_CLEANING_DELAY=10
IRONIC_CLEANING_ATTEMPTS=$(( $IRONIC_CLEANING_TIMEOUT / $IRONIC_CLEANING_DELAY ))
# Timeout for ironic-neutron-agent to report state before providing nodes.
# The agent reports every 60 seconds, 2 minutes should do.
IRONIC_NEUTRON_AGENT_REPORT_STATE_DELAY=10
IRONIC_NEUTRON_AGENT_REPORT_STATE_TIMEOUT=${IRONIC_NEUTRON_AGENT_REPORT_STATE_TIMEOUT:-120}
IRONIC_NEUTRON_AGENT_REPORT_STATE_ATTEMPTS=$(( $IRONIC_NEUTRON_AGENT_REPORT_STATE_TIMEOUT / IRONIC_NEUTRON_AGENT_REPORT_STATE_DELAY ))
# Username to use by Ansible to access ramdisk,
# to be set as '[ansible]/default_username' option.
# If not set here (default), will be set to 'tc' for TinyIPA ramdisk,
@ -1693,6 +1699,36 @@ function provide_nodes {
fi
}
function wait_for_ironic_neuton_agent_report_state_for_all_nodes {
local nodes=$@
echo "Waiting for ironic-neutron-agent to report state for nodes: $nodes"
local attempt
for attempt in $(seq 1 $IRONIC_NEUTRON_AGENT_REPORT_STATE_ATTEMPTS); do
local reported
reported=$(openstack network agent list -f value -c Host -c Binary | grep ironic-neutron-agent | cut -d ' ' -f 1 | paste -s -d ' ')
echo "Currently reported nodes: $reported"
local can_break
for node_id in $nodes; do
if echo $reported | grep -q $node_id; then
can_break="True"
else
can_break="False"
break
fi
done
if [[ $can_break == "True" ]]; then
break
fi
sleep $IRONIC_NEUTRON_AGENT_REPORT_STATE_DELAY
done
if [[ "$can_break" == "False" ]]; then
die $LINENO "ironic-neutron-agent did not report some nodes."
fi
}
function enroll_nodes {
local chassis_id
chassis_id=$($IRONIC_CMD chassis create --description "ironic test chassis" -f value -c uuid)
@ -1941,6 +1977,12 @@ function enroll_nodes {
total_nodes=$((total_nodes+1))
done < $ironic_hwinfo_file
# NOTE(hjensas): ensure ironic-neutron-agent has done report_state for all
# nodes we attempt cleaning.
if [[ "${IRONIC_USE_NEUTRON_SEGMENTS}" == "True" ]]; then
wait_for_ironic_neuton_agent_report_state_for_all_nodes $node_uuids
fi
# NOTE(dtantsur): doing it outside of the loop, because of cleaning
provide_nodes $node_uuids