pact-foundation / pact-broker-docker

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

application doesn't start up in k8s #66

Closed SongGithub closed 3 years ago

SongGithub commented 3 years ago

Pre issue-raising checklist

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

Software versions

Expected behaviour

application starts up normally

Actual behaviour

It blows up during startup process which is scripted in entrypoint.sh bundle exec puma. Error: bundler: failed to load command: puma (/pact_broker/vendor/bundle/ruby/2.6.0/bin/puma) ArgumentError: invalid value for Integer(): "tcp://172.20.79.244:80" /pact_broker/vendor/bundle/ruby/2.6.0/gems/puma-5.4.0/lib/puma/dsl.rb:260:in Integer' /pact_broker/vendor/bundle/ruby/2.6.0/gems/puma-5.4.0/lib/puma/dsl.rb:260:inport'

And the code blows up is /pact_broker/vendor/bundle/ruby/2.6.0/gems/puma-5.4.0/lib/puma/dsl.rb:260:

    # Define the TCP port to bind to. Use +bind+ for more advanced options.
    #
    # @example
    #   port 9292
    def port(port, host=nil)
      host ||= default_host
      bind URI::Generic.build(scheme: 'tcp', host: host, port: Integer(port)).to_s
    end

So it expects a port number in Integer, but it got an address. I am confused.

Steps to reproduce

env var provided:

  - name: PACT_BROKER_APPLICATION_PORT
    value: "9292"
  - name: PACT_BROKER_DATABASE_ADAPTER
    value: postgres
  - name: PACT_BROKER_DATABASE_URL
    value: "{aws-sm}pact-broker-db-connection-string" 
  - name: PACT_BROKER_PUBLIC_HEARTBEAT
    value: "true"

Relevent log files

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

SongGithub commented 3 years ago

I managed to fix the issue by adding following env-var to the runtime.

  - name: PACT_BROKER_PORT_ENVIRONMENT_VARIABLE_NAME
    value: PACT_BROKER_APPLICATION_PORT

because Port has been assigned this way:

  - name: PACT_BROKER_APPLICATION_PORT
    value: "9292"

But still, it is confusing to me how the app/Puma can start to consume the env-var PACT_BROKER_APPLICATION_PORT correctly, with this annotation-like env-var PACT_BROKER_PORT_ENVIRONMENT_VARIABLE_NAME? It sounds tricky.

SongGithub commented 3 years ago

nvm I managed to answer my above question in this doco. https://github.com/pact-foundation/pact-broker-docker/blob/ee2f93db03f04103378e83e6359a961c14a63f07/README.md#port

mefellows commented 3 years ago

Yep, there is an explicit section that deals with this for Kubernetes: https://github.com/pact-foundation/pact-broker-docker/blob/ee2f93db03f04103378e83e6359a961c14a63f07/README.md#running-on-kubernetes.

Closing the issue as it seems you have a working solution.