Skip to content

Commit

Permalink
Rearrange cell mapping tasks
Browse files Browse the repository at this point in the history
Existing instances can be mapped to a newly created cell immediately
after the cell is created and by the same conductor host that created
the cell.

After a new compute host is built, it will need to mapped to a cell
through the 'discover_hosts' command of nova-manage. This command will
still need to be run against a host that has direct database access, but
the command is able to handle mapping of all compute hosts that do not
currently belong to the cell so it only needs to be run once per play.

There can be a short delay in the time between a compute service
starting and becoming available to be discovered and mapped but, for
most deployments, compute host discovery will be handled automatically
as a periodic task.

Conflicts:
>------tasks/main.yml

Change-Id: I4f7328e1aff79eb94f278999b97fbad8f44c6a3e
Closes-Bug: 1749037
Related-Bug: 1729661
Related-Bug: 1752540
(cherry picked from commit 6321cf9)
  • Loading branch information
jimmymccrory authored and Jesse Pretorius committed Mar 14, 2018
1 parent bd3204e commit c581c2a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
13 changes: 5 additions & 8 deletions tasks/main.yml
Expand Up @@ -129,15 +129,12 @@
# because the compute hosts do not have access to
# the database connection string and therefore
# cannot run nova-manage.
# Also, we delegate this to a random host in the
# conductor group in order to spread the load of
# multiple forks across the group members.
- include: nova_db_post_setup.yml
delegate_to: "{{ conductor_host }}"
with_random_choice: "{{ groups['nova_conductor'] }}"
loop_control:
loop_var: conductor_host
delegate_to: "{{ random_conductor }}"
run_once: true
when:
- "'nova_compute' in group_names"
- "nova_services['nova-compute']['group'] in group_names"
vars:
random_conductor: "{{ groups[nova_services['nova-conductor']['group']] | random }}"
tags:
- nova-config
20 changes: 2 additions & 18 deletions tasks/nova_db_post_setup.yml
Expand Up @@ -15,28 +15,12 @@

- name: Set the delegated task facts
set_fact:
_db_nova_bin: "{{ hostvars[conductor_host]['nova_bin'] | default(nova_bin) }}"
_db_nova_system_user_name: "{{ hostvars[conductor_host]['nova_system_user_name'] | default(nova_system_user_name) }}"
_db_nova_cell1_name: "{{ hostvars[conductor_host]['nova_cell1_name'] | default(nova_cell1_name) }}"
_db_nova_bin: "{{ hostvars[random_conductor]['nova_bin'] | default(nova_bin) }}"
_db_nova_system_user_name: "{{ hostvars[random_conductor]['nova_system_user_name'] | default(nova_system_user_name) }}"

# This needs to be done after Compute hosts are added.
- name: Perform a cell_v2 discover
command: "{{ _db_nova_bin }}/nova-manage cell_v2 discover_hosts {{ (debug | bool) | ternary('--verbose', '') }}"
become: yes
become_user: "{{ _db_nova_system_user_name }}"
changed_when: false

# When upgrading we need to map existing instances to the new cell1
# To do this we need the cell UUID.
- name: Get UUID of new Nova Cell
shell: "{{ _db_nova_bin }}/nova-manage cell_v2 list_cells | grep ' {{ _db_nova_cell1_name }} '"
become: yes
become_user: "{{ _db_nova_system_user_name }}"
register: cell1_uuid
changed_when: false

- name: Map instances to new Cell1
command: "{{ _db_nova_bin }}/nova-manage cell_v2 map_instances --cell_uuid {{ cell1_uuid['stdout'].split()[3] }}"
become: yes
become_user: "{{ _db_nova_system_user_name }}"
changed_when: false
15 changes: 15 additions & 0 deletions tasks/nova_db_setup.yml
Expand Up @@ -73,3 +73,18 @@
when:
- not data_migrations | skipped
- data_migrations | succeeded

# When upgrading we need to map existing instances to the new cell1
# To do this we need the cell UUID.
- name: Get UUID of new Nova Cell
shell: "{{ nova_bin }}/nova-manage cell_v2 list_cells | grep ' {{ nova_cell1_name }} '"
become: yes
become_user: "{{ nova_system_user_name }}"
register: cell1_uuid
changed_when: false

- name: Map instances to new Cell1
command: "{{ nova_bin }}/nova-manage cell_v2 map_instances --cell_uuid {{ cell1_uuid['stdout'].split()[3] }}"
become: yes
become_user: "{{ nova_system_user_name }}"
changed_when: false

0 comments on commit c581c2a

Please sign in to comment.