aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/nova-cell/handlers/main.yml
blob: 2dcca1546f861d7cff94a61c40dda11069a3aadc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
---
- name: Restart nova-conductor container
  vars:
    service_name: "nova-conductor"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"
  when:
    - kolla_action != "upgrade" or not nova_safety_upgrade | bool

- name: Restart nova-novncproxy container
  vars:
    service_name: "nova-novncproxy"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"
  when:
    - kolla_action != "upgrade" or not nova_safety_upgrade | bool

- name: Restart nova-spicehtml5proxy container
  vars:
    service_name: "nova-spicehtml5proxy"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"
  when:
    - kolla_action != "upgrade" or not nova_safety_upgrade | bool

- name: Restart nova-serialproxy container
  vars:
    service_name: "nova-serialproxy"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"
  when:
    - kolla_action != "upgrade" or not nova_safety_upgrade | bool

- name: Restart nova-ssh container
  vars:
    service_name: "nova-ssh"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    pid_mode: "{{ service.pid_mode | default('') }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"

- name: Restart nova-libvirt container
  vars:
    service_name: "nova-libvirt"
    service: "{{ nova_cell_services[service_name] }}"
    nova_libvirt_notify: "{{ ['Checking libvirt container is ready', 'Create libvirt SASL user'] if libvirt_enable_sasl | bool else [] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    pid_mode: "{{ service.pid_mode | default('') }}"
    cgroupns_mode: "{{ service.cgroupns_mode | default(omit) }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"
  register: restart_nova_libvirt
  # NOTE(Jeffrey4l): retry 5 to remove nova_libvirt container because when
  # guests running, nova_libvirt will raise error even though it is removed.
  retries: 5
  until: restart_nova_libvirt is success
  notify: "{{ nova_libvirt_notify }}"

# need to wait kolla_set_configs script to overwrite sasl config file
- name: Checking libvirt container is ready
  become: true
  shell:
    cmd: >
      set -o pipefail &&
      {{ kolla_container_engine }} exec -i nova_libvirt ls /run/libvirtd.pid
    executable: /bin/bash
  register: libvirt_container_ready
  until: libvirt_container_ready is succeeded
  retries: 10

# The SASL user needs to exist in order for nova-compute to start successfully.
- name: Create libvirt SASL user
  become: true
  shell:
    cmd: >
      set -o pipefail &&
      echo {{ libvirt_sasl_password }} |
      {{ kolla_container_engine }} exec -i nova_libvirt
      saslpasswd2 -c -p -a libvirt {{ libvirt_sasl_authname }}
    executable: /bin/bash
  changed_when: true
  no_log: true

- name: Reload libvirtd
  become: true
  service:
    name: libvirtd
    state: reloaded
  when:
    - kolla_action != "config"

- name: Restart nova-compute container
  vars:
    service_name: "nova-compute"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    environment: "{{ service.environment }}"
    image: "{{ service.image }}"
    privileged: "{{ service.privileged | default(False) }}"
    ipc_mode: "{{ service.ipc_mode }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"

- name: Restart nova-compute-ironic container
  vars:
    service_name: "nova-compute-ironic"
    service: "{{ nova_cell_services[service_name] }}"
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "{{ service.container_name }}"
    image: "{{ service.image }}"
    privileged: "{{ service.privileged | default(False) }}"
    volumes: "{{ service.volumes | reject('equalto', '') | list }}"
    dimensions: "{{ service.dimensions }}"
    healthcheck: "{{ service.healthcheck | default(omit) }}"

# nova-compute-fake is special. It will start multi numbers of container
# so put all variables here rather than defaults/main.yml file
- name: Restart nova-compute-fake containers
  become: true
  kolla_container:
    action: "recreate_or_restart_container"
    common_options: "{{ docker_common_options }}"
    name: "nova_compute_fake_{{ item }}"
    image: "{{ nova_compute_image_full }}"
    privileged: true
    volumes:
      - "{{ node_config_directory }}/nova-compute-fake-{{ item }}/:{{ container_config_directory }}/:ro"
      - "/etc/localtime:/etc/localtime:ro"
      - "/lib/modules:/lib/modules:ro"
      - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"
      - "/run/netns:/run/netns:shared"
      - "/run/lock/nova:/run/lock/nova:shared"
      - "/run/libvirt:/run/libvirt:shared"
      - "/run/nova:/run/nova:shared"
      - "/run/openvswitch:/run/openvswitch:shared"
      - "kolla_logs:/var/log/kolla/"
  with_sequence: start=1 end={{ num_nova_fake_per_node }}

# NOTE(mgoddard): After upgrading nova-compute, services will have an RPC
# version cap in place.  We need to restart all services that communicate with
# nova-compute in order to allow them to use the latest RPC version. Ideally,
# there would be a way to check whether all nova services are using the latest
# version, but currently there is not. Instead, wait a short time for all nova
# compute services to update the version of their service in the database.
# This seems to take around 10 seconds, but the default is 30 to allow room
# for slowness.

- name: Wait for nova-compute services to update service versions
  pause:
    seconds: "{{ nova_compute_startup_delay }}"
  run_once: true
  when:
    - kolla_action == 'upgrade'
  listen:
    - Restart nova-compute container
    - Restart nova-compute-ironic container
    - Restart nova-compute-fake containers