Upgrading a geo instance results in error rendering pg_hba.conf template
On attempting to upgrade a Geo instance from Gitlab-EE 9.2.2 -> 9.3.0, we encountered an error in the Chef process when it was trying to render the pg_hba.conf template. The full error context is below.
- omnibus-gitlab package version: gitlab-ee-9.3.0-ee.0.el7.x86_64
- This issue occurred on an upgrade
- The system is a CentOS 7.3 VM only running the Gitlab Geo setup
We had to add the following block to the gitlab.rb file in order to get past the issue:
geo_postgresql['custom_pg_hba_entries'] = []
Please let me know if there are other sections you would like to see.
Perhaps this needs to be added to the default attributes for the gitlab-ee cookbook?
================================================================================
Error executing action `create` on resource 'template[/var/opt/gitlab/geo-postgresql/data/pg_hba.conf]'
================================================================================
Chef::Mixin::Template::TemplateError
------------------------------------
undefined method `each' for nil:NilClass
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/geo-postgresql.rb
86: template pg_hba_config do
87: source 'pg_hba.conf.erb'
88: owner postgresql_username
89: mode '0644'
90: variables(node['gitlab']['geo-postgresql'].to_hash)
91: cookbook 'gitlab'
92: notifies :restart, 'service[geo-postgresql]', :immediately if should_notify
93: end
94:
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/geo-postgresql.rb:86:in `from_file'
template("/var/opt/gitlab/geo-postgresql/data/pg_hba.conf") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source "pg_hba.conf.erb"
cookbook "gitlab"
variables {"enable"=>true, "ha"=>false, "dir"=>"/var/opt/gitlab/geo-postgresql", "data_dir"=>"/var/opt/gitlab/geo-postgresql/data", "log_directory"=>"/var/log/gitlab/geo-postgresql", "unix_socket_directory"=>"/var/opt/gitlab/geo-postgresql", "sql_user"=>"gitlab_geo", "port"=>5431, "listen_address"=>nil, "max_connections"=>200, "md5_auth_cidr_addresses"=>[], "trust_auth_cidr_addresses"=>[], "shared_buffers"=>"1024MB", "work_mem"=>"8MB", "maintenance_work_mem"=>"16MB", "effective_cache_size"=>"2048MB", "log_min_duration_statement"=>-1, "checkpoint_segments"=>10, "min_wal_size"=>"80MB", "max_wal_size"=>"1GB", "checkpoint_timeout"=>"5min", "checkpoint_completion_target"=>0.9, "checkpoint_warning"=>"30s", "wal_buffers"=>"-1", "autovacuum"=>"on", "log_autovacuum_min_duration"=>"-1", "autovacuum_max_workers"=>"3", "autovacuum_naptime"=>"1min", "autovacuum_vacuum_threshold"=>"50", "autovacuum_analyze_threshold"=>"50", "autovacuum_vacuum_scale_factor"=>"0.02", "autovacuum_analyze_scale_factor"=>"0.01", "autovacuum_freeze_max_age"=>"200000000", "autovacuum_vacuum_cost_delay"=>"20ms", "autovacuum_vacuum_cost_limit"=>"-1", "statement_timeout"=>"0", "log_line_prefix"=>nil, "track_activity_query_size"=>"1024", "shared_preload_libraries"=>nil, "wal_level"=>"minimal", "max_wal_senders"=>0, "wal_keep_segments"=>10, "hot_standby"=>"off", "max_standby_archive_delay"=>"30s", "max_standby_streaming_delay"=>"30s", "max_replication_slots"=>0, "synchronous_commit"=>"on", "synchronous_standby_names"=>"", "hot_standby_feedback"=>"off", "archive_mode"=>"off", "archive_command"=>nil, "archive_timeout"=>"60", "bootstrap"=>false}
declared_type :template
cookbook_name "gitlab-ee"
recipe_name "geo-postgresql"
mode "0644"
owner "gitlab-psql"
path "/var/opt/gitlab/geo-postgresql/data/pg_hba.conf"
end
Template Context:
-----------------
on line #68
66:
67: # TYPE DATABASE USER CIDR-ADDRESS METHOD
68: <% @custom_pg_hba_entries.each do |entry| %>
69: <%= entry['type'] %> <%= entry['database'] %> <%= entry['user'] %> <%= entry['cidr'] %> <%= entry['method'] %> <%= entry['option'] %>
70: <% end %>
Platform:
---------
x86_64-linux