From 1abd15d4a6b3f52656a334a6439bd3cc08887e93 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 16 Jul 2019 10:51:47 +0100 Subject: [PATCH] Fix glance bootstrap with file backend Change https://review.opendev.org/#/c/670247/ attempted to fix glance deployment with the file backend. However, it added a new bug by being more strict about only generating configuration where the container will be deployed. This means that the current method of running the glance bootstrap container on any host in glance-api group could be broken, since it needs the container configuration. This change only runs the bootstrap container on hosts in the glance_api_hosts list, which in the case of the file backend typically only contains one host. This change also fixes up some logic during rolling upgrade, where we might not generate new configuration for the bootstrap host. Change-Id: I83547cd83b06ddefb3a9e1f39844537bdb32bd7f Related-Bug: #1836151 --- .../roles/glance/tasks/bootstrap_service.yml | 10 +++------- .../roles/glance/tasks/rolling_upgrade.yml | 20 ++++++++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/ansible/roles/glance/tasks/bootstrap_service.yml b/ansible/roles/glance/tasks/bootstrap_service.yml index f182d7d689..c460aff68e 100644 --- a/ansible/roles/glance/tasks/bootstrap_service.yml +++ b/ansible/roles/glance/tasks/bootstrap_service.yml @@ -1,7 +1,5 @@ --- - name: Enable log_bin_trust_function_creators function - vars: - glance_api: "{{ glance_services['glance-api'] }}" become: true kolla_toolbox: module_name: mysql_variables @@ -13,7 +11,7 @@ variable: log_bin_trust_function_creators value: 1 run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" when: - not use_preconfigured_databases | bool @@ -35,11 +33,9 @@ restart_policy: "never" volumes: "{{ glance_api.volumes|reject('equalto', '')|list }}" run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" - name: Disable log_bin_trust_function_creators function - vars: - glance_api: "{{ glance_services['glance-api'] }}" become: true kolla_toolbox: module_name: mysql_variables @@ -51,6 +47,6 @@ variable: log_bin_trust_function_creators value: 0 run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" when: - not use_preconfigured_databases | bool diff --git a/ansible/roles/glance/tasks/rolling_upgrade.yml b/ansible/roles/glance/tasks/rolling_upgrade.yml index c971507faa..71ef9de722 100644 --- a/ansible/roles/glance/tasks/rolling_upgrade.yml +++ b/ansible/roles/glance/tasks/rolling_upgrade.yml @@ -4,14 +4,12 @@ # Upgrade first node (NEW NODE in the Glance documentation) - include_tasks: config.yml - when: inventory_hostname == groups["glance-api"][0] + when: inventory_hostname == glance_api_hosts[0] - include_tasks: stop_service.yml - when: inventory_hostname == groups["glance-api"][0] + when: inventory_hostname == glance_api_hosts[0] - name: Enable log_bin_trust_function_creators function - vars: - glance_api: "{{ glance_services['glance-api'] }}" become: true kolla_toolbox: module_name: mysql_variables @@ -23,7 +21,7 @@ variable: log_bin_trust_function_creators value: 1 run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" when: - not use_preconfigured_databases | bool @@ -46,7 +44,7 @@ restart_policy: "never" volumes: "{{ glance_api.volumes }}" run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" - name: Running Glance database migrate container vars: @@ -67,13 +65,13 @@ restart_policy: "never" volumes: "{{ glance_api.volumes }}" run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" notify: - Restart glance-api container # Upgrade remaining node - include_tasks: config.yml - when: inventory_hostname != groups["glance-api"][0] + when: inventory_hostname != glance_api_hosts[0] - name: Flush handlers meta: flush_handlers @@ -97,11 +95,9 @@ restart_policy: "never" volumes: "{{ glance_api.volumes }}" run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" - name: Disable log_bin_trust_function_creators function - vars: - glance_api: "{{ glance_services['glance-api'] }}" become: true kolla_toolbox: module_name: mysql_variables @@ -113,7 +109,7 @@ variable: log_bin_trust_function_creators value: 0 run_once: True - delegate_to: "{{ groups[glance_api.group][0] }}" + delegate_to: "{{ glance_api_hosts[0] }}" when: - not use_preconfigured_databases | bool