Skip to content

Commit 3ff63fc

Browse files
committed
Validate slot-based attested mesh deployment
1 parent 3f96971 commit 3ff63fc

11 files changed

Lines changed: 528 additions & 165 deletions

File tree

ATTESTATION.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ as:
109109
- `app_info.compose_hash` present and policy-allowed
110110
- `app_info.key_provider_info` present and equal to the policy-pinned
111111
KMS provider id
112+
- when `production_profile = true`, `os_image_hash_verified == true`
113+
and `os_image_hash` equals the Terraform preflight hash
112114

113115
KMS identity should be policy-controlled because it defines the key
114116
lifecycle. This example pins the long-term KMS public key in
@@ -128,9 +130,13 @@ configuration. The Terraform default matches the example's default
128130
`kms = "phala"` backend; override it when changing KMS backend.
129131

130132
For production profiles, OS image identity should also be checked.
131-
The expected OS image hash should be both a Terraform launch setting
132-
and an admission policy field, so a workload cannot satisfy the
133-
compose policy while running on an unexpected base image.
133+
This example makes that an explicit profile: set
134+
`production_profile = true` and an `os_image` name such as
135+
`dstack-0.5.7`. Terraform uses that image in the Phala launch config,
136+
reads the resulting
137+
`os_image_hash` from preflight, and emits that SHA-256 hash into the
138+
admission policy. The broker then requires `dstack-verifier` to prove
139+
the same OS image hash before issuing Consul ACL tokens.
134140

135141
## Runtime Checks
136142

@@ -164,6 +170,12 @@ phala logs --cvm-id <worker-app-id> dstack-sidecar-1 -n 700 |
164170

165171
No output from the failure grep is expected.
166172

173+
Production Phala OS images disable SSH access. For prod-profile runs,
174+
use Phala instance metadata, `phala ps`, and public logs to validate
175+
OS hash, container health, and admission success. Use a dev image only
176+
when the test specifically requires in-CVM `consul` or `patronictl`
177+
commands.
178+
167179
## Current Limits
168180

169181
- The low-level mesh rendezvous path still uses TURN HMAC admission.

PROGRESS.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,30 @@ deployment model, trust model, or operational status.
77
## Current Status
88

99
- Terraform deploys a 3-coordinator / 3-worker real Phala Cloud
10-
cluster with public provider `phala-network/phala v0.2.0-beta.4`.
10+
cluster with public provider `phala-network/phala v0.3.0-beta.1`
11+
using the named-slot model.
1112
- `mesh-conn` direct connectivity is enabled by default; relay-only
1213
configuration was removed.
1314
- Consul server quorum, Consul clients, Envoy Connect sidecars, and
1415
Patroni HA Postgres are running through the mesh.
1516
- Attestation admission gates Consul node and service token issuance
1617
through real dstack quotes and `dstack-verifier`.
17-
- Worker preflight compose hashes are generated by Terraform and used
18-
as revision evidence in the admission policy.
18+
- Worker role preflight compose hashes are generated by Terraform and
19+
used as revision evidence in the admission policy.
20+
- Admission policy checks KMS key-provider evidence. When
21+
`production_profile = true`, it also checks verifier-proven OS image
22+
hash evidence against the Terraform preflight hash.
1923

2024
## Recently Validated
2125

2226
- Full real-cluster Terraform apply with preflight-backed admission
2327
policy.
24-
- Public Terraform provider path, with no local provider override.
28+
- Public Terraform provider path, with no local provider override:
29+
`terraform init -upgrade`, `apply`, no-op `plan`, and `destroy`
30+
against `phala-network/phala v0.3.0-beta.1`.
31+
- Production-profile real-cluster apply on prod `dstack-0.5.7`, with
32+
all six CVMs reporting `is_dev = false` and OS image hash
33+
`761c05d282c81abeae2d1a8f6d5b1e039c8ce14cc95a6da020b9ed2ff1056816`.
2534
- Real attestation path on all workers for node, webdemo, and
2635
postgres identities.
2736
- Negative admission test: a valid quote claiming the wrong `peer_id`
@@ -30,23 +39,36 @@ deployment model, trust model, or operational status.
3039
token are re-issued through attestation before the worker rejoins.
3140
- Consul health after tests: zero critical checks, all coordinators
3241
and workers alive.
42+
- Broker unit tests cover KMS mismatch rejection and production OS
43+
image hash mismatch rejection.
3344

