pact-foundation / pact-broker-docker

Dockerized Pact Broker
https://pact.io
MIT License
107 stars 109 forks source link

Facing a problem establishing a connection with Postgres from k8s #182

Closed xxxsemyonxxx closed 1 month ago

xxxsemyonxxx commented 6 months ago

Pre issue-raising checklist

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

Software versions

Expected behaviour

Works locally in Docker as expected. When deployed, should act simillarly

Actual behaviour

Fails to start pact-broker app instance due the following error in k8s:

/pact_broker/vendor/bundle/ruby/3.2.0/gems/pg-1.5.5/lib/pg/connection.rb:696:inasync_connect_or_reset': PG::ConnectionBad: connection to server at "10.168.3.100", port 5432 failed: server closed the connection unexpectedly (Sequel::DatabaseConnectionError)`

Steps to reproduce

Provide a repository, gist or reproducable code snippet so that we can test the problem.

`FROM pactfoundation/pact-broker:latest

ENV PACT_BROKER_PORT_ENVIRONMENT_VARIABLE_NAME=PACT_BROKER_APPLICATION_PORT ENV PACT_BROKER_PORT=9292 ENV PACT_BROKER_DATABASE_ADAPTER="postgres" ENV PACT_BROKER_LOG_LEVEL="DEBUG" ENV PACT_BROKER_SQL_LOG_LEVEL="DEBUG" ENV PACT_BROKER_DATABASE_USERNAME="pact_broker" ENV PACT_BROKER_DATABASE_PASSWORD="xxxxxxxxxxx" ENV PACT_BROKER_DATABASE_HOST="pact-broker.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com" ENV PACT_BROKER_DATABASE_NAME="pact_broker" ENV PACT_BROKER_PUBLIC_HEARTBEAT=true`

Relevent log files

/pact_broker/vendor/bundle/ruby/3.2.0/gems/pg-1.5.5/lib/pg/connection.rb:696:inasync_connect_or_reset': PG::ConnectionBad: connection to server at "10.168.3.100", port 5432 failed: server closed the connection unexpectedly (Sequel::DatabaseConnectionError)

from /pact_broker/vendor/bundle/ruby/3.2.0/gems/pg-1.5.5/lib/pg/connection.rb:824:in `connect_to_hosts'

.......

2024-04-25 20:56:33.389634 I [7:3280] pact-broker -- Connecting to database: -- {:adapter=>"postgres", :user=>"pact_broker", :password=>"*****", :host=>"pact-broker.xxxxxxx.us-east-1.rds.amazonaws.com", :database=>"pact_broker", :encoding=>"utf8", :sql_log_level=>:debug, :enable_caller_logging=>false, :log_warn_duration=>5.0, :pool_timeout=>5, :driver_options=>{:options=>"-c statement_timeout=15s"}, :connect_max_retries=>0}

`

Please ensure you set logging to DEBUG and attach any relevant log files here (or link from a gist).

YOU54F commented 1 month ago

Many people have have successful deployments on k8s, we provide an example in this repository and helm charts are held here https://github.com/pact-foundation/pact-broker-chart

I would imagine this to be a network configuration issue, where your database is not accessible to the network your pact broker application is running on. This is out of scope for support I am afraid!