pact-foundation / pact-broker-docker

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

Pact Broker does not bind to `[::]`, only `0.0.0.0` #163

Open rmartine-ias opened 8 months ago

rmartine-ias commented 8 months ago

Pre issue-raising checklist

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

Software versions

Expected behaviour

Pact broker binds to ipv6 "any" address.

Actual behaviour

The containerized pact broker is not reachable in an ipv6-only environment.

Steps to reproduce

docker-compose -f docker-compose.yml up pact-broker # using example conf in this repo's root
curl [::1]:9292 # fails
curl 127.0.0.1:9292 # succeeds

Context

See also: https://pact-foundation.slack.com/archives/C9VPNUJR2/p1706574031623059

We're moving to ipv6-only kubernetes clusters. We're using https://github.com/pact-foundation/pact-broker-docker via the https://github.com/pact-foundation/pact-broker-chart. The container was failing to be reachable, because puma was only binding to the ipv4 port. We saw this by kubectl execing in and running netstat -nl:

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN

This is resolved by modifying entrypoint.sh to read bundle exec puma --bind 'tcp://[::]:9292' (note: --bind 'tcp://[::]' --port 9292 does NOT work.) Then we get:

tcp        0      0 :::9292                 :::*                    LISTEN

and everything works. Ideally, I think puma should bind to both the ipv4 and ipv6 "any" addresses.

bethesque commented 7 months ago

Thanks for the report. If you would like to submit the PR to fix this, I will approve it.

bethesque commented 7 months ago

The port is variable, btw, so the bind will need to go in https://github.com/pact-foundation/pact-broker-docker/blob/master/pact_broker/config/puma.rb and not be hardcoded to 9292

bethesque commented 7 months ago

Docs for bind https://www.rubydoc.info/gems/puma/Puma%2FDSL:bind which will replace the port https://www.rubydoc.info/gems/puma/Puma/DSL#port-instance_method in the config file

bethesque commented 7 months ago

The most recent release should support IPv6 any. Please try it out and let me know.

YOU54F commented 7 months ago

Release should be out shortly, we had a couple of issues holding it back but they've been resolved now (failing audit and gem update)

YOU54F commented 7 months ago

Going to reopen this, #170 introduced some test failures which we need to investigate further. I've pulled #170 from master for now