3445
## Open Work
3546

36-
- Terraform slot API: integrate the newly implemented Phala Cloud
37-
slot API into the Terraform deployment flow. Tracking note:
38-
`design/terraform-slot-api.md`.
39-
- KMS policy: Terraform now carries the selected KMS backend and the
40-
expected long-term KMS public key; admission requires the verifier
41-
returned key-provider evidence to match it.
42-
- Production OS policy: when a production profile is enabled, include
43-
the expected OS image hash in both Phala launch config and admission
44-
policy.
47+
- Terraform slot API: provider 0.3.0-beta.1 lands the named-slot
48+
resource (`phala_app_instance` + `phala_app.members`) and
49+
`cluster-example/cluster.tf` is migrated onto it. App-level
50+
`docker_compose`/`env`/`image` updates on a phala_app in members
51+
mode are intentionally refused at plan time by the provider until
52+
the cloud's `/apps/{app_id}/revisions/{rev_id}/redeploy` fan-out
53+
endpoint is wired into the provider — see
54+
`design/terraform-slot-api.md` for the integration path.
55+
- Rollout driver: `cluster-example/rollout.sh` is paused for
56+
in-place rolls. It still serves `--plan` and Consul-health
57+
probing; the actual `terraform apply -target=...` loop now exits
58+
with a clear "Unsafe update in members mode" guidance message
59+
rather than half-mutating a cluster. The eventual slot-aware
60+
rollout will drive `/apps/{app_id}/revisions/{rev_id}/redeploy`
61+
with per-slot drains, reusing this script's leader-transfer +
62+
wait-for-quorum scaffolding.
4563
- Secret lifecycle: move remaining cluster-wide-identical secrets
4664
out of Terraform env into TEE-rooted generation/distribution.
4765
- Long soak: run the real cluster for at least one hour with zero ACL
4866
authorization failures, zero attestation rejections, and stable
4967
Patroni leader/replica health.
68+
- Deep prod-profile operational validation: prod OS images disable SSH,
69+
so use Phala logs/API evidence for admission and container health.
70+
Run dev-image validation when direct `consul`/`patronictl` CLI access
71+
is required.
5072
- Token lifecycle: keep non-expiring tokens for the first integrated
5173
version; next step is one active token per attested workload
5274
instance, then bounded TTL plus renewal once Consul, Envoy, and

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ $EDITOR terraform.tfvars # set gateway_domain, image refs, external_*
8080
# deploy is silent until you spot it in the dashboard.
8181
export PHALA_CLOUD_API_KEY=phak_...
8282

