Repository navigation
fix(sdk): the Python SDK wrote config files the daemon refused to start on (#385) - #394
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
Configuration.to_yaml()in the Python SDK emitted sixteen keysinternal/configdoes not define, across seven sections.LoadFromFiledecodes strictly, sosave_to_fileproduced a document the daemon refused at startup, naming the first key it hit: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
global.pid_file,global.daemonstorage.s3.timeoutintof unstated unit; the real settings arenetwork.timeouts.connect/read/write, as durationsperformance.read_ahead_sizeperformance.read_ahead.window_size(#176)performance.max_write_bufferwrite_buffer.max_memorycluster.election_timeout,heartbeat_interval,join_timeoutinternal/distributed.ClusterConfig— a disjoint type frominternal/config.ClusterConfig, no conversion between them (#139). Greppedsdks/: no consumer of any of the three, which answers #385's open question aboutjoin_timeoutsecurity.tls_ca_pathsecurityblock; trust configuration is thesecurity.tlsblockmonitoring.opentelemetry.headersfuseblock (6 keys)direct_io,keep_cache,sync_read. The removed six were doubly inert — discarded by the loader, andallow_other/uid/gidare onescmd/objectfs/doc.goalready records as not settable because nothing on the adapter's mount path reads themThe gate
A cross-language contract in the reverse direction from the metrics fixture.
internal/metricsgeneratessdks/testdata/metrics-scrape.txtfor 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.to_yaml()output is committed undersdks/testdata/presets/.internal/config'sTestSDKPresetsLoadUnderTheGoLoaderglobs that directory and runs every file throughLoadFromFile+Validate— so a preset added on the Python side is covered without editing the Go side.TestSDKPresetsAreNotAllDefaultsis the companion assertion, matchingTestShippedConfigsSetWhatTheySay: 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=1to regenerate. Without that, the Go gate would read committed files and stay green on stale ones — editconfig.py, skip pytest, and a refused key ships green. That is the same asymmetryTestSDKFixtureMatchesTheLiveScrapeuses with-update-fixture. Both halves run in CI; the Python half in the existingsdk-metricsjob, whose comment now says so.Verification
Mutation-checked in both directions (reintroduced
cluster.join_timeout):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_fieldasserted its siblings survived a merge usingmax_retriesands3.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"). Removings3.timeoutsurfaced it. It now merges from theproductionpreset and asserts onuse_acceleration, which isTruethere andFalseby default, so it can actually tell the two apart.Closes #385