From 959b7f79212cf8fee7f8c0d7abb124b37270798e Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Thu, 21 Apr 2022 18:54:10 +0200 Subject: [PATCH] Split haproxy and keepalived restarts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need this to be stop-start as haproxy and proxysql need to be reconfigured simultaneously when switching between them. This change also introduces checks for service enablement. Co-Authored-By: Radosław Piliszek Change-Id: I2e10f490305f3d8b1b7abbc66ddb40df65c37fe7 --- ansible/roles/loadbalancer/handlers/main.yml | 36 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/ansible/roles/loadbalancer/handlers/main.yml b/ansible/roles/loadbalancer/handlers/main.yml index 4adea1b1e7..f17d3f8aa0 100644 --- a/ansible/roles/loadbalancer/handlers/main.yml +++ b/ansible/roles/loadbalancer/handlers/main.yml @@ -46,7 +46,26 @@ listen: - Restart keepalived container -- name: Restart backup haproxy container +# NOTE(yoctozepto): We need the following to be stop-start as haproxy and +# proxysql need to be reconfigured simultaneously when switching between them. + +- name: Stop backup haproxy container + become: true + kolla_docker: + action: "stop_container" + # NOTE(kevko): backup node might not have haproxy yet - ignore + ignore_missing: true + common_options: "{{ docker_common_options }}" + name: "haproxy" + when: + - kolla_action != "config" + - groups.kolla_ha_is_master_False is defined + - inventory_hostname in groups.kolla_ha_is_master_False + listen: + - Restart haproxy container + - Restart keepalived container + +- name: Start backup haproxy container vars: service_name: "haproxy" service: "{{ loadbalancer_services[service_name] }}" @@ -64,6 +83,7 @@ - kolla_action != "config" - groups.kolla_ha_is_master_False is defined - inventory_hostname in groups.kolla_ha_is_master_False + - service.enabled | bool listen: - Restart haproxy container - Restart keepalived container @@ -92,6 +112,7 @@ - kolla_action != "config" - groups.kolla_ha_is_master_False is defined - inventory_hostname in groups.kolla_ha_is_master_False + - service.enabled | bool listen: - Restart keepalived container notify: @@ -103,6 +124,8 @@ become: true kolla_docker: action: "stop_container" + # NOTE(yoctozepto): master node might not have haproxy yet - ignore + ignore_missing: true common_options: "{{ docker_common_options }}" name: "haproxy" when: @@ -143,6 +166,7 @@ - kolla_action != "config" - groups.kolla_ha_is_master_True is defined - inventory_hostname in groups.kolla_ha_is_master_True + - service.enabled | bool listen: - Restart haproxy container - Restart keepalived container @@ -171,12 +195,20 @@ - kolla_action != "config" - groups.kolla_ha_is_master_True is defined - inventory_hostname in groups.kolla_ha_is_master_True + - service.enabled | bool listen: - Restart keepalived container notify: - Wait for virtual IP to appear -- name: Wait for virtual IP to appear +- name: Wait for haproxy to listen on VIP + vars: + service_name: "haproxy" + service: "{{ loadbalancer_services[service_name] }}" wait_for: host: "{{ kolla_internal_vip_address }}" port: "{{ haproxy_monitor_port }}" + when: + - service.enabled | bool + listen: + - Wait for virtual IP to appear