gitlab-ctl reconfigure does not exit with an non-zero value when chef-zero fails
Running this all on CentOS 7 and bash. I've noticed that the cookbook gitlab-ctl reconfigure often needs multiple runs to complete successfully (separate issue, not terribly concerned about it, not going to get into it here). In attempting to automate around this, I opted to try using the $? value. However, gitlab-ctl reconfigure seems to exit 0 even if the chef-zero run fails. See below.
...snip...
================================================================================
Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20160707-27146-1gw1kc6" ----
STDOUT: rake aborted!
PG::ConnectionBad: could not translate host name "nil" to address: Temporary failure in name resolution
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
...snip...
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
STDERR:
---- End output of "bash" "/tmp/chef-script20160707-27146-1gw1kc6" ----
Ran "bash" "/tmp/chef-script20160707-27146-1gw1kc6" returned 1
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb
41: bash "migrate gitlab-rails database" do
42: code <<-EOH
43: set -e
44: log_file="/tmp/gitlab-rails-db-migrate-$(date +%s)-$$/output.log"
45: umask 077
46: mkdir $(dirname ${log_file})
47: /opt/gitlab/bin/gitlab-rake db:migrate 2>& 1 | tee ${log_file}
48: STATUS=${PIPESTATUS[0]}
49: echo $STATUS > #{db_migrate_status_file}
50: exit $STATUS
51: EOH
52: notifies :run, 'execute[enable pg_trgm extension]', :before unless OmnibusHelper.not_listening?("postgresql") || !node['gitlab']['postgresql']['enable']
53: notifies :run, "execute[clear the gitlab-rails cache]", :immediately unless OmnibusHelper.not_listening?("redis")
54: dependent_services.each do |svc|
55: notifies :restart, svc, :immediately
56: end
57: not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
58: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:41:in `from_file'
bash("migrate gitlab-rails database") do
action [:run]
updated true
retries 0
retry_delay 2
default_guard_interpreter :default
command "migrate gitlab-rails database"
backup 5
returns 0
code " set -e\n log_file=\"/tmp/gitlab-rails-db-migrate-$(date +%s)-$$/output.log\"\n umask 077\n mkdir $(dirname ${log_file})\n /opt/gitlab/bin/gitlab-rake db:migrate 2>& 1 | tee ${log_file}\n STATUS=${PIPESTATUS[0]}\n echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-42dceaa\n exit $STATUS\n"
interpreter "bash"
declared_type :bash
cookbook_name "gitlab"
recipe_name "database_migrations"
not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-42dceaa) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-42dceaa | grep -Fx 0)"
end
[vagrant@gitlab-centos-71 log] []$ echo $?
0