Merge branch 'enable_pg_trgm_with_before_run' into 'master'

Chef 12.6 introduced :before, use it to enable extension before migration or database seed.

With gitlab-org/omnibus-gitlab!704 , Chef got upgraded to 12.6.

That version has a new feature to run a notification before resource is ran.

Use this feature to resolve gitlab-org/omnibus-gitlab#1189 
.(and similar)

See merge request !705
This commit is contained in:
Marin Jankovski 2016-03-29 15:25:25 +00:00
commit fd6c88e062
4 changed files with 2 additions and 2 deletions

View File

@ -26,6 +26,7 @@ define :migrate_database, :command => nil, :action => :run, :restarts => [] do
exit ${PIPESTATUS[0]}
EOH
action params[:action]
notifies :run, 'execute[enable pg_trgm extension]', :before unless OmnibusHelper.not_listening?("posgresql") || !node['gitlab']['postgresql']['enable']
notifies :run, "execute[clear the #{params[:name]} cache]", :immediately unless OmnibusHelper.not_listening?("redis")
params[:restarts].each do |svc|
notifies :restart, svc, :immediately

View File

@ -25,6 +25,7 @@ execute "initialize gitlab-rails database" do
command "/opt/gitlab/bin/gitlab-rake db:schema:load db:seed_fu"
environment ({'GITLAB_ROOT_PASSWORD' => initial_root_password }) if initial_root_password
action :nothing
notifies :run, 'execute[enable pg_trgm extension]', :before unless OmnibusHelper.not_listening?("posgresql") || !node['gitlab']['postgresql']['enable']
end
migrate_database 'gitlab-rails' do

View File

@ -289,7 +289,6 @@ end
# Only run `rake db:migrate` when the gitlab-rails version has changed
remote_file File.join(gitlab_rails_dir, 'VERSION') do
source "file:///opt/gitlab/embedded/service/gitlab-rails/VERSION"
notifies :run, 'execute[enable pg_trgm extension]', :immediately unless postgresql_not_listening || !node['gitlab']['postgresql']['enable']
notifies :run, 'bash[migrate gitlab-rails database]' unless postgresql_not_listening
notifies :run, 'execute[clear the gitlab-rails cache]' unless redis_not_listening
notifies :run, 'bash[generate assets]' if node['gitlab']['gitlab-rails']['gitlab_relative_url']

View File

@ -154,7 +154,6 @@ if node['gitlab']['gitlab-rails']['enable']
command "#{bin_dir}/createdb --port #{pg_port} -h #{postgresql_socket_dir} -O #{gitlab_sql_user} #{database_name}"
user postgresql_user
retries 30
notifies :run, "execute[enable pg_trgm extension]", :immediately
notifies :run, "execute[initialize gitlab-rails database]", :immediately
not_if { !pg_helper.is_running? || pg_helper.database_exists?(database_name) }
end