pact-foundation / pact-python

Python version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
http://pact.io
MIT License
575 stars 137 forks source link

503 service unavailable #196

Closed NigelVanHattum closed 3 years ago

NigelVanHattum commented 3 years ago

We are trying to setup our pipelines to validate PACTs for our consumers. We've got a PACT broker setup which stores the contracts.

We are trying to validate them with the following command:

pact-verifier --provider-base-url=https://$PROVIDER_URL \
     --pact-broker-url="$BROKER_URL:443" \
     --provider="$PROVIDER_NAME" \
     --pact-url="$BROKER_URL:443/pacts/provider/$PROVIDER_NAME/consumer/$CONSUMER_NAME/$VERSION" \
     --publish-verification-results \
     --provider-app-version=$VERSION

This results in the following stack trace:

Error making request - Net::HTTPFatalError 503 "Service Unavailable" , attempt 1 of 3
 Error making request - Net::HTTPFatalError 503 "Service Unavailable" , attempt 2 of 3
 Error making request - Net::HTTPFatalError 503 "Service Unavailable" , attempt 3 of 3
 /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http/response.rb:119:in `error!': 503 "Service Unavailable" (Net::HTTPFatalError)
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http/response.rb:128:in `value'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:915:in `connect'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/hal/http_client.rb:55:in `block in perform_request'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/retry.rb:23:in `until_true'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/hal/http_client.rb:49:in `perform_request'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/hal/http_client.rb:24:in `get'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/hal/link.rb:49:in `get'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:50:in `index'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:37:in `call'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:33:in `call'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/pact_broker.rb:18:in `fetch_pact_uris_for_verification'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:45:in `pacts_for_verification'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:38:in `pacts_urls_from_broker'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:25:in `call'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:10:in `call'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:199:in `all_pact_urls'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:40:in `call'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:34:in `call'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/cli/verify.rb:47:in `verify'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start'
    from /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/app/pact-provider-verifier.rb:33:in `<main>'

We are able to connect to both the PACT broker and the provider via the same pipeline.

bethesque commented 3 years ago

Unrelated, you don't need both the pact URL and the Pact Broker URL. Have a look at the "Description" section in the Usage https://github.com/pact-foundation/pact-provider-verifier#usage

If it's a 503, that's a server error. Probably not something wrong with your client code, unless you're pointing the Pact Broker URL to the wrong location. Can you access the Pact Broker through the UI? Can you put the --verbose flag on to make sure you're actually getting that 503 from the Pact Broker itself? A 503 is likely to come from a reverse proxy or something sitting in between your client and the Pact Broker application like a load balancer or ngnix, not the Ruby code itself.

NigelVanHattum commented 3 years ago

It seems to be a proxy issue indeed. A reverse proxy shoudn't be an easy I guess?

mefellows commented 3 years ago

It seems to be a proxy issue indeed. A reverse proxy shoudn't be an easy I guess?

I don't understand the question sorry, are you asking if setting up a reverse proxy should be easy?