Improve repo server haproxy healthcheck to verify repo synchronisation

This patch updates the healthcheck to test for the presence of the file
/var/www/repo/repo_sync_complete.
This addresses an issue where haproxy would direct traffic to redeployed
repo servers which were correctly serving the web root but had no
meaningful content.
The repo_sync_complete file is created by related changes to the
repo_server ansible role.

Partial-Bug: 1829930
Depends-On: https://review.opendev.org/660788/

Change-Id: Ib7b64b09413fbdd8c630311d437539c9f876fac0
This commit is contained in:
Georgina 2019-05-21 17:39:16 +00:00 committed by Dmitriy Rabotyagov
parent b053c2019e
commit 215bc46f80
4 changed files with 12 additions and 3 deletions

View File

@ -140,6 +140,7 @@ shared-infra_hosts:
galera_container: 3 galera_container: 3
memcached_container: 3 memcached_container: 3
rabbit_mq_container: 3 rabbit_mq_container: 3
repo_container: 3
{% endif %} {% endif %}
repo-infra_hosts: repo-infra_hosts:

View File

@ -68,7 +68,9 @@ haproxy_default_services:
haproxy_port: 8181 haproxy_port: 8181
haproxy_balance_type: http haproxy_balance_type: http
haproxy_backend_options: haproxy_backend_options:
- "httpchk HEAD / HTTP/1.0\\r\\nUser-agent:\\ osa-haproxy-healthcheck" - "httpchk GET /repo_sync_complete HTTP/1.0\\r\\nUser-agent:\\ osa-haproxy-healthcheck"
haproxy_backend_httpcheck_options:
- "expect status 200"
haproxy_service_enabled: "{{ groups['repo_all'] is defined and groups['repo_all'] | length > 0 }}" haproxy_service_enabled: "{{ groups['repo_all'] is defined and groups['repo_all'] | length > 0 }}"
- service: - service:
haproxy_service_name: glance_api haproxy_service_name: glance_api

View File

@ -24,9 +24,9 @@
hosts: all_containers[0]:physical_hosts[0] hosts: all_containers[0]:physical_hosts[0]
gather_facts: yes gather_facts: yes
vars: vars:
repo_requirements_file: "os-releases/{{ openstack_release }}/{{ os_distro_version }}/" repo_requirements_file: "repo_sync_complete"
tasks: tasks:
- name: Check the upper constraint on each repo server - name: Check the repo sync file on each repo server
uri: uri:
url: "http://{{ hostvars[item]['container_address'] }}:{{ repo_server_port }}/{{ repo_requirements_file }}" url: "http://{{ hostvars[item]['container_address'] }}:{{ repo_server_port }}/{{ repo_requirements_file }}"
with_inventory_hostnames: "{{ groups['repo_all'] }}" with_inventory_hostnames: "{{ groups['repo_all'] }}"

View File

@ -0,0 +1,6 @@
---
other:
- |
HAProxy now verifies if repo server is healthy by ``repo_sync_complete``
file that is created with repo_server role. This should prevent
non-synced repo containers from participating in load balancing.