Fix nova compute addition with limit

Deploy a small cloud. Add one host to the compute group in the
inventory, and scale out:

$ kolla-ansible deploy --limit <new compute host>

The command succeeds, but creating an instance fails with the following:

    Host 'compute0' is not mapped to any cell

This happens because we only discover computes on the first host in the
cell's nova conductor group. If that host is not in the specified limit,
the discovery will not happen.

This change fixes the issue by running compute discovery when any ironic
or virtualised compute hosts are in the play batch, and delegating it to
a conductor.

Change-Id: Ie984806240d147add825ffa8446ae6ff55ca4814
Closes-Bug: #1869371
This commit is contained in:
Mark Goddard 2020-03-27 13:27:15 +00:00
parent 9643dd54e2
commit 3af28d2151
5 changed files with 38 additions and 17 deletions

View File

@ -1,5 +1,7 @@
---
- import_tasks: get_cell_settings.yml
when:
- inventory_hostname == groups[nova_conductor.group][0] | default(None)
- name: Create cell
vars:

View File

@ -18,4 +18,22 @@
meta: flush_handlers
- include_tasks: discover_computes.yml
when: inventory_hostname in groups[nova_cell_conductor_group]
vars:
# List of virtualised compute hypervisors in this Ansible play batch.
virt_computes_in_batch: >-
{{ groups[nova_cell_compute_group] |
intersect(ansible_play_batch) |
list }}
# List of iroinc compute hosts in this Ansible play batch.
ironic_computes_in_batch: >-
{{ (groups[nova_cell_compute_ironic_group] |
intersect(ansible_play_batch) |
list)
if nova_cell_services['nova-compute-ironic'].enabled | bool else [] }}
all_computes_in_batch: "{{ virt_computes_in_batch + ironic_computes_in_batch }}"
when:
# Run discovery when one or more compute hosts are in the Ansible batch,
# and there is a cell conductor in the inventory to delegate to.
- all_computes_in_batch | length > 0
- inventory_hostname == all_computes_in_batch[0]
- groups[nova_cell_conductor_group] | length > 0

View File

@ -9,22 +9,19 @@
# is similar to what nova uses internally as its default for the
# [DEFAULT] host config option.
virt_compute_service_hosts: >-
{{ groups[nova_cell_compute_group] |
intersect(ansible_play_batch) |
{{ virt_computes_in_batch |
map('extract', hostvars, 'ansible_nodename') |
list }}
# For ironic, use {{ansible_hostname}}-ironic since this is what we
# configure for [DEFAULT] host in nova.conf.
ironic_compute_service_hosts: >-
{{ (groups[nova_cell_compute_ironic_group] |
intersect(ansible_play_batch) |
{{ ironic_computes_in_batch |
map('extract', hostvars, 'ansible_hostname') |
map('regex_replace', '^(.*)$', '\1-ironic') |
list)
if nova_cell_services['nova-compute-ironic'].enabled | bool else [] }}
list }}
set_fact:
expected_compute_service_hosts: "{{ virt_compute_service_hosts + ironic_compute_service_hosts }}"
when: inventory_hostname == groups[nova_cell_conductor_group][0] | default(None)
delegate_to: "{{ groups[nova_cell_conductor_group][0] }}"
- name: Waiting for nova-compute services to register themselves
become: true
@ -60,17 +57,17 @@
map(attribute='Host') |
list)
is superset(expected_compute_service_hosts)
when: inventory_hostname == groups[nova_cell_conductor_group][0] | default(None)
delegate_to: "{{ groups[nova_cell_conductor_group][0] }}"
- import_tasks: get_cell_settings.yml
delegate_to: "{{ groups[nova_cell_conductor_group][0] }}"
- name: Fail if cell settings not found
fail:
msg: >-
Unable to find settings for {{ nova_cell_name or 'the default cell' }}.
when:
- inventory_hostname == groups[nova_cell_conductor_group][0] | default(None)
- not nova_cell_settings
when: not nova_cell_settings
delegate_to: "{{ groups[nova_cell_conductor_group][0] }}"
# TODO(yoctozepto): no need to do --by-service if ironic not used
- name: Discover nova hosts
@ -78,4 +75,4 @@
command: >
docker exec nova_conductor nova-manage cell_v2 discover_hosts --by-service --cell_uuid {{ nova_cell_settings.cell_uuid }}
changed_when: False
when: inventory_hostname == groups[nova_cell_conductor_group][0] | default(None)
delegate_to: "{{ groups[nova_cell_conductor_group][0] }}"

View File

@ -18,11 +18,9 @@
changed_when: false
failed_when:
- existing_cells_list.rc != 0
when: inventory_hostname == groups[nova_conductor.group][0] | default(None)
- name: Extract current cell settings from list
vars:
nova_conductor: "{{ nova_cell_services['nova-conductor'] }}"
set_fact:
nova_cell_settings: "{{ existing_cells_list | extract_cell(nova_cell_name) }}"
when: inventory_hostname == groups[nova_conductor.group][0] | default(None)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue with Nova when deploying new compute hosts using
``--limit``. `LP#1869371
<https://bugs.launchpad.net/kolla-ansible/+bug/1869371>`__.