From 9c18eeac6d0072522e2537f3848b577ddb3a690d Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 24 Feb 2017 15:50:00 -0500 Subject: [PATCH] Workaround for network start race condition Add a workaround for the libvirt network start race condition bug. In some cases the libvirt default network starts in an inactive state with the bridge interface down. Trying to start the network via libvirt fails because the network interface already exists. This condition is checked for and ignored but causes the Bifrost deployment test to fail later when templating ironic.conf as the configured network interface has no IP address. This change checks for the condition where the libvirt default network is inactive and attempts to delete the associated bridge interface before starting the libvirt network. This has been run through the CI job and appears to resolve the issue. Change-Id: Icb2baf0975ca3feb6041b2f2da9702ad6cc9fa06 Closes-Bug: #1660953 Related-Bug: #1650025 --- .../roles/bifrost-create-vm-nodes/tasks/main.yml | 9 +++++++-- .../bifrost-ironic-install/tasks/ironic_config.yml | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml index bc86c7fb3..cd3772c52 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml @@ -73,6 +73,12 @@ delegate_to: localhost ignore_errors: yes +- name: "Delete default network interface if not running" + shell: ip link del $(virsh net-info default | awk '$1 == "Bridge:" { print $2 }') + when: virsh_network_status.rc != 0 + ignore_errors: yes + delegate_to: localhost + - name: "Start default network if not running" command: virsh net-start default when: virsh_network_status.rc != 0 @@ -85,8 +91,7 @@ msg: "Unable to verify the libvirt default network is available" when: > virsh_network_status.rc != 0 and - task_start_default_net.rc != 0 and - 'File exists' not in task_start_default_net.stderr + task_start_default_net.rc != 0 - name: "Create virtual machines" script: create_vm_nodes-for-role.sh diff --git a/playbooks/roles/bifrost-ironic-install/tasks/ironic_config.yml b/playbooks/roles/bifrost-ironic-install/tasks/ironic_config.yml index 62313940b..b770b5223 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/ironic_config.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/ironic_config.yml @@ -13,6 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. --- +- name: "Fail if the network interface does not exist" + fail: + msg: > + The configured network interface {{ network_interface }} does + not exist + when: "{{ 'ansible_' ~ ans_network_interface not in hostvars[inventory_hostname] }}" +- name: "Fail if the network interface has no IP address assigned" + fail: + msg: > + The configured network interface {{ network_interface }} does + not have an IP address assigned + when: "{{ not hostvars[inventory_hostname]['ansible_' ~ ans_network_interface].get('ipv4', {}).get('address') }}" - name: "Update driver list if PXE drivers are enabled" set_fact: enabled_drivers: "{{ enabled_drivers }},{{ pxe_drivers }}"