You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8fd4fc3
Browse filesBrowse the repository at this point in the historyBrowse files
fix(prisma-cloud): an unchanged deploy no longer replaces a service that depends on another service (#446)
* fix(prisma-cloud): an unchanged deploy no longer makes a new version 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>
* fix(prisma-cloud): a missing endpoint domain names the service, and the 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>
* fix(prisma-cloud): a service's deployment is still created only after 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>
* fix(prisma-cloud): the deploy-order tests fail when the producer is never 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>
* fix(prisma-cloud): a serviceOrigin that cannot resolve names the consumer 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>
---------
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Copy file name to clipboardExpand all lines: docs/design/05-prisma-cloud/alchemy-lowering.md
+10-33Lines changed: 10 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,9 +67,9 @@ behind them.
67
67
|`Prisma.Project`| Project | name | projectId |**one per Prisma Composer application**; resolved by the CLI before Alchemy runs, so no lowering yields one |
68
68
|`Prisma.Database`| Database | project, name?, region, branchId?, logicalId? | databaseId, connection strings | one per Module-provisioned postgres resource; never the project default; a branch-attached database is created with `branchId` and no display name (upstream refuses the combination — see [deploying.md](../../guides/deploying.md)) |
69
69
|`Prisma.Connection`| database connection info | database, name | connectionId, directConnectionString | Composer binds the DIRECT string explicitly; upstream's `databaseUrl` is pooled-first |
70
-
|`Prisma.App`| App | project, displayName, regionId, branchId?, logicalId? | appId, appEndpointDomain |`branchId` targets the Branch of an environment other than `production`; omitted, upstream attaches the App to the project's default (production) Branch. `appEndpointDomain` is available at provision — that is what a service's own origin is read from |
70
+
|`Prisma.App`| App | project, displayName, regionId, branchId?, logicalId? | appId, appEndpointDomain |`branchId` targets the Branch of an environment other than `production`; omitted, upstream attaches the App to the project's default (production) Branch. `appEndpointDomain` is available at provision — that is what a service's own origin and its published `url` are read from |
71
71
|`Prisma.EnvironmentVariable`| ConfigVariable | project, class, key, value (Redacted), branchId? | environmentVariableId | production-class with no `branchId` for `production`; preview-class with `branchId` for any other environment. Values are write-only, so upstream re-applies the desired one on every deploy |
72
-
|`Prisma.Deployment`| Deployment (ComputeVersion) + Promotion | app, artifactPath, artifactContentType, portMapping, triggers, start, promote | deploymentId, appEndpointDomain | provider reconcile: create → upload tar.gz → start → poll until running → promote; `appEndpointDomain` read **post-promote** (create-time domain is a placeholder — PRO-200). It is replaced, not updated, when its artifact fingerprint or its `triggers` fingerprint moves |
72
+
|`Prisma.Deployment`| Deployment (ComputeVersion) + Promotion | app, artifactPath, artifactContentType, portMapping, triggers, start, promote | deploymentId, appEndpointDomain | provider reconcile: create → upload tar.gz → start → poll until running → promote; `appEndpointDomain` read **post-promote**; it is the same domain the App reports from its create. It is replaced, not updated, when its artifact fingerprint or its `triggers` fingerprint moves |
73
73
|`Prisma.Bucket`| Bucket | project, name, branchId?, logicalId? | bucketId, name | one per bucket resource; `Prisma.BucketAccessKey` mints its read-write S3 credentials, which become the node's outputs |
74
74
75
75
`logicalId` is set on every deploy except branchless local dev; [§ Platform identity](#platform-identity-logicalid) says what it carries.
@@ -178,14 +178,7 @@ logic is untouched.
178
178
Management API; the table above is that mapping. One resource maps to one PDP
promote (and therefore owns the env-snapshot moment).
181
-
-**PDP → ours**: `foundryVersionId`, `Promotion`, and Foundry's version record
182
-
have no resource of ours; they are internal to the `Deployment` provider's
183
-
behavior or unmodeled. **Branch** likewise has no Alchemy resource — it is
184
-
resolved and its lifecycle managed by the CLI's container-resolution
185
-
client, outside the Alchemy graph entirely (see
186
-
[§ Environments and container resolution](#environments-and-container-resolution)).
187
-
`serviceEndpointDomain` surfaces as `App.appEndpointDomain` (before the first
188
-
deploy) and `Deployment.appEndpointDomain` (post-promote).
181
+
-**PDP → ours**: `foundryVersionId`, `Promotion`, and Foundry's version record have no resource of ours; they are internal to the `Deployment` provider's behavior or unmodeled. **Branch** likewise has no Alchemy resource — it is resolved and its lifecycle managed by the CLI's container-resolution client, outside the Alchemy graph entirely (see [§ Environments and container resolution](#environments-and-container-resolution)). `serviceEndpointDomain` surfaces as `App.appEndpointDomain` and `Deployment.appEndpointDomain`; both are the same domain.
Da -- appEndpointDomain --> EVu["EnvironmentVariable(COMPOSER_SHOP_STOREFRONT_AUTH_URL)"]
211
+
Sa -- appEndpointDomain --> EVu["EnvironmentVariable(COMPOSER_SHOP_STOREFRONT_AUTH_URL)"]
219
212
EVu -- resource ref --> Ds
213
+
Da -- "serviceId (after promote)" --> Ds
220
214
end
221
215
```
222
216
@@ -227,12 +221,9 @@ How the pieces map:
227
221
-**Each service** lowers to an `App → Deployment` chain plus its own
228
222
`Database → Connection`, whose url is written as that service's **explicitly
229
223
named** variable — the same `serialize` path as any other config value.
230
-
-**The connection** lowers to two edges: the producer's endpoint domain flows
231
-
into a named `EnvironmentVariable`, and that **whole resource flows into the
232
-
consumer's `Deployment`** through its `app` prop.
233
-
- Every `EnvironmentVariable` a Deployment boots with is threaded into its
234
-
`app` — database URLs and connection URLs alike — so the deployment
235
-
depends on its config being written first.
224
+
-**The connection** lowers to two edges: the producer's App's endpoint domain flows into a named `EnvironmentVariable`, and that **whole resource flows into the consumer's `Deployment`** through its `app` prop. The domain comes from the App, not the Deployment: the Deployment is promoted on every deploy, so its domain is unknown while planning, and a consumer's deployment, whose triggers hold the value, would be replaced on every deploy. Because the App's domain is known, an unchanged consumer keeps its deployment when its producer is redeployed.
225
+
- Every `EnvironmentVariable` a Deployment boots with is threaded into its `app` — database URLs and connection URLs alike — so the deployment depends on its config being written first.
226
+
- Every output of a consumer's producers is threaded into its Deployment's `app` too, so its deployment waits for its producers' promotion: a Compute producer's `serviceId` comes from its Deployment and resolves only after the promotion. The wait is on `app`, not in `triggers`, and upstream treats an unresolved `app` as unchanged, so an unchanged consumer is not replaced.
236
227
- The Deployment's `portMapping.http` rides the same seam: `serialize` resolves
237
228
the service's `port` param from the typed Config and surfaces it in its
238
229
outputs, and `deploy` routes the platform to it — so the routed port and the
@@ -247,25 +238,11 @@ deployment-create, so new and replacement deployments boot with the completed
247
238
configuration updates.
248
239
Without it the two race — the failure documented as PRO-211 in `gotchas.md`.
249
240
250
-
**Why the edge rides `app`.** Upstream's `Prisma.Deployment` has no
251
-
`environment` prop (Composer's deleted one did). Alchemy derives its dependency
252
-
graph from the resource references a prop's *value* is built from, so the
253
-
descriptor builds `app` as an Output over the app id AND every whole variable
254
-
resource, resolving to the app id itself: the graph gains the edges. A persisted
255
-
variable ID can resolve before its pending value update finishes; the whole
256
-
resource keeps that update as a dependency. The edge cannot ride
257
-
`artifactPath` (or any of upstream's other replacement-block props): the diff
258
-
reads that block as one unit and gives no opinion the moment any member is
259
-
unresolved — and a brand-new variable's reference IS unresolved at plan time —
260
-
which would skip the artifact comparison and silently drop a code change.
261
-
`compute/deployment-edge.ts` records the full argument and its test drives
262
-
upstream's real diff.
241
+
**Why the edge rides `app`.** Upstream's `Prisma.Deployment` has no `environment` prop (Composer's deleted one did). Alchemy derives its dependency graph from the resource references a prop's *value* is built from, so the descriptor builds `app` as an Output over the app id, every whole variable resource and every output of the service's producers, resolving to the app id itself: the graph gains the edges. A persisted variable ID can resolve before its pending value update finishes; the whole resource keeps that update as a dependency. The edge cannot ride `artifactPath` (or any of upstream's other replacement-block props): the diff reads that block as one unit and gives no opinion the moment any member is unresolved — and a brand-new variable's reference IS unresolved at plan time — which would skip the artifact comparison and silently drop a code change. [ADR-0048](../90-decisions/ADR-0048-prisma-cloud-resources-come-from-the-upstream-alchemy-provider.md) records the full argument, and `compute/__tests__/deployment-edge.test.ts` drives upstream's real diff.
263
242
264
243
**Change propagation is wired through `Prisma.Deployment.triggers`.** The platform freezes a deployment's environment at create, so a *value* change (a rotated URL) reaches a running service only through a new deployment. The compute descriptor declares one trigger member per environment row, carrying the same `Redacted` value the row writes; upstream folds the resolved members into a salted fingerprint inside its own encrypted state and plans a replacement exactly when one moved (and conservatively when a member cannot be resolved at plan time because the producing resource is itself changing). Unchanged service → same fingerprint → reuse; changed value or artifact → replace. Because upstream resolves the actual values, a value re-issued under a stable resource identity (a connection rotated in place, a re-minted service key) moves the fingerprint too. No plaintext lands in state — the members are `Redacted` in props and only the salted hash is persisted. A platform variable a row merely POINTS at (operator-owned; Composer never reads its value) contributes a `<name>:updatedAt` member instead, read at preflight and handed to the lowering in the extension's preflight payload, so an out-of-band rotation still ships a new deployment. A service's input document is not an environment row and has no trigger member: it travels in the service's artifact, in the `inputDocument` field of `compute.bootstrap.json` ([ADR-0065](../90-decisions/ADR-0065-a-compute-services-input-document-travels-in-its-artifact.md)), so a changed document changes the artifact's bytes and its content-addressed `artifactPath`, which replaces the deployment. A platform variable the document names is still a `<name>:updatedAt` member.
265
244
266
-
The framework's core constructs these edges when lowering a connection (the
267
-
`serialize` env-var records thread into `deploy` through the service SPI); no pack
268
-
author and no app author ever hand-wires them.
245
+
The compute descriptor constructs these edges (the `serialize` env-var records thread into `deploy` through the service SPI, and the producers' outputs come from the lowering context); no app author ever hand-wires them.
Copy file name to clipboardExpand all lines: docs/design/05-prisma-cloud/pdp-data-model.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ This is the timing model Prisma Composer's graph must respect:
85
85
| any time | ConfigVariable rows are created/updated/deleted via the environment-variables API — **rows only; no effect on any existing version**|`routes/v1/environment-variables.ts`|
86
86
|**version create**|`materializeBranchEnvVars(app.branchId)` resolves the complete map — production branch → production templates; preview branch → preview templates merged with that branch's overrides (override wins) — decrypts it, and hands the **plain map to Foundry with the version**. The env is **frozen into the version**|`routes/v1/versions.ts` → `resolveDeployEnvVars.ts` → `compute-config/materializeBranchEnvVars.ts`|
87
87
| version start | boots the version; **no env re-resolution**|`routes/v1/version-handlers.ts`|
88
-
| promote | endpoint routed to the version; `serviceEndpointDomain` persisted. The domain returned at *create*time is a placeholder region — only the post-promote read is trustworthy (PRO-200)|`interactors/compute/service.ts`|
88
+
| promote | endpoint routed to the version; `serviceEndpointDomain` persisted. The domain returned at *create*names the domain the service will serve on|`interactors/compute/service.ts`|
2.core**buildsthetyped`Config`** — eachinput's declared params matched by name to its producer's`outputs`throughtheone`dependency`edge: whateverthemodulewiredin — aresource's outputs (shared by every consumer wired to it) or a producer service'sdeployoutputs — plusservice-paramdefaults. Leafvaluesareprovisioningrefs, notstrings. Corelowersaproducerbeforeitsconsumers, soaconsumer's hooks receive the producer'soutputs; howatargetmakestheconsumer's deployment wait for its producers is the target's ([PrismaCloud](../05-prisma-cloud/alchemy-lowering.md#the-lowering-graphs)).
(theenvvarconsumestheprojectidandtheproducer's URL), and the one that
792
-
doesn't — deploy-after-serialize — exists because the service descriptor builds
793
-
the`Deployment`'s props out of the environment records it boots with, which is
794
-
PDP's own dataflow restored (the deployment-create call literally contains the
795
-
materializedenvmap). Seetheloweringgraphsin
781
+
**Howtheorderingisactuallyenforced:**ourwalkonly*assembles*Alchemyresourcedescriptions — Alchemyexecutesthemindependencyorderandrunsunorderedresourcesconcurrently; declarationorderisneverconsulted. Socorerealizesthesequenceas **dependencyedges**: mostarisenaturallyfromvalueflow (theenvvarconsumestheprojectidandtheproducer's URL), and two do not. Deploy-after-serialize exists because the service descriptor builds the `Deployment`'spropsoutoftheenvironmentrecordsitbootswith, whichisPDP's own dataflow restored (the deployment-create call literally contains the materialized env map). Deploy-after-producers exists because the service descriptor also builds them out of its producers'outputs, soaconsumer's deployment is created after its producers go live. See the lowering graphs in
0 commit comments