Repository navigation
fix(prisma-cloud): an unchanged deploy no longer replaces a service that depends on another service - #446
Conversation
…of a service that reads another service's URL A service's url output came from its deployment, which promotes itself on every deploy, so the url was unknown while planning. A consumer writes that url into an environment row and its deployment's triggers, and an unknown trigger replaces the deployment. Every deploy made a new version of every such consumer, even with nothing changed. The url output is now the App's endpoint domain, which is known from the App's create and does not change, the same value a service's own origin already uses. serviceId still waits for the promotion, because a custom domain reads it and is bound to the live deployment. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…he docs say a service's url comes from its App One function reads an App's endpoint domain for a service's url, for serviceOrigin and for a service's own origin, and its error names the service. The design docs now draw a reading service's url row from the App, and no longer say the create-time domain is a placeholder. The tests also check that the reading service's row holds the url, that a new artifact for the service being read replaces only that service's deployment, and that reserve publishes the App's domain. The fake Management API used by the apply tests is now exported from @internal/lowering/scratch-stack. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…keeps-consumer-version Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… the services it reads are promoted Taking a service's url from its App removed the edge that made a reading service's deployment wait for its provider's promotion. A reading service's Deployment now also waits, through its app prop, on every output of the services and resources it reads. A Compute provider's serviceId resolves only after its promotion, so the order is kept on a first deploy and when both services change. The wait is on app, not in triggers, and an unresolved app counts as unchanged, so an unchanged reading service is still not replaced. appAfterEnvironment is renamed appAfter, since it now orders the deployment after its provider outputs as well as its environment rows. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…ever promoted, and the docs name producers and consumers The ordering tests now assert the exact sequence of the producer's promotion and the consumer's deployment create, so a missing promotion fails them. Code, tests and docs use producer and consumer for the two ends of a dependency edge. The serviceId output says both reasons it comes from the deployment, the edge helper's comment says only what a caller needs, and the self-origin value is endpointDomainOf itself. The edge decision record has a dated amendment: a service's url comes from its App, and a consumer's deployment waits for its producers' promotion through the app prop, never through triggers. The Prisma Cloud docs and core's lowering steps state what is true now. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
|
✅ Gizmo reviewed aa57e4c — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughThis delta retires the framework's Extension ( Tests ( Design docs — alchemy-lowering.md replaces the placeholder-claim section with the new stance plus an explicit note on what a service reading |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
commit: |
…umer again The shared missing-domain error named only the producing service. It now also says which consumer's serviceOrigin could not be resolved, as the message did before the check was shared. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…keeps-consumer-version Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
The
storefront-authexample has two services. The storefront depends on auth, so Composer gives the storefront auth's URL:Run
prisma deploytwice without changing anything. This is what the second deploy does to the storefront.Before this change, it builds a new version of the storefront and deletes the old one:
After this change, it leaves the storefront's version alone:
This happened to every service that depends on another service, on every deploy.
The decision
A service now publishes its URL from the service itself, not from its latest version. The rest of this description explains why that fixes the problem, and the one thing that had to be added to keep deploys in the same order as before.
Background: the three platform objects behind a service
Composer deploys each service as three Alchemy resources:
Prisma.App: the service. It has a stable ID and a stable domain, both set when it is created.Prisma.EnvironmentVariable: one per environment variable the service reads.Prisma.Deployment: one version of the service's code. Deploying creates a deployment, starts it and promotes it, which makes it the live version.Two more facts matter here:
triggers: when a trigger changes, Alchemy replaces the deployment.In this description the service that is depended on (auth) is the producer, and the service that depends on it (the storefront) is the consumer.
Why the storefront was replaced every time
Auth published its URL from its
Prisma.Deployment. A deployment is promoted again on every deploy, so everything it reports is unknown while planning, on every deploy.The chain was:
The fix
Auth's URL is the domain of its
Prisma.App. That domain is set when the App is created and never changes, so on every later deploy it is known while planning. It is the same string the deployment reported. A service already read its own origin from its App; now a service's published URL comes from the same place.outputs: { - url: deployment.appEndpointDomain, + url: endpointDomainOf(provisioned, address), // the App's domain projectId: provisioned.projectId, serviceId: deployment.appId, },serviceIdstill comes from the deployment on purpose. A custom domain reads it, and a custom domain is attached to the live version, so it has to wait until the version is promoted.Keeping the order in which services go live
The old URL had a useful side effect. Because the storefront's variable waited for auth's deployment, auth always went live before the storefront's new version was created. That matters when one deploy changes both: if the storefront starts calling a method auth has just added, auth must be live first.
Reading the URL from the App removes that wait, so this change adds it back explicitly. A consumer's deployment now waits for everything its producers publish, which includes each producer's
serviceId, the value that is ready only once the producer is live.The wait is attached to the deployment's
appprop and not totriggers. The upstream provider treats an unknownappas unchanged, so the wait changes the order and can never cause a replacement. The deployment's wait for its own environment variables already worked this way;appAfterEnvironmentis renamedappAfterand takes the producers' outputs as well.This stays inside the Prisma Cloud packages. It uses the graph and the outputs that core already hands to every descriptor, and it does not check what kind of node a producer is.
Smaller changes
endpointDomainOf, reads an App's domain. Three places had their own copy of the check for a missing domain. Its error names the service.How it was checked
New tests in
compute-redeploy-apply.test.tsrun Alchemy's real plan and apply against a fake Management API:Each test was seen to fail with its part of the change removed: the URL put back on the deployment, the wait removed,
serviceIdtaken from the App, or the promotion turned off.On Prisma Cloud, with
storefront-authunder a throwaway app name:main, the unchanged second deploy replaced the storefront's version.Not covered
A consumer whose own code changes is still replaced, as it should be. In
storefront-auththat happens more often than you would expect: every fresh Next.js build of the storefront produces a slightly different artifact, so a rebuild makes a new version even with no source change. That has a different cause and is not addressed here.Alternatives considered
Agent: kurtz-83
🤖 Generated with Claude Code