Skip to content

feat(config): refuse a wildcard advertise_addr, and an operator guide for clustering (#152) - #418

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/152-cluster-validation-docs
Aug 9, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/152-cluster-validation-docs

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #152.

What this refuses, and why that list is short

Nothing validated the cluster: block before this. Validate checked storage, cache, network,
monitoring and mount, then returned — so every value below was accepted and discovered, if at all,
as a runtime symptom on a different host.

The defect worth reading is one #152 does not mention. listen_addr defaults to 0.0.0.0:8080
and advertise_addr is the next key in the file, so copying the value down is the obvious operator
move — and it is the worst one available. advertise_addr is what peers are told to dial, and a peer
that dials a wildcard reaches its own loopback. Measured with net.DialUDP, replicating
gossip.go's sendMessage:

advertise_addr what a peer's dial resolves to
0.0.0.0:8080 remote=127.0.0.1:8080
:8080 remote=127.0.0.1:8080
[::]:8080 remote=[::1]:8080

The dial succeeds. Since gossip is one-way UDP, no send fails and no reply is expected, so a
three-node cluster silently becomes three clusters of one — each mounting, serving reads and
reporting healthy, and each able to serve an object a peer has already overwritten. An integrity
outcome with no error anywhere, so it fails closed.

Also refused, each with a diagnostic naming the key and the value:

  • a negative replication_factor — applyConfigDefaults only substitutes for 0, so a negative
    value survives; min(rf, len(alive)) stays negative, LoadBalancer.SelectNodes returns [] for
    any count <= 0 (probed with -1, 0, 1, 3, 99), and executeOnce turns that into no target nodes selected — naming neither the key nor the value.
  • a non-host:port address, a non-numeric port, and port 0 on advertise_addr.

Port 0 stays legal on listen_addr, because the asymmetry is real and measured: ListenUDP on
127.0.0.1:0 binds and the kernel assigns a port (49314 observed), while DialUDP to 127.0.0.1:0
fails with can't assign requested address. That is why validateGossipAddr is separate from
validateListenAddr rather than reusing it — the latter's port-0 advice is right for a monitoring
endpoint and wrong here. Reusing it first broke two real internal/adapter tests that set
cluster.listen_addr: 127.0.0.1:0 on purpose; the check was wrong, not the tests, and
ClusterManager.GossipAddr exists precisely to report the kernel-assigned port back.

What warns instead of failing

Two settings are legal in one deployment and wrong in another, so they are --dry-run warnings:

Setting Legitimate use What it does otherwise
seed_nodes: [] the first node of a new cluster every later node forms its own cluster of one
loopback advertise_addr a single-host dev cluster peers on other hosts reach their own loopback

Refusing either breaks a real deployment — the second is what NewDefault sets and what the shipped
Compose file uses. Ignoring either ships a silent partition. Warnings go to stderr and the exit
code stays 0, so a config-management tool can still bring up a first node.

The section reports the cluster secret by source, never by value (from OBJECTFS_CLUSTER_SECRET,
from <path>, or not configured — the cluster will refuse to start). A dry run gets pasted into
issues, and which of the two sources is in use is the hardest thing to establish from outside, since
the environment leaves no trace in the file.

Three of the six documented sections could not be written

Stated here rather than faked, and repeated in the page's limitations section:

  1. cluster.persistent_log, cluster.data_dir and peer_fetch_timeout have zero occurrences in
    the tree
    , so the in-memory-to-persistent-log upgrade procedure describes nothing, and two of the
    issue's validation rows have no field to validate.
  2. The consistency-modes section is replaced by CAS-against-S3: ConsistencyEventual/Session/ Strong were removed in 0.12.0 and survive only as a comment recording it.
  3. The issue's own proposed check — enabled && advertise_addr == "" — can never fire, verified
    by calling Validate: NewDefault sets the field and applyConfigDefaults sets it again.

Two more of the issue's numbers are corrected in the page: the gossip port is 8080, not 7946
(7946 is memberlist's default and appears in some test fixtures, but is the default nowhere in the
code — an operator who opens only 7946 gets the silent-partition failure by following the docs), and
the cache-sizing formula must not multiply by replication_factor, because the cluster makes no
copies. S3 holds the single one; the factor is a selection width.

The documentation gate

internal/config/docs_distributed_test.go exists because the four existing documentation gates
cannot see what this page gets wrong: a default written as prose in a table cell is invisible to
the YAML gate, the symbol gate and the link gate alike. It pins the defaults against NewDefault,
requires a table row for every ClusterConfig yaml tag, checks each documented environment variable
against getEnvMappings() — #146's defect exactly, four variables documented and unread — and
asserts the three absent keys are still absent. That last one inverts the usual staleness
direction: the claim goes stale when someone does the work, at which point the page is telling an
operator a shipped feature is unavailable, so the test says to write the section rather than delete
the check.

Verification

Mutation-verified, since a predicted failure signature has been wrong here before. 10 mutations of
the two source files
(wildcard refusal deleted, negative RF allowed, the validateClusterConfig
call removed, port 0 allowed on advertise, the enabled guard removed; seed warning suppressed,
loopback warning suppressed, emitClusterDryRun call removed, the section printed when the cluster
is off, secret material printed) and 6 of the documentation gates — all caught, every file
restored clean.

One mutation initially missed: deleting the secret_file table row passed, because the key is
also named in the prose three paragraphs down. The check now requires a row rather than a mention,
and the reason is in the test's comment.

  • go build ./..., gofmt -l ., go vet ./... — clean
  • golangci-lint run — 0 issues
  • go test -race ./... — pass
  • coverage gate under CI's own conditions (CGO_ENABLED=1 go test -covermode=atomic over the whole
    tree) — 35 packages at or above their floor
  • end-to-end --dry-run: prints the block plus both warnings at exit 0 for a loopback/no-seeds/
    no-secret config, prints the block with no warnings for a good three-node config, and prints
    nothing for deploy/docker/node-config.yaml

