Env:info rake task fails on HA nodes without DB connection
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
On nodes that don't connect to the database (i.e. Redis-only HA nodes), the gitlab:env:info rake task will fail when trying to retrieve data from the DB, as there is no connection to the database.
Since the Redis node (in this example) doesn't need to connect to the DB, the error may be counter-intuitive as everything is actually healthy (and we mention using this task for getting information about the installation)
Steps to reproduce
- Either use in a Redis-only node in an HA setup, or run
gitlab-ctl stop postgresqlon a test instance to see the same error - Run
gitlab-rake gitlab:env:info- the task fails as it can't connect to the DB.
What is the current bug behavior?
The rake task fails when trying to retrieve data from the DB, even if that is not necessary for the specific node.
What is the expected correct behavior?
Maybe we should gracefully handle that and note that PG is not up or this node is not configured to connect to it, whilst still showing the other bits of info.
Relevant logs and/or screenshots
System information
System: Ubuntu 18.04
Proxy: no_proxy: domain.yourdomain.com
https_proxy: http://USERNAME:PASSWORD@example.com:8080
http_proxy: http://USERNAME:PASSWORD@example.com:8080
Current User: git
Using RVM: no
Ruby Version: 2.6.5p114
Gem Version: 2.7.10
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 5.0.7
Git Version: 2.24.1
Sidekiq Version:5.2.7
Go Version: unknown
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "0.0.0.0" and accepting
TCP/IP connections on port 5432?
/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 `<main>'
Tasks: TOP => gitlab:env:info
(See full trace by running task with --trace)
Possible fixes
Handling DB connections in the task.