DiUS / pact_broker-docker

'Dockerised' pact broker
http://pact.io
MIT License
76 stars 102 forks source link

Pact Broker fails to connect to Aurora PostgreSQL database #100

Closed mahm-ali closed 4 years ago

mahm-ali commented 4 years ago

Pre issue-raising checklist

I have already (please mark the applicable with an x):

Software versions

Expected behaviour

The server comes up.

Actual behaviour

The pod is crashing and the pact-broker service isn't coming up.

Steps to reproduce

I'm trying to deploy the latest pact-broker version and using an Aurora PostgreSQL clustered database to store the data but getting the failure below. I tried this with 2 different pact broker versions and got the same results.

v. 2.31.0-1 and 2.58.3.0

Relevent log files

[ E 2020-08-19 02:16:34.4818 35/T8 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 52987d51. Please see earlier logs for details about the error. App 493 output: I, [2020-08-19T02:16:35.417622 #493] INFO -- : PACT_BROKER_DATABASE_USERNAME=pactbroker App 493 output: I, [2020-08-19T02:16:35.417653 #493] INFO -- : PACT_BROKER_WEBHOOK_SCHEME_WHITELIST=http https App 493 output: I, [2020-08-19T02:16:35.417662 #493] INFO -- : PACT_BROKER_DATABASE_PASSWORD= App 493 output: I, [2020-08-19T02:16:35.417668 #493] INFO -- : PACT_BROKER_DATABASE_ADAPTER=postgres App 493 output: I, [2020-08-19T02:16:35.417682 #493] INFO -- : PACT_BROKER_DATABASE_NAME=pact_broker App 493 output: I, [2020-08-19T02:16:35.417687 #493] INFO -- : PACT_BROKER_LOG_LEVEL=DEBUG App 493 output: I, [2020-08-19T02:16:35.417695 #493] INFO -- : PACT_BROKER_DATABASE_HOST=HOST App 493 output: I, [2020-08-19T02:16:35.417745 #493] INFO -- : Connecting to database with config: {:adapter=>"postgres", :user=>"pactbroker", :password=>"", :host=>"", :database=>"pact_broker", :encoding=>"utf8"} App 493 output: Error: The application encountered the following error: PG::ConnectionBad: timeout expired App 493 output: (Sequel::DatabaseConnectionError) App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/adapters/postgres.rb:206:in initialize' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/adapters/postgres.rb:206:innew' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/adapters/postgres.rb:206:in connect' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/connection_pool.rb:122:inmake_new' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/connection_pool/threaded.rb:209:in assign_connection' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/connection_pool/threaded.rb:139:inacquire' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/connection_pool/threaded.rb:91:in hold' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/database/connecting.rb:253:insynchronize' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/database/connecting.rb:279:in test_connection' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/database/connecting.rb:58:inconnect' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/sequel-5.19.0/lib/sequel/core.rb:121:in connect' App 493 output: /home/app/pact_broker/database_connection.rb:39:increate_database_connection' App 493 output: config.ru:14:in block (2 levels) in <main>' App 493 output: /home/app/pact_broker/vendor/bundle/ruby/2.4.0/gems/pact_broker-2.31.0/lib/pact_broker/app.rb:33:ininitialize'

mefellows commented 4 years ago

The host value looks empty to me, is that just an artifact of the way you've raised the ticket?

I.e. PACT_BROKER_DATABASE_HOST= has no value

mahm-ali commented 4 years ago

The host value looks empty to me, is that just an artifact of the way you've raised the ticket?

I.e. PACT_BROKER_DATABASE_HOST= has no value

@mefellows I removed the hostname from the logs, but it is getting set properly.

mahm-ali commented 4 years ago

@mefellows do we know if Aurora postgres is supported and works with the adapter postgres or foes it need a different adapter?

mefellows commented 4 years ago

Aurora postgres is wire compatible with postgres so as my understanding goes it should work.

One way to test is to setup a standard postgres RDS database and see if you have the same issue.

Then you could rule out things like security groups or VPC routes

mahm-ali commented 4 years ago

Thanks for your help @mefellows. Yes it turned out to be a security group issue. Closing the ticket.