Allow remote detection of repo sync status

If a repo container and its data are deleted and recreated then it is
not currently possible for a loadbalancer healthcheck to differentiate
between an empty repo server and a correctly synchronised one.

This patch creates a file 'repo-sync-complete' as part of the process
of synchronising repo contents from master repo servers to slaves. The
presence of this file on the slave can then be used as the loadbalancer
healthcheck to ensure that repo contents are only served once sync has
completed.

In addition, this patch ensures that synchronisation occurs from the
master to a reprovisioned slave by triggering a master repo server lsyncd
restart handler during the initial setup of the slave repo server.
Currently, a freshly provisioned repo server will remain empty
for an indeterminate amount of time, this patch forces a complete re-sync
to occur.

Change-Id: I6913341674dbde5524c2270e824bda4544211eca
This commit is contained in:
Georgina 2019-05-22 17:05:01 +00:00 committed by Dmitriy Rabotyagov
parent 7f58e1cc61
commit 7132acbd3b
5 changed files with 15 additions and 1 deletions

View File

@ -45,3 +45,5 @@
until: _restart is success
retries: 5
delay: 2
delegate_to: "{{ groups['repo_all'][0] }}"
run_once: true

View File

@ -53,6 +53,7 @@
dest: "/etc/nginx/sites-available/openstack-slushee.vhost"
notify:
- reload nginx
- reload lsyncd
- name: Drop rsyncd configuration file
template:

View File

@ -50,6 +50,15 @@
- path: "/var/log/nginx"
mode: "0775"
- name: Sync file for master repo node
file:
path: "{{ repo_service_home_folder }}/repo/repo_sync_complete"
state: "touch"
owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}"
when: inventory_hostname == groups['repo_all'][0]
changed_when: False
- name: Drop repo pre/post command script
template:
src: repo_prepost_cmd.sh.j2

View File

@ -618,7 +618,7 @@ sync {
rsync,
source = "{{ repo_service_home_folder }}/repo",
target = "{{ hostvars[node]['ansible_host'] }}:{{ repo_service_home_folder }}/repo",
exclude = "{{ repo_build_global_links_dirname }}",
exclude = {"{{ repo_build_global_links_dirname }}","/repo_sync_complete"},
rsync = {
compress = true,
acls = true,

View File

@ -6,10 +6,12 @@ case $CMD in
pre-www)
rm /etc/nginx/sites-enabled/openstack-slushee.vhost
systemctl reload nginx
rm -f {{ repo_service_home_folder }}/repo/repo_sync_complete
;;
post-www)
ln -s /etc/nginx/sites-available/openstack-slushee.vhost /etc/nginx/sites-enabled/openstack-slushee.vhost
systemctl reload nginx
touch {{ repo_service_home_folder }}/repo/repo_sync_complete
;;
*)
echo "Unknown command."