Repository navigation
Let a wrangler project join a cluster with --cluster-addr - #8753
Conversation
There was a problem hiding this comment.
Superseded by the review of
2ac14806.
This review, of d515bd9f
💬 Approved with comments — No correctness, security or performance problems found. There are two INFO notes: the new --data-dir refusals have no tests, and a schema comment leaves out one case.
Findings: 2 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 info
The cluster join and --data-dir logic look correct. The new refusal paths have no tests.
Recommendation: 💬 Optional Nits
- [INFO] The new
--data-dirrefusals (compiled binary, Cap'n Proto config) and the refusal of--cluster-addrwithout--experimentalhave no tests (src/workerd/server/cli/lib.rs:96)
View full review
The wrangler translation, joining_cluster, served_storage and check_experimental look correct. The new --data-dir usage errors (lib.rs:96-102 for a compiled binary, lib.rs:465-471 for a Cap'n Proto config) have no tests. Neither does the refusal of --cluster-addr without --experimental.
📝 Documentation: 💬 1 info
The schema comment leaves out one edge case of do-storage
Recommendation: 💬 Optional Nits
- [INFO] The schema comment says
do-storageis always defined, butserved_storagedefines no disk when the state directory cannot be created (src/workerd/server/workerd.capnp:106)
View full review
workerd.capnp says a wrangler config that joins with --cluster-addr always defines do-storage. served_storage defines no disk when the state directory cannot be created.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found.
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates match the change.
⚡ Performance: ✅ LGTM
The config translation runs once at startup and is not on a hot path.
Reviewed commit: d515bd9f
dd1d57e to
4819872
Compare
d515bd9 to
2ac1480
Compare
There was a problem hiding this comment.
Superseded by the review of
1c7a109d.
This review, of 2ac14806
💬 Approved with comments — No correctness, security or performance problems, and both earlier notes are fixed. One optional suggestion remains for the wrangler.rs row in AGENTS.md.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📖 AGENTS.md: 💬 1 suggestion
The wrangler.rs row leaves out the cluster restrictions and how R2 storage changes in a cluster.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The
wrangler.rsrow leaves out the cluster restrictions and how R2 storage changes in a cluster, and the new sentence is garbled (src/workerd/server/AGENTS.md:63)
View full review
The wrangler.rs row in src/workerd/server/AGENTS.md:
- still describes R2 objects as stored only in a local
bucketstore; - does not mention that a project joining a cluster cannot have
kv_namespacesorqueues; - has its new sentence ("Served, Durable Objects ... for deployments';") joined to the end of the previous one without punctuation.
✅ All other checks passed
🔒 Security: ✅ LGTM
--data-dircomes from the operator's command line.- The cluster key and bucket are read from the environment only with
--experimental, and nothing logs them. - A process joins a cluster only when
--cluster-addris passed explicitly.
📋 Code Quality: ✅ LGTM
The new refusals now have tests in args-test.rs, cluster-test.mjs and config-test.rs.
The logic of Config::with_cluster holds up:
- It leaves a config that already has a cluster unchanged when there is nothing to fill in.
--cluster-advertisewithout a cluster is a usage error.- Without
--experimental, the config still joins, so the server's own refusal applies. testandbenchnever join a cluster.
⚡ Performance: ✅ LGTM
The config translation runs once at startup and is not on a hot path.
📝 Documentation: ✅ LGTM
The workerd.capnp comment now covers the case where the state directory cannot be created.
Reviewed commit: 2ac14806
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8753 +/- ##
==========================================
- Coverage 67.81% 67.77% -0.05%
==========================================
Files 848 848
Lines 215343 215483 +140
Branches 32493 32493
==========================================
+ Hits 146030 146038 +8
- Misses 50112 50244 +132
Partials 19201 19201 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2ac1480 to
1c7a109
Compare
There was a problem hiding this comment.
Superseded by the review of
3de38fbc.
This review, of 1c7a109d
💬 Approved with comments — No correctness, security or performance problems. The only open item is an optional wording fix in the AGENTS.md wrangler.rs row.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📖 AGENTS.md: 💬 1 suggestion
The wrangler.rs row now covers the cluster restrictions and where R2 stores objects in a cluster; one sentence still reads awkwardly.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The 'Served, Durable Objects are on…' sentence in the
wrangler.rsrow is hard to parse (src/workerd/server/AGENTS.md:63)
View full review
The wrangler.rs row now says where R2 objects go in a cluster and that a joined config cannot have kv_namespaces or queues. The sentence that starts with "Served, Durable Objects are on…" is still hard to parse.
✅ All other checks passed
🔒 Security: ✅ LGTM
--cluster-addrand--data-dircome only from the operator's command line.- The cluster key and bucket are read from the environment only with
--experimental, and no error message prints them. - A process joins a cluster only when
--cluster-addris passed explicitly.
📋 Code Quality: ✅ LGTM
Config::with_cluster: the join, usage-error and environment-fill paths are consistent.- A config that already has a cluster, with nothing to fill in, is returned unchanged.
--cluster-advertisewithout a cluster is a usage error.- A compiled binary's config cannot join.
- Each branch has a unit test in
config-test.rs.
--data-dir: it is refused for compiled binaries and Cap'n Proto configs, andcluster-test.mjscovers both refusals.served_storage: it definesdo-storagewhen joining and rejects a worker with that name. The error for a state directory that cannot be created names--data-dir.
⚡ Performance: ✅ LGTM
The config translation runs once at startup and is not on a hot path. with_cluster replaces the earlier separate decode and re-encode passes with one.
📝 Documentation: ✅ LGTM
The workerd.capnp comment and the serve help match the behavior.
Reviewed commit: 1c7a109d
4819872 to
c3a2cf6
Compare
1c7a109 to
3de38fb
Compare
There was a problem hiding this comment.
Superseded by the review of
7661e8b4.
This review, of 3de38fbc
💬 Approved with comments — No correctness, security or performance problems. The only open item is an optional wording fix in the AGENTS.md wrangler.rs row.
Findings: 1 suggestion
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📖 AGENTS.md: 💬 1 suggestion
The wrangler.rs row now covers the cluster restrictions and where R2 stores objects in a cluster; one sentence still reads awkwardly.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The 'Served, Durable Objects are on…' sentence in the
wrangler.rsrow is hard to parse (src/workerd/server/AGENTS.md:63)
View full review
The wrangler.rs row now says where R2 objects go in a cluster and that a joined config cannot have kv_namespaces or queues. The sentence that starts with "Served, Durable Objects are on…" is still hard to parse.
✅ All other checks passed
🔒 Security: ✅ LGTM
--cluster-addrand--data-dircome only from the operator's command line.- The cluster key and bucket are read from the environment only with
--experimental, and no error message prints them. - A process joins a cluster only when
--cluster-addris passed explicitly.
📋 Code Quality: ✅ LGTM
Config::with_cluster: the join, usage-error and environment-fill paths are consistent.- A config that already has a cluster, with nothing to fill in, is returned unchanged.
--cluster-advertisewithout a cluster is a usage error.- A compiled binary's config cannot join.
- Each branch has a unit test in
config-test.rs.
--data-dir: it is refused for compiled binaries and Cap'n Proto configs, andcluster-test.mjscovers both refusals.served_storage: it definesdo-storagewhen joining and rejects a worker with that name. The error for a state directory that cannot be created names--data-dir.
⚡ Performance: ✅ LGTM
The config translation runs once at startup and is not on a hot path. with_cluster replaces the earlier separate decode and re-encode passes with one.
📝 Documentation: ✅ LGTM
The workerd.capnp comment and the serve help match the behavior.
Reviewed commit: 3de38fbc — same changes as 1c7a109d, so this is that commit's review (no new review was run; line numbers are as of 1c7a109d)
c3a2cf6 to
9fa8c66
Compare
3de38fb to
7661e8b
Compare
There was a problem hiding this comment.
Superseded by the review of
48a5f19c.
This review, of 7661e8b4
✅ Approved — No correctness, security, performance or documentation problems found at this commit. The new do-storage requirement closes the compile --config-only + serve -b --cluster-addr gap raised in the discussion, and the AGENTS.md wording fix from the last review is in.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- A process joins a cluster only when
--cluster-addris passed explicitly. - Joining with
--cluster-addris refused without--experimental. - The cluster key and bucket come from the environment, and no error message prints them.
--data-diris set only from the operator's command line.
📖 AGENTS.md: ✅ LGTM
The wrangler.rs row in src/workerd/server/AGENTS.md now starts that sentence with "When served, …", which fixes the wording point from the last review.
📋 Code Quality: ✅ LGTM
🔄 Since last review: 1 finding resolved, 0 preserved, 0 new
Config::with_cluster: the join, usage-error and environment-fill branches cover every combination of an existingcluster,--cluster-addr,--cluster-advertiseandcan_join. Each branch has a unit test.do-storagerequirement:has_cluster_storagerequires a writable disk service nameddo-storage.config-test.rscovers the missing, non-disk and read-only cases, andcluster-test.mjscovers thecompile --config-only+serve -b --cluster-addrcase from the discussion.--data-dirrefusals: a binary config, a Cap'n Proto config and a compiled executable each refuse--data-dir, andcluster-test.mjstests all three.- Wrangler translation: a joined node's
do-storageis in<state>/do, so a deployment's storage key cannot name a bundled service's directory. Outside a cluster the<name>-do-storagelayout is unchanged. Both layouts are tested. - Tests that change the working directory:
set_current_dirinwrangler-test.rschanges it for the whole process. That is safe here because the crate's tests run on a single thread (RUST_TEST_THREADS=1).
⚡ Performance: ✅ LGTM
The changes run once, at CLI startup.
Config::with_clusterdecodes and re-encodes the config once, instead of in separate passes.- The
has_cluster_storagescan is linear over the services and runs only with--cluster-addr.
📝 Documentation: ✅ LGTM
The workerd.capnp comment and the serve help match the behavior at this commit, including the do-storage requirement and the --data-dir behavior.
Reviewed commit: 7661e8b4
7661e8b to
48a5f19
Compare
There was a problem hiding this comment.
Superseded by the review of
cbdabe88.
This review, of 48a5f19c
✅ Approved — No findings: none of the files changed since the last approved review, and a re-read found no correctness, security, performance or documentation issues.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- A process joins a cluster only when
--cluster-addris passed explicitly, and only with--experimental. - The cluster key and bucket come from the environment, and no error message prints them.
- A deployment's storage key cannot point into a bundled service's directory, because
do-storageis<state>/do. --data-dircan only be set from the operator's command line.
📖 AGENTS.md: ✅ LGTM
The wrangler.rs row in src/workerd/server/AGENTS.md is accurate and reads clearly.
📋 Code Quality: ✅ LGTM
Config::with_clusterhandles every combination of an existingcluster,--cluster-addr,--cluster-advertiseandcan_join, andconfig-test.rstests each one.- To join, a config must define a writable
do-storagedisk.cluster-test.mjscovers the case ofcompile --config-onlyfollowed byserve -b --cluster-addr. - A compiled binary, a binary config and a Cap'n Proto config each refuse
--data-dir, and each refusal is tested. - A joined node keeps
do-storagein<state>/do. Outside a cluster, the<name>-do-storagelayout is the same as before.
⚡ Performance: ✅ LGTM
All of this code runs once, at CLI startup. The config is decoded and re-encoded in a single pass, and the has_cluster_storage scan is linear over the services.
📝 Documentation: ✅ LGTM
The workerd.capnp comments and the serve help text match the behavior at this commit.
Reviewed commit: 48a5f19c
A node needed a `cluster` section in a Cap'n Proto config to join a cluster, so a wrangler project could not join one. `serve --cluster-addr=<addr>` now joins a config without `cluster` to a cluster at that address, as if the config held `cluster = (address = "<addr>")`. Every other setting keeps its default, so the key and bucket come from WORKERD_CLUSTER_KEY or WORKERD_CLUSTER_KEY_FILE and WORKERD_CLUSTER_BUCKET, and the bucket's endpoint and credentials from the AWS_* variables. * The flag is the trigger, not WORKERD_CLUSTER_BUCKET, so that a stray environment variable cannot make a process join a cluster. * For a config with `cluster`, `--cluster-addr` overrides its address, as before. * A binary from `workerd compile` whose config has no `cluster` cannot join one: `--cluster-addr` is a usage error that says to serve the config instead or to compile one with `cluster`. `compile` translates a wrangler config for a server that joins no cluster, so the binary has no way to become a node of one. * Without --experimental, the server refuses the cluster, as it does one in the config. Before, `--cluster-addr` was ignored for a config without `cluster`. * `--cluster-advertise` for a config without `cluster` and without `--cluster-addr` is a usage error rather than ignored.
A wrangler project's Durable Objects are stored on a disk service named `<name>-do-storage`. When `--cluster-addr` joins the project to a cluster, the config now defines a disk service named `do-storage` instead, even for a project without Durable Objects. It is the disk service a node defines for the Durable Objects of the bucket's deployments, so a node started from a wrangler project can serve those too. Its directory is `do/` in the state directory, apart from the bundled services' directories, such as `cache/` and `d1/`, which a deployment's storage key could otherwise name. Outside a cluster the name is unchanged, and so is the one in a binary from `workerd compile`, which cannot join a cluster. In a cluster, a project named `do-storage` is refused, since its worker would take the disk's name. `--data-dir <dir>` puts a wrangler project's state directory, by default `.wrangler/state/workerd` next to the config, in `<dir>`. That covers its Durable Objects, the disks of the Workers behind `kv_namespaces`, `r2_buckets`, `triggers.crons`, `queues`, `workflows` and `d1_databases`, and the Cache API's entries. A manifest or image then needs one flag, whatever the project's name or bindings, and the project can sit in a read-only directory. When the state directory cannot be created, the error names the option. `--data-dir` is refused for a Cap'n Proto config, which names its own directories, and for a binary from `workerd compile`, whose paths were fixed when it was compiled. A joined project cannot have `kv_namespaces` yet: their Worker keeps large values on the local disk of the instance that wrote them, which the other instances cannot read once a namespace's object moves. Nor can it have `queues` yet: the translation does not set up their Worker for a cluster. `triggers.crons`, `workflows`, `d1_databases` and `r2_buckets` work in a cluster as they do outside one; an R2 bucket's objects are in the cluster's bucket. When the directory that esbuild bundles into cannot be created, as in a read-only project, the error suggests `"no_bundle": true`.
`serve` decoded and re-encoded the whole config once to join a cluster with `--cluster-addr` and once more to fill the key and bucket from the environment, and a compiled binary decoded it a third time to check that it has a cluster before joining. `Config::with_cluster` now does all three over one decode and at most one encode. `ClusterFlags` carries `--cluster-addr`, `--cluster-advertise` and whether the config may join a cluster, which a compiled config may not. A `ClusterError` says whether a refusal is a usage error or a missing or unusable key or bucket, which ends the process as before.
The cluster's deployments keep their Durable Objects on each instance's disk service `do-storage`. A wrangler config joined with `--cluster-addr` defines it, but any other config without `cluster` could join too and lack it. For example, `workerd compile --config-only` translates a wrangler config for a server that joins no cluster, so the result has no `do-storage` and skips the refusal of `kv_namespaces` and `queues`. Its node joined, and failed every deployment with Durable Objects. `--cluster-addr` for a config without `cluster` is now a usage error unless the config defines a writable disk service named `do-storage`. The error says to add one or to serve the wrangler config itself. A config with `cluster` is joined as written, as before.
48a5f19 to
cbdabe8
Compare
There was a problem hiding this comment.
✅ Approved — No findings: none of the files changed since the last approved review, and a re-read found no correctness, security, performance or documentation issues.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- A process joins a cluster only when
--cluster-addris passed explicitly, and only with--experimental. - The cluster key and bucket come from the environment, and no error message prints them.
- A deployment's storage key cannot point into a bundled service's directory, because
do-storageis<state>/do. --data-dircan only be set from the operator's command line.
📖 AGENTS.md: ✅ LGTM
The wrangler.rs row in src/workerd/server/AGENTS.md is accurate and reads clearly.
📋 Code Quality: ✅ LGTM
Config::with_clusterhandles every combination of an existingcluster,--cluster-addr,--cluster-advertiseandcan_join, andconfig-test.rstests each one.- To join, a config must define a writable
do-storagedisk.cluster-test.mjscovers the case ofcompile --config-onlyfollowed byserve -b --cluster-addr. - A compiled binary, a binary config and a Cap'n Proto config each refuse
--data-dir, and each refusal is tested. - A joined node keeps
do-storagein<state>/do. Outside a cluster, the<name>-do-storagelayout is the same as before.
⚡ Performance: ✅ LGTM
All of this code runs once, at CLI startup. The config is decoded and re-encoded in a single pass, and the has_cluster_storage scan is linear over the services.
📝 Documentation: ✅ LGTM
The workerd.capnp comments and the serve help text match the behavior at this commit.
Reviewed commit: cbdabe88 — same changes as 48a5f19c, so this is that commit's review (no new review was run; line numbers are as of 48a5f19c)
This lets a Wrangler project join
workerd's experimental clustermode directly, with no Cap'n Proto config.
Joining:
workerd serve --experimental --cluster-addr=<addr>lets a configwithout
clusterjoin with defaults for all other cluster settings,as if it held
cluster = (address = "<addr>"). The key and bucketcome from the environment.
WORKERD_CLUSTER_BUCKET, so a strayenvironment variable cannot make a process join a cluster.
--experimentalis refused.--cluster-advertisewithout a cluster is a usage error.service named
do-storage, as a joined Wrangler project does (seebelow). Without one, its node would fail every deployment with
Durable Objects, so
--cluster-addris a usage error.workerd compilebinary cannot join this way unless its config hascluster; binaries withclustercontinue to work as before.in one pass over the config (
Config::with_cluster).Storage:
do-storagedisk service, which exists even with none declared, sothe node can also serve the Durable Objects of the bucket's
deployments. Its directory is
do/in the state directory, apartfrom the bundled services' directories, which a deployment's storage
key could otherwise name. Outside a cluster, storage remains
<name>-do-storage, in the state directory itself. A worker nameddo-storageis rejected when joining.--data-dir <dir>puts a Wrangler project's state directory, bydefault
.wrangler/state/workerdnext to the config, in<dir>.That covers Durable Objects, the disks of the bundled KV, R2, cron,
Queues, Workflows and D1 Workers, and the Cache API's entries. A
manifest needs one flag whatever the project's name or bindings, and
the project directory can be read-only.
--data-diris refused for a Cap'n Proto config, which names itsown directories, and for a binary from
workerd compile, whosepaths were fixed when it was compiled.
--directory-pathisunchanged.
kv_namespacescannot join a cluster yet: its largevalues would sit on one node's disk, out of reach of the others. Nor
can one with
queues, whose Worker is not yet set up for a clusterby the wrangler translation.
workflows,d1_databasesandr2_bucketscan join: their state is in Durable Objects, and an R2bucket's objects are in the cluster's bucket.
that names
no_bundle.servehelp's cluster setup shows awrangler.jsonjoining with--cluster-addr,--data-dirand the environment variables.servehelp, AGENTS.mdComments in code files are counted with that file, except the
workerd.capnpcomments and the help text, which are documentation.