pact-foundation/pact_broker-client

Tag all verified contracts when provider is published

Closed this issue · 4 comments

I would like to have an idea about some race conditions (I had) and how to pass them:

  • Consumer version vX developed a new feature, contract changed, Provider webhook triggerred. ,
  • Provider version 123 verified the Consumer's contract and published to Broker.
  • Consumer's can-i-deploy failed (sure) since Provider is not deployed and is not tagged with prod

BROKER STATE NOW: Consumer vX, Provider v123 (Not tagged), Verified

  • Provider did not deploy version 123, instead added a new commit where git hash is 124

  • Provider run it's tests, verified prod contracts and deployed

  • Provider is now tagged with prod
    BROKER STATE NOW (still): Consumer vX, Provider v123 (Not tagged since this is not version 124?), Verified

  • Consumer re-triggerred it's pipeline since the expected Provider is now in the prod.

  • Consumer did not trigger webhook of Provider since contract is not changed

BROKER STATE NOW (still): Consumer vX, Provider v123 (Not tagged), Verified

  • Consumer's can-i-deploy failed (false positive) since Provider is not deployed and is not tagged with prod
  • But Provider in the production is capable to meet Consumer's contract

Maybe I misconfigured something in my flow and those caused. Any idea? I thouht provider will tag all versions as prod when it is tagged but seems like only v124 is tagged with prod. So this blocks consumer since v123 of Provider will not be deployed or tagged

My guess is that the provider verification task is not configured correctly. You said it "verified prod contracts", but you didn't mention any other pacts. It should be verifying at the very least, the master pact, and the pact for every environment that the consumer is deployed to. If the pact that you're talking about is on a feature branch, then enabling WIP pacts will bring that in automatically. You can read about the recommended provider configuration here.

Yes provider verifies every environment that consumer is deployed. But to continue can-i-deploy process in consumer side, also provider should tag the contract just verified in the previous step, should not it? In the webhook consumer --> triggers provider only verification task is being run, not tagging. Tagging only happens after provider's deployment job. But provider will not re-deploy since it is already deployed (also verification passed).

Thanks Beth! That was my main problem, especially this article for further readers: http://blog.pact.io/2020/02/24/introducing-wip-pacts/

Sounds like you're missing the verification between the production provider and the feature pact. This may help you https://docs.pact.io/pact_nirvana/step_8

However, if that version of the provider never supported the provider state you need, then you'll need to wait until the provider has updated and deployed a new version.

I tend to have an environment variable in my build called SKIP_CAN_I_DEPLOY, which I set to true if I know that I can safely deploy even if can-i-deploy says no. It does what it says (skips can I deploy!). Sometimes it's needed just to get things started.