Hi all. I'm currently investigating Pact to see ho...
# pact-broker
p
Hi all. I'm currently investigating Pact to see how it might help my team identify and fix compatibility with rolling / blue - green deployments. Yesterday, I ran a scenario where I deliberately broke compatibility initially in the provider, and then the consumer. The Matrix and
can-i-deploy
tool agreed (correctly) with the initial provided based break, but seem to disagree on the consumer break. I attach images of the Matrix and
can-i-deploy
tool output. I will post further diagnostic info in a thread. Is this expected? I'm, perhaps incorrectly, expecting
can-i-deploy
to say "computer saids no...."
blobwave 1
Software versions: Broker:
pactfoundation/pact-broker:latest
which returns
x-pact-broker-version
2.118.0 in Inspector response headers CLI:
pactfounation/pact-cli:latest
which returns 1.5.0 JVM consumer / provider libraries and Maven plugin (
<http://au.com|au.com>.dius.pact.provider
) all at 4.6.20
m
The matrix suggests that the apps with version 0.0.3-SNAPSHOT are compatible. Is this what you say should be red and, if so, what makes you think they are not compatible? It looks like only β€’ 0.0.1 -> 0.0.2 (provider break?) is red β€’ 0.0.03 -> 0.0.2 (consumer break?) is red You could dig into the contract between them to see why
The can-i-deploy result suggests 0.0.3 is the provider in production, and as the matrix believes they are compatible, it thinks it’s safe to release 0.0.3 of the consumer (no surprises they align, because can-i-deploy uses the matrix data)
p
Hi Matt. You and the Matrix have correctly identified the breakages. However, in the state shown, I shouldn't be able to deploy 0.0.3 of the consumer because it's not compatible with 0.0.2 of the provider which is still in production (alongside 0.0.3 which is currently being "blue / green deployed"...
I suppose the question is why does can-i-deploy think only 0.0.3 provider is in production, when the matrix correctly shows both 0.0.2 and 0.0.3.
As this is a spike, I'm running the broker against sqlite if that makes a difference.
r
I am interested in this. We are going to do blue-green as well. It seems that
production
is an environment. Do you record deployments or releases against this environment for the provider? As far as I know, a deployments overwrites the previous deployment. Pact kind-of assumes that 1 version is running at the same time. I think releases might be the alternative option here. Disadvantage is that you explicitly need to un-release the versions https://docs.pact.io/pact_broker/recording_deployments_and_releases#recording-releases
p
I am using releases @Ruud Welling as i want to model the fact that two versions of each service will be running during that deployment. Once the deployment is proven, then manually unreleasing the old versions is my current plan.
As hinted, but not stated, the first breakage I modelled worked correctly with both the matrix and can-i-deploy complaining about the breakage when considering deploying a provider that would break during blue / green. It just doesn't seem to work the same for consumer.
But it could be my process to blame. I think the screenshots are fairly illustrative though.
r
I agree, looking at what you are showing. I would expect can-i-deploy to check against 0.0.3-SNAPSHOT and 0.0.2-SNAPSHOT of the provider.
p
Thank you for the sanity check.
y
I would agree that doesn’t look correct, I would expect any released providers, that have consumer dependency to
profile-service
to be included in that check. Given your screenshot, you have both
0.0.2-snapshot
and
0.0.3-snapshot
released, so they should both be considered in the matrix, or I would at least have expected them too. There are some comprehensive test suites in the pact broker repository that you could use to extend to cover this case, which can aid anyone trying to fix forward, or raise an issue on the pact_broker repo itself.
πŸ‘ 1
p
Yeah, I've not touched Ruby for a decade now and as I'm only evaluating Pact atm, I'll raise an issue. Cheers.
So, I spent some time yesterday replicating this issue totally independently from the first time I replicated it with the only similarities being the use of Pact-JVM and the general workflow and ordering of breaking / fixing commits between consumer / provider. However, this time I used Pactflow.io rather than running a broker with Docker. The actual breakages of contract were different, but the end result was the same - it seems that
can-i-deploy
doesn't check that ONLY compatible providers are deployed to an environment, and gives a full positive. I'm writing an issue on https://github.com/pact-foundation/pact_broker now.
I've replicated the above issue using PactFlow.io. I've subsequently raised a GitHub issue: https://github.com/pact-foundation/pact_broker/issues/903
If it helps, I can PM the Pactflow url and app token to help diagnosis as the app demonstrating the issue is a sandbox app to replicate this issue...
m
Hey Paul! thanks for raising this, will take a look today and comment on the public issue (so we have the context when fixing etc.). Much appreciated
thanks 1
p
Hi, I'm trying to find the hal browser in PactFlow.
m
Top right, the globe looking thing
p
Got it - cheers.
πŸ‘ 1
I'm in the Hal browser. I've navigated to
/pacticipants/provider
but don't see a link for
pb:deployed-environments
or
pb:released-environments
.. Only have empty json on right for the former.
Copy code
"pb:deployed-environments": [],
Which is correct - I haven't 'deployed' but instead released. I wanted to use the release semantics as it seems to address blue / green deployments better.
I've attached a screenshot to issue.
So... I was a little disappointed to see that my issue has been closed today. Especially with a statement such as "As for the concern about multiple provider versions appearing in production β€” this was, as mentioned, likely a UI glitch. Only one version of an application can be deployed to production at a time.". There can, and often will be different versions of a provider deployed to production, either during a release, or as releases get rolled out over data centres etc.
m
Hey Paul! I haven’t seen the public issue response yet (I’ll go and take a look now) but the analysis Sauparna did and shared first on the internal tracking Jira issue suggested to me the
can-i-deploy
/
matrix
results are correct - if you don’t believe this to be the case, we should keep the issue open and get to the bottom of it. I seemed to recall at the time that
can-i-deploy
was passing, but with the data to reproduce it was correctly failing, stating a dependency wasn’t met.
Only one version of an application can be deployed to production at a time.
Yep. That’s obviously not true with releases, which is their design intent.
p
Yeah, casting my mind back several months...
can_i_deploy
was incorrectly stating that releasing a consumer was safe, when it was indeed incompatible with one of the providers in production at the time.
It seems you confirmed this in https://github.com/pact-foundation/pact_broker/issues/903#issuecomment-3981215590 - asking why
can_i_deploy
is ignoring the old but still released version of the provider. The matrix was demonstrating this was still deployed. I have subsequently lost my pactflow.io deployments as my trial expired. If it helps, I can reserect my local deployment with latest pactbroker although this will take a few days, as I'll need to interleave it with my other duties.
If it was possible to re-enable my trial, possibly for an extended period to allow diagnosis and experimentation with my issue, than I'd be happy to redeploy to that.
m
It seems you confirmed this in https://github.com/pact-foundation/pact_broker/issues/903#issuecomment-3981215590 - asking why can_i_deploy is ignoring the old but still released version of the provider. The matrix was demonstrating this was still deployed. I have subsequently lost my pactflow.io deployments as my trial expired. If it helps, I can reserect my local deployment with latest pactbroker although this will take a few days, as I’ll need to interleave it with my other duties.
Yeah, I can’t remember if I directly queried the data, or relied on your output (either way, at some point it showed that and I think you showed pretty good reasoning in the analysis - so I had no reason to not believe you)
If it was possible to re-enable my trial, possibly for an extended period to allow diagnosis and experimentation with my issue, than I’d be happy to redeploy to that.
Thanks! I’ll see if I can quickly bump you, but to do it properly I’ll need to raise a request. I think there’s a 15m or so cache on the plan entitlements, so give it a little bit and see if it updates
FWIW this is the current can-i-deploy output on that example
Copy code
pact broker can-i-deploy  \
    --pacticipant consumer \
    --version 0.0.3-SNAPSHOT \
    --to-environment production
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ CONSUMER ┆ C.VERSION      ┆ PROVIDER ┆ P.VERSION      ┆ SUCCESS? ┆ RESULT β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•ͺ════════════════β•ͺ══════════β•ͺ════════════════β•ͺ══════════β•ͺ════════║
β”‚ consumer ┆ 0.0.3-SNAPSHOT ┆ provider ┆ 0.0.2-SNAPSHOT ┆ false    ┆ 1      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

VERIFICATION RESULTS
--------------------
1. <https://na-f6c548c6.pactflow.io/pacts/provider/provider/consumer/consumer/pact-version/4a9234eb022c262a1a3d960f70b64cf0f7c7dc73/metadata/Y3ZuPTAuMC4zLVNOQVBTSE9U/verification-results/237> (failure)


The verification for the pact between version 0.0.3-SNAPSHOT of consumer and the version of provider currently in production (0.0.2-SNAPSHOT) failed
p
Okay, cheers. I will redeploy to pactflow.io over the next few days, and will report back, via the GH issue and here.
πŸ™ 1
m
thanks, I really appreciate it
p
Oh yeah, that environment is still available.
Cheers.
oh... so now...
Copy code
will@Pauls-MacBook-Pro consumer % podman run --rm \
    -e PACT_BROKER_BASE_URL=<https://na-f6c548c6.pactflow.io> \
    -e PACT_BROKER_TOKEN=<token> \
    pactfoundation/pact-cli:latest pact-broker can-i-deploy \
    --pacticipant consumer \
    --version 0.0.3-SNAPSHOT \
    --to-environment production
Computer says no Β―\_(ツ)_/Β―

CONSUMER | C.VERSION      | PROVIDER | P.VERSION      | SUCCESS? | RESULT#
---------|----------------|----------|----------------|----------|--------
consumer | 0.0.3-SNAPSHOT | provider | 0.0.2-SNAPSHOT | false    | 1

VERIFICATION RESULTS
--------------------
1. <https://na-f6c548c6.pactflow.io/pacts/provider/provider/consumer/consumer/pact-version/4a9234eb022c262a1a3d960f70b64cf0f7c7dc73/metadata/Y3ZuPTAuMC4zLVNOQVBTSE9U/verification-results/237> (failure)
Which differs from the previous output
Copy code
Computer says yes \o/

CONSUMER | C.VERSION      | PROVIDER | P.VERSION      | SUCCESS? | RESULT#
---------|----------------|----------|----------------|----------|--------
consumer | 0.0.3-SNAPSHOT | provider | 0.0.3-SNAPSHOT | true     | 1

VERIFICATION RESULTS
--------------------
1. <https://xxx.pactflow.io/pacts/provider/provider/consumer/consumer/pact-version/4a9234eb022c262a1a3d960f70b64cf0f7c7dc73/metadata/Y3ZuPTAuMC4zLVNOQVBTSE9U/verification-results/221> (success)

All required verification results are published and successful
This change would indicate that it's been fixed in pactflow.io, either explicitly or through other changes. I will try to replicate using a local broker.
m
Interesting. It’s possible, there was some work going on there around that time if I’m not mistaken. The logic should be the same in PF and the local Pact Broker (OSS). Occasionally, we’ll test out new behaviour in PF first but I’m not aware of anything of that happening at the moment