Wait for nova-compute service registration

A race condition is caused when nova-compute is started for the
first time because it takes a period of time for nova-compute
to spin up, register itself with nova API, and become available for
cell enrollment.

Prior to this there was no wait condition when nova-compute
restarts occurred, so the first time nova-compute started, often
the compute service was not registered in the database and available
for cell enrollment when the enrollment tasks ran.

Change-Id: I510f0a957f53d15affa1fc23f809abff52208438
This commit is contained in:
Logan V 2017-02-08 11:30:13 -06:00
parent 46c1576c1e
commit b9b8e08ac0
4 changed files with 34 additions and 0 deletions

View File

@ -457,6 +457,7 @@ nova_requires_pip_packages:
- virtualenv-tools
- python-keystoneclient # Keystoneclient needed to OSA keystone lib
- httplib2
- python-openstackclient
nova_compute_pip_packages:
- libvirt-python

View File

@ -23,6 +23,7 @@
name: "{{ item.value.service_name }}"
state: "restarted"
with_dict: "{{ nova_services }}"
register: nova_service_restart
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"

View File

@ -85,6 +85,13 @@
- name: Flush handlers
meta: flush_handlers
- include: nova_compute_wait.yml
when:
- "{{ 'nova_compute' in group_names }}"
- "{{ nova_service_restart | default(dict(changed=False)) | changed }}"
tags:
- nova-config
- include: nova_db_post_setup.yml
when: inventory_hostname == groups['nova_api_os_compute'][0]
tags:

View File

@ -0,0 +1,25 @@
---
# Copyright 2017, Logan Vig <logan2211@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Wait for the nova-compute service to initialize
command: openstack --os-cloud default compute service list -f json
changed_when: false
register: nova_service_list
retries: 10
delay: 5
until: "{{ ansible_hostname in (nova_service_list.stdout
| from_json
| selectattr('Binary', 'equalto', 'nova-compute')
| map(attribute='Host') | list) }}"