Skip to content

fix(sdk): the Python SDK wrote config files the daemon refused to start on (#385) - #394

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/385-python-cluster-keys
Aug 9, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/385-python-cluster-keys

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

What was wrong

Configuration.to_yaml() in the Python SDK emitted sixteen keys internal/config does not define, across seven sections. LoadFromFile decodes strictly, so save_to_file produced a document the daemon refused at startup, naming the first key it hit:

line 4: field pid_file not found in type config.GlobalConfig

This affected the default Configuration() and all five presets — so the SDK's documented path (build a config, save_to_file, mount with it) could not work at all. sdks/python/README.md's "Written out, this is what the daemon reads" was false for every configuration the SDK could produce.

#385 named three of the sixteen. The other thirteen were found by the test that closes it, on its first run.

What was removed, and why not added to the Go schema instead

Key(s) Why removed
global.pid_file, global.daemon ObjectFS does not fork — no background mode to select, no forked child's pid to record
storage.s3.timeout An int of unstated unit; the real settings are network.timeouts.connect/read/write, as durations
performance.read_ahead_size Removed Go-side in v0.11.0 for naming a second read-ahead size beside performance.read_ahead.window_size (#176)
performance.max_write_buffer Is write_buffer.max_memory
cluster.election_timeout, heartbeat_interval, join_timeout Exist on internal/distributed.ClusterConfig — a disjoint type from internal/config.ClusterConfig, no conversion between them (#139). Grepped sdks/: no consumer of any of the three, which answers #385's open question about join_timeout
security.tls_ca_path No CA path in the schema's security block; trust configuration is the security.tls block
monitoring.opentelemetry.headers Where an OTLP bearer token would go, in a document the loader rejected. An unloadable place to put a credential is worse than no key
the entire fuse block (6 keys) Replaced by the three the Go schema has: direct_io, keep_cache, sync_read. The removed six were doubly inert — discarded by the loader, and allow_other/uid/gid are ones cmd/objectfs/doc.go already records as not settable because nothing on the adapter's mount path reads them

The gate

A cross-language contract in the reverse direction from the metrics fixture. internal/metrics generates sdks/testdata/metrics-scrape.txt for the SDKs to parse because the Go exporter is the authority on metric names; here the Go loader is the authority on config keys, so the SDK generates and Go checks.

  • Each preset's to_yaml() output is committed under sdks/testdata/presets/.
  • internal/config's TestSDKPresetsLoadUnderTheGoLoader globs that directory and runs every file through LoadFromFile + Validate — so a preset added on the Python side is covered without editing the Go side.
  • It asserts the property, not a key list. Python SDK's to_yaml emits three cluster keys the Go loader refuses #385's acceptance criteria asked for exactly this, and the reason is visible in the outcome: a list is a second copy of the schema and would have had to be right about all sixteen keys to catch them.
  • TestSDKPresetsAreNotAllDefaults is the companion assertion, matching TestShippedConfigsSetWhatTheySay: a document that loads cleanly and changes nothing is not evidence the contract holds.

The Python half compares rather than writes, taking OBJECTFS_UPDATE_FIXTURES=1 to regenerate. Without that, the Go gate would read committed files and stay green on stale ones — edit config.py, skip pytest, and a refused key ships green. That is the same asymmetry TestSDKFixtureMatchesTheLiveScrape uses with -update-fixture. Both halves run in CI; the Python half in the existing sdk-metrics job, whose comment now says so.

Verification

Mutation-checked in both directions (reintroduced cluster.join_timeout):

  • Without regenerating → the Python comparison fails on all six documents, naming the regeneration command.
  • Regenerating with it → the Go gate fails naming the key and the line: line 28: field join_timeout not found in type config.ClusterConfig.

Also: go build ./... && gofmt -l . && go vet ./... clean, golangci-lint run → 0 issues, go test -race ./... clean, pytest tests/ → 72 passed / 31 subtests.

One test defect fixed in passing

MergeIsDeepTest.test_nested_s3_field asserted its siblings survived a merge using max_retries and s3.timeout — both already at their dataclass defaults, so a broken one-level merge would have left them looking correct. That is precisely the failure mode the test's own comment warns about ("the dataclass hid the loss for most fields"). Removing s3.timeout surfaced it. It now merges from the production preset and asserts on use_acceleration, which is True there and False by default, so it can actually tell the two apart.

Closes #385

…rt on (#385)

`Configuration.to_yaml()` emitted sixteen keys `internal/config` does not
define, across seven sections, and `LoadFromFile` decodes strictly — so
`save_to_file` produced a document that failed at startup naming the first
key it hit. The default `Configuration()` and all five presets were
affected, which means the SDK's documented path (build a config, save it,
mount with it) could not work at all.

#385 named three of the sixteen: `cluster.election_timeout`,
`heartbeat_interval` and `join_timeout`. The other thirteen were found by
the test that closes it, on its first run, which is the argument for the
test's shape. Also removed: `global.pid_file` and `global.daemon` (ObjectFS
does not fork), `storage.s3.timeout` (an int of unstated unit where the real
settings are three `network.timeouts` durations),
`performance.read_ahead_size` and `max_write_buffer`,
`security.tls_ca_path`, `monitoring.opentelemetry.headers`, and all six keys
of the `fuse` block — replaced by the three the Go schema has. Three of the
six removed FUSE keys are ones `cmd/objectfs/doc.go` already records as not
settable, so they were doubly inert: discarded by the loader, and with
nothing to reach even had they loaded.

Removed rather than added to the Go schema. In each case the setting either
had a real home under another name or had nothing to reach, and the three
cluster timeouts exist only on `internal/distributed.ClusterConfig` — a
disjoint type with no conversion to the config one (#139).

The gate is a cross-language contract in the reverse direction from the
metrics fixture: the SDK generates, Go checks, because the Go loader is the
authority on what a config document may contain. Each preset's `to_yaml()`
is committed under `sdks/testdata/presets/` and
`TestSDKPresetsLoadUnderTheGoLoader` globs the directory and runs every file
through `LoadFromFile` and `Validate`. It asserts the property rather than
comparing emitted keys against a list — a list is a second copy of the
schema and would have had to be right about all sixteen.

The Python half compares rather than writes, taking
`OBJECTFS_UPDATE_FIXTURES=1` to regenerate, because a Go test reading
committed files would otherwise stay green on stale ones. Verified by
mutation in both directions: reintroducing one key fails the Python
comparison on all six documents, and regenerating with it fails the Go gate
naming the key and line.

`test_nested_s3_field`'s sibling assertion was rewritten while removing
`s3.timeout`: it asserted on two fields already at their defaults, which a
broken one-level merge would have left looking correct — the exact failure
mode its own comment warns about. It now merges from the production preset
and asserts on `use_acceleration`, which differs from the default.

Closes #385
@scttfrdmn
scttfrdmn merged commit 627b65d into main Aug 9, 2026
35 checks passed
@scttfrdmn
scttfrdmn deleted the fix/385-python-cluster-keys branch August 9, 2026 00:56
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.

Python SDK's to_yaml emits three cluster keys the Go loader refuses

1 participant