Skip to content
Snippets Groups Projects
Commit 451eb36e authored by Robert Marshall's avatar Robert Marshall Committed by Ian Baum
Browse files

Improve pgbouncer running? method

- PGBouncer commands check for if the service is running using a status
  check. This does not always work, as the service can be running
  without listening. Changed to run a command that should always work so
  that it verifies that PGBouncer is both running and ready.

Related https://gitlab.com/gitlab-org/gitlab-orchestrator/-/issues/195



Signed-off-by: default avatarRobert Marshall <rmarshall@gitlab.com>
parent 24324300
No related branches found
No related tags found
No related merge requests found
---
title: Improve pgbouncer running? method
merge_request: 4557
author:
type: fixed
Loading
Loading
@@ -93,6 +93,7 @@ execute 'generate databases.ini' do
node['consul']['watchers'].include?('postgresql') &&
File.exist?(node['gitlab']['pgbouncer']['databases_ini'])
end
retries 3
end
 
execute 'reload pgbouncer' do
Loading
Loading
Loading
Loading
@@ -105,7 +105,9 @@ module Pgbouncer
end
 
def running?
GitlabCtl::Util.run_command('gitlab-ctl status pgbouncer').error?
true if show_databases
rescue GitlabCtl::Errors::ExecutionError
false
end
 
def database_paused?
Loading
Loading
Loading
Loading
@@ -97,4 +97,24 @@ RSpec.describe Pgbouncer::Databases do
)
end
end
context 'with pgbouncer listening' do
before do
allow(@obj).to receive(:show_databases).and_return("nyan")
end
it 'should be running' do
expect(@obj.running?).to be true
end
end
context 'with pgbouncer not listening' do
before do
allow(@obj).to receive(:show_databases).and_raise(GitlabCtl::Errors::ExecutionError.new("nya", "nya", "neko"))
end
it 'should not be running' do
expect(@obj.running?).to be false
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment