Skip to content

Failed to reconfigure when `postgresql['listen_address']` is set to not null

Summary

Failed to reconfigure when postgresql['listen_address'] is set to not null (nil).

Steps to reproduce

  1. Download gitlab-ce_12.1.3-ce.0_amd64.deb and install it by dpkg -i ./gitlab-ce_12.1.3-ce.0_amd64.deb;
  2. Run gitlab-ctl reconfigure and it is OK;
  3. Modify the file /etc/gitlab/gitlab.rb as follows:
postgresql['enable'] = true
postgresql['listen_address'] = nil
postgresql['port'] = 5432
postgresql['data_dir'] = "/var/opt/gitlab/postgresql/data"
  1. Run gitlab-ctl reconfigure again.

If I set postgresql['listen_address'] = '0.0.0.0' or postgresql['listen_address'] = '192.168.1.26' or postgresql['listen_address'] = '*', reconfiguration aborts.

Example Project

This has nothing to do with specific projects.

What is the current bug behavior?

Reconfiguration aborts.

What is the expected correct behavior?

Reconfiguration successfully exits and the Postgresql database can listen on the IP address which I set.

Relevant logs and/or screenshots

Here is the main part of the output of gitlab-ctl reconfigure command.

Recipe: gitlab::database_migrations
  * bash[migrate gitlab-rails database] action run
    [execute] rake aborted!
              PG::ConnectionBad: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on
              FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off
              /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:55:in `block (3 levels) in <top (required)>'
              /opt/gitlab/embedded/bin/bundle:23:in `load'
              /opt/gitlab/embedded/bin/bundle:23:in `<main>'
              Tasks: TOP => gitlab:db:configure
              (See full trace by running task with --trace)
    
    ================================================================================
    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-script20190802-87471-1ittnoy" ----
    STDOUT: rake aborted!
    PG::ConnectionBad: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on
    FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:55:in `block (3 levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'
    Tasks: TOP => gitlab:db:configure
    (See full trace by running task with --trace)
    STDERR: 
    ---- End output of "bash"  "/tmp/chef-script20190802-87471-1ittnoy" ----
    Ran "bash"  "/tmp/chef-script20190802-87471-1ittnoy" returned 1
    
    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb
    
     53: bash "migrate gitlab-rails database" do
     54:   code <<-EOH
     55:     set -e
     56:     log_file="#{node['gitlab']['gitlab-rails']['log_directory']}/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log"
     57:     umask 077
     58:     /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
     59:     STATUS=${PIPESTATUS[0]}
     60:     echo $STATUS > #{db_migrate_status_file}
     61:     exit $STATUS
     62:   EOH
     63:   environment env_variables unless env_variables.empty?
     64:   notifies :run, "execute[clear the gitlab-rails cache]", :immediately
     65:   dependent_services.each do |svc|
     66:     notifies :restart, svc, :immediately
     67:   end
     68:   not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
     69:   only_if { node['gitlab']['gitlab-rails']['auto_migrate'] }
     70: end
    
    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:53:in `from_file'
    
    bash("migrate gitlab-rails database") do
      action [:run]
      default_guard_interpreter :default
      command nil
      backup 5
      interpreter "bash"
      declared_type :bash
      cookbook_name "gitlab"
      recipe_name "database_migrations"
      code "    set -e\n    log_file=\"/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log\"\n    umask 077\n    /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}\n    STATUS=${PIPESTATUS[0]}\n    echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-44b9ce5a9022698939f44e592affbdd1-f9abaa7d833\n    exit $STATUS\n"
      domain nil
      user nil
      not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-44b9ce5a9022698939f44e592affbdd1-f9abaa7d833) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-44b9ce5a9022698939f44e592affbdd1-f9abaa7d833 | grep -Fx 0)"
      only_if { #code block }
    end
    
    System Info:
    ------------
    chef_version=14.13.11
    platform=ubuntu
    platform_version=18.04
    ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
    program_name=/opt/gitlab/embedded/bin/chef-client
    executable=/opt/gitlab/embedded/bin/chef-client
    
Recipe: <Dynamically Defined Resource>
  * service[unicorn] action restart
    - restart service service[unicorn]
  * service[sidekiq] action restart
    - restart service service[sidekiq]

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 53) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20190802-87471-1ittnoy" ----
STDOUT: rake aborted!
PG::ConnectionBad: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on
FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:55:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR: 
---- End output of "bash"  "/tmp/chef-script20190802-87471-1ittnoy" ----
Ran "bash"  "/tmp/chef-script20190802-87471-1ittnoy" returned 1

Running handlers complete
Chef Client failed. 7 resources updated in 20 seconds

Output of checks

None.

Results of GitLab environment info

Expand for output related to GitLab environment info

System information System: Ubuntu 18.04 Current User: git Using RVM: no Ruby Version: 2.6.3p62 Gem Version: 2.7.9 Bundler Version:1.17.3 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.21.0 Sidekiq Version:5.2.7 Go Version: unknown rake aborted! PG::ConnectionBad: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/info.rake:48:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load' /opt/gitlab/embedded/bin/bundle:23:in `' Tasks: TOP => gitlab:env:info (See full trace by running task with --trace)

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 9.3.0 ? ... OK (9.3.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: FAILED: Failed to connect to internal API gitlab-shell self-check failed Try fixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml Please fix the error above and rerun the checks.

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... Exception: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... no Try fixing it: sudo -u git -H RAILS_ENV=production bin/background_jobs start For more information see: doc/install/installation.md in section "Install Init Script" see log/sidekiq.log for possible errors Please fix the error above and rerun the checks.

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... Exception: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off

GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... Exception: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off

Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.3) Git version >= 2.21.0 ? ... yes (2.21.0) Git user has default SSH configuration? ... yes Active users: ... Exception: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL on FATAL: no pg_hba.conf entry for host "127.0.0.1", user "gitlab", database "gitlabhq_production", SSL off

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

I do not know ruby, so I cannot help to solve it in programming.