83-
terraform init
84-
terraform apply -parallelism=1 # phala-cloud#247 needs serial creates
83+
terraform init -upgrade
84+
terraform apply
8585
```
8686

8787
Once apply finishes, the cluster is HA Postgres on
@@ -295,7 +295,7 @@ the platform plumbing untouched.
295295

296296
| | |
297297
|---|---|
298-
| In-place env updates | Yes — change image tags or env values, `terraform apply`, CVMs update without losing pgdata. Requires provider `phala-network/phala 0.2.0-beta.4+`. |
298+
| Slot add/remove | With provider `phala-network/phala 0.3.0-beta.1+`, replica count changes map to stable named slots; adding or removing a slot does not disturb the remaining slots. |
299299
| Failover RTO | ~24s soft-kill, ~33s hard-kill (default Patroni `ttl=30`). See [`FAILOVER.md`](FAILOVER.md). |
300300
| Cheap rejoin | Yes — a recovered ex-leader replays local WAL and rejoins as a streaming replica without pg_basebackup. |
301301
| Disk-loss rejoin | Yes — Patroni detects empty pgdata and runs full pg_basebackup over the QUIC overlay. |
@@ -304,10 +304,18 @@ the platform plumbing untouched.
304304

305305
## Known limitations
306306

307-
* Each `terraform apply` that fans out more than 1 `phala_app` create
308-
in parallel hits
309-
[`phala-cloud#247`](https://github.com/Phala-Network/phala-cloud/issues/247)
310-
— use `-parallelism=1` for now (~5 min × N to bring-up).
307+
* Provider `0.3.0-beta.1` named-slot support is indexed by Terraform
308+
Registry and the cluster example has been validated with the public
309+
provider. Keep the exact beta pin until the slot model has soaked
310+
under real traffic.
311+
* App-level `docker_compose`, `env`, and `image` updates are blocked
312+
in provider `0.3.0-beta.1` members mode. Slot add/remove is safe;
313+
in-place rolling revisions need the cloud revision redeploy endpoint
314+
wired into the provider.
315+
* Prod OS images disable SSH. Production-profile attestation tests
316+
should validate through Phala instance metadata, `phala ps`, and
317+
logs; use a dev image for tests that require direct `consul` or
318+
`patronictl` commands inside the CVM.
311319
* The low-level mesh-conn rendezvous story is **shared-secret based
312320
today** (TURN HMAC), not attestation-based. Consul/Connect
313321
admission can be gated by TEE attestation with
@@ -326,12 +334,7 @@ the platform plumbing untouched.
326334
* [`Phala-Network/terraform-provider-phala#5`](https://github.com/Phala-Network/terraform-provider-phala/issues/5)
327335
`storage_fs` triggers ForceNew when unset; we explicitly pin
328336
`storage_fs = "zfs"` in `cluster.tf`.
329-
* [`Phala-Network/phala-cloud#247`](https://github.com/Phala-Network/phala-cloud/issues/247)
330-
— concurrent `phala_app` creates against the same workspace return
331-
`400 "configuration parameters not compatible"`. Workaround:
332-
`terraform apply -parallelism=1`.
333-
* [`Phala-Network/phala-cloud#242`](https://github.com/Phala-Network/phala-cloud/issues/242)
334-
`phala cvms list` collapses replicas to one entry.
335337
* [`Phala-Network/phala-cloud#243`](https://github.com/Phala-Network/phala-cloud/issues/243)
336-
— per-instance Terraform resource + `update_policy` + lifecycle
337-
hooks would let `cluster-example/rollout.sh` collapse into HCL.
338+
— per-instance Terraform resource landed in provider
339+
`0.3.0-beta.1`; revision rollout policy still needs provider support
340+
for the cloud `/apps/{app_id}/revisions/{rev_id}/redeploy` path.

ROBUSTNESS.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,12 @@ depth.
305305

306306
### Already shipped
307307

308-
- **Three Consul servers** — landed in commit `17f4642`. The
309-
coordinator app deploys with `replicas = 3` and Consul agents on
310-
those CVMs run as servers with `bootstrap_expect = 3`. Workers
311-
retry-join through every coordinator's serf port via mesh-conn,
312-
so the single-coordinator-failure scenario stays operational.
308+
- **Three Consul servers** — landed in commit `17f4642`; the current
309+
Terraform model deploys three stable coordinator slots, and Consul
310+
agents on those CVMs run as servers with `bootstrap_expect = 3`.
311+
Workers retry-join through every coordinator's serf port via
312+
mesh-conn, so the single-coordinator-failure scenario stays
313+
operational.
313314
- **Real registry** — Sigstore-attested GHCR images via
314315
`.github/workflows/consul-postgres-ha-publish.yml`. See
315316
`PUBLISHING.md`.
@@ -401,9 +402,8 @@ in attestation rather than handed in by the deployer.
401402
"Already shipped" for the failure analysis and the regression test.
402403
- **Auth-channel reconnect deadlock** — fixed via fresh
403404
`peerSession{}` per `dialICE` + drain-then-push on `authCh`.
404-
- **Three-server Consul** — coordinator deploys with
405-
`replicas = 3`; Consul agents run as servers with
406-
`bootstrap_expect = 3`.
405+
- **Three-server Consul** — coordinator deploys three stable named
406+
slots; Consul agents run as servers with `bootstrap_expect = 3`.
407407
- **PEERS_JSON validation**`validatePeers()` runs at startup
408408
with nine-case unit-test coverage.
409409
- **Real registry** — Sigstore-attested GHCR images via

0 commit comments

Comments
 (0)