Currently there is a race between the repo servers syncing and the first
role that attempts to install a pip package. This change ensures that
only the primary repo server is accessible until the slaves are synced.
This is achieved by adding a hook into lsyncd that allows a command to
be run before and after each sync. This command is an ssh command to
connect to the relevant secondary container and stop/start nginx. As the
nginx user is unprivileged, a sudoers file is added to allow nginx to be
stopped and started.
Notes on adding the hook into lsyncd:
* There is an existing script in lsyncd/examples for postcmd. This
works at a higher level by adding an event onto the stack for executing a
command once the sync has finished. I experimented with that but
events dont get fired for the initial recursive sync, only on
subsequent changes. As it is the initial sync that causes the problem
that this patch is addressing, I had to look at a lower level.
* The lsync lua C lib has an exec function, but it is hidden from
config scripts except through the spawn(...) function. However spawn
requires an event so can't be used for the initial sync.
* I ended up going outside the lsync framework and using lua's own
os.execute() function for pre/post cmds.
Reviewed: https:/ /review. openstack. org/279452 /git.openstack. org/cgit/ openstack/ openstack- ansible- repo_server/ commit/ ?id=b457f3bda65 a418884e1847759 e6bfa26a7ed5ab
Committed: https:/
Submitter: Jenkins
Branch: master
commit b457f3bda65a418 884e1847759e6bf a26a7ed5ab
Author: Hugh Saunders <email address hidden>
Date: Fri Feb 12 10:04:59 2016 +0000
Disable slave repo servers while syncing
Currently there is a race between the repo servers syncing and the first
role that attempts to install a pip package. This change ensures that
only the primary repo server is accessible until the slaves are synced.
This is achieved by adding a hook into lsyncd that allows a command to
be run before and after each sync. This command is an ssh command to
connect to the relevant secondary container and stop/start nginx. As the
nginx user is unprivileged, a sudoers file is added to allow nginx to be
stopped and started.
Notes on adding the hook into lsyncd:
* There is an existing script in lsyncd/examples for postcmd. This
works at a higher level by adding an event onto the stack for executing a
command once the sync has finished. I experimented with that but
events dont get fired for the initial recursive sync, only on
subsequent changes. As it is the initial sync that causes the problem
that this patch is addressing, I had to look at a lower level.
* The lsync lua C lib has an exec function, but it is hidden from
config scripts except through the spawn(...) function. However spawn
requires an event so can't be used for the initial sync.
* I ended up going outside the lsync framework and using lua's own
os.execute() function for pre/post cmds.
While this looks like a big patch, its actually a relatively small /github. com/hughsaunder s/lsyncd/ compare/ master. ..hughsaunders: rsync_prepost
change to the default rsync script. See
https:/
for a comparison.
Bug: #1543146 f1e01d21fbbec73 3872acb87a5
Change-Id: I045a4a6bf722d6