… for clustering (#152)

Nothing validated the `cluster:` block before this. `Validate` checked storage, cache, network,
monitoring and mount, then returned — so every value below was accepted and discovered, if at all,
as a runtime symptom on a different host.

The defect worth naming is one #152 does not mention, found by probing rather than by reading the
issue. `listen_addr` defaults to `0.0.0.0:8080` and `advertise_addr` is the next key in the file,
so copying the value down is the obvious operator move, and it is the worst one available.
`advertise_addr` is what peers are told to dial, and a peer that dials a wildcard reaches its own
loopback: measured with net.DialUDP, `0.0.0.0:8080` resolves to `remote=127.0.0.1:8080` and
`[::]:8080` to `remote=[::1]:8080`, and the dial *succeeds*. Gossip is one-way UDP, so no send
fails and no reply is expected — a three-node cluster becomes three clusters of one, each mounting,
serving reads and reporting healthy, and each able to serve an object a peer has already
overwritten. That is an integrity outcome with no error anywhere, so it fails closed.

Also refused: a negative `replication_factor` (applyConfigDefaults only substitutes for 0, so a
negative value survives, SelectNodes returns nothing for any count <= 0, and every write fails with
"no target nodes selected" — naming neither the key nor the value), a non-host:port address, a
non-numeric port, and port 0 on `advertise_addr`. Port 0 stays legal on `listen_addr`, because the
asymmetry is real and measured: ListenUDP on 127.0.0.1:0 binds and the kernel assigns a port, while
DialUDP to 127.0.0.1:0 fails with "can't assign requested address". This is why validateGossipAddr
is separate from validateListenAddr rather than reusing it — the latter's port-0 advice is right for
a monitoring endpoint and wrong here. Reusing it first broke two real adapter tests that set
`cluster.listen_addr: 127.0.0.1:0` deliberately; the check was wrong, not the tests.

Two settings are warnings on --dry-run instead, because each is correct in one deployment and wrong
in another: an empty `seed_nodes` is how the first node of a new cluster is configured, and a
loopback `advertise_addr` is what NewDefault sets and what the shipped Compose file uses. Refusing
either breaks a real deployment; ignoring either ships a silent partition. Warnings go to stderr and
the exit code stays 0, so a config-management tool can still bring up a first node. The section
reports the cluster secret by source and never by value — a dry run is the kind of output that gets
pasted into an issue, and which of OBJECTFS_CLUSTER_SECRET or `secret_file` is in use is the hardest
thing to establish from outside, since the environment leaves no trace in the file.

Three of the six documentation sections #152 asked for could not be written, and are not faked.
`cluster.persistent_log`, `cluster.data_dir` and `peer_fetch_timeout` have zero occurrences in the
tree, so the in-memory-to-persistent-log upgrade procedure describes nothing; the consistency-modes
section is replaced by CAS-against-S3, because ConsistencyEventual/Session/Strong were removed in
0.12.0 and survive only as a comment recording it. The issue's own proposed check — `enabled &&
advertise_addr == ""` — can never fire, verified by calling Validate: NewDefault sets the field and
applyConfigDefaults sets it again. docs/admin-guide/distributed.md lists what is absent under
limitations instead, and corrects two more of the issue's numbers: the gossip port is 8080, not
7946, and the cache-sizing formula must not multiply by `replication_factor`, because the cluster
makes no copies and S3 holds the single one.

internal/config/docs_distributed_test.go gates the page, because the four existing documentation
gates cannot see what it gets wrong: a default written as prose in a table cell is invisible to the
YAML gate, the symbol gate and the link gate alike. It pins the defaults against NewDefault, checks
every ClusterConfig yaml tag has a table row, checks each documented environment variable against
getEnvMappings — #146's defect exactly, four variables documented and unread — and asserts the three
absent keys are still absent, which inverts the usual staleness direction: that claim goes stale
when someone does the work, at which point the page tells an operator a shipped feature is
unavailable.

Verified by mutation, since a predicted failure signature has been wrong before: 10 mutations of the
two source files and 6 of the documentation gates, all caught, every file restored. The row check
needed tightening after one miss — deleting the `secret_file` row passed, because the key is also
named in the prose three paragraphs down, so it now requires a table row rather than a mention.

go build ./..., gofmt, go vet, golangci-lint (0 issues), go test -race ./... all clean, and the
coverage gate passes under CI's own conditions: 35 packages at or above their floor.
…ement

TestClusterAddrsAllowPortZeroOnlyWhereItBinds asserted that net.DialUDP to "127.0.0.1:0" fails, on
the strength of a measurement made on darwin, where it returns "can't assign requested address". It
passed locally and failed in CI at validate_cluster_test.go:215 with the message it was written to
print: "dialing 127.0.0.1:0 succeeded ... that rule should be reconsidered rather than kept on
faith".

Measured on Linux rather than reasoned about: the dial succeeds, reports remote=127.0.0.1:0, and a
subsequent Write returns n=12 with a nil error. The datagram goes nowhere.

So the rule stands and its justification was half wrong. The platforms differ only in where the
failure appears, and Linux — the platform CI runs and most deployments use — is the worse of the two:
darwin refuses at the dial, while Linux accepts the address, accepts the send, and drops the datagram
with nothing reported at either end. That is exactly the silent-partition shape this validation
exists for, so an advertised port 0 is refused on every platform and the error message now describes
both behaviours instead of the one I happened to measure.

The dial probe is removed rather than made conditional. Its purpose was to keep the rule honest if
the platform changed, but a probe that behaves differently per platform asserts something about the
runner instead of about the rule. What remains asserted is the half that is observable on both: the
listening side binds and the kernel assigns a real port, so port 0 has to stay legal on
cluster.listen_addr — which internal/distributed's testConfig sets and ClusterManager.GossipAddr
exists to report back. The unobservable half is argued in the doc comment and in the refusal's own
message, because a test cannot assert "the send silently goes nowhere" without a receiver to prove
the absence against, and a negative over UDP is a timeout rather than a fact.

Verified on both platforms this time: ./internal/config/ and ./cmd/objectfs/ pass on darwin and pass
in a linux/amd64 container. gofmt clean.
@scttfrdmn
scttfrdmn merged commit ce86a62 into main Aug 9, 2026
39 checks passed
@scttfrdmn
scttfrdmn deleted the feat/152-cluster-validation-docs branch September 20, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A3-3: Distributed mode config documentation and validation

1 participant