Fixes two race conditions in gitlab-ctl reconfigure.

1) An issue I observed in LXC test environments where the gitlab-runsvdir service status check would fail
due to the newly created config file not having been loaded by upstart. A manual configuration reload
has resolved this issue entirely.

I was seeing this issue approxmiately 1/10 first runs of reconfigure but only in my LXC environment
with this fix I have tested 100 runs without failure.

2)  Was a race condition between the postgresql server service being started (a command which returns before
the service is started) and the first sql command to create the user being run. I have added 20 retries to the
user creation command.

It may be that a better fix for this is to add a separate execute block after the service start to run an
arbitrary command in case a new first command is added before the user creation.
This commit is contained in:
Dave Birch 2015-08-06 18:57:03 +01:00
parent b8e4bdf47f
commit 83ce5ac3fe
2 changed files with 7 additions and 0 deletions

View File

@ -170,6 +170,8 @@ databases.each do |rails_app, db_name, sql_user|
execute "create #{sql_user} database user" do
command "#{bin_dir}/psql --port #{pg_port} -h #{postgresql_socket_dir} -d template1 -c \"CREATE USER #{sql_user}\""
user pg_user
# Added retries to give the service time to start on slower systems
retries 20
not_if { !pg_helper.is_running? || pg_helper.user_exists?(sql_user) }
end

View File

@ -25,6 +25,11 @@ cookbook_file "/etc/init/gitlab-runsvdir.conf" do
source "gitlab-runsvdir.conf"
end
# Reload the configuration to ensure the new conf file is loaded
execute "initctl reload-configuration" do
command "initctl repload-configuration"
end
# Keep on trying till the job is found :(
execute "initctl status gitlab-runsvdir" do
retries 30