Repository navigation
fix: one address per listener, beside the flag that enables it - #246
Merged
Merged
Conversation
Closes #202, #211, #212, and #192's validation half. They are one code path: the endpoints bound a hardcoded wildcard, and the settings that would have changed them were inert. A port cannot express what these settings need. It cannot name an interface — so `fmt.Sprintf(":%d", port)` was the only bind possible, and every value of `metrics_port` published an unauthenticated endpoint on every interface (#211) — and it cannot say "off" without overloading zero, which the two blocks did differently: `health_port: 0` disabled its listener while `metrics_port: 0` read as unset, defaulted back to 8080, and bound it (#212). `monitoring` already declared `metrics_addr` and `health_check_addr`, defaulted them, documented them, and read neither (#202). So an operator who set `health_check_addr: 127.0.0.1:8081` got a wildcard bind and no warning: the live setting could not express a host and the expressive setting was dead. An address subsumes a port, so keeping both would preserve the disagreement. Removed: `global.metrics_port`, `global.health_port`, `global.profile_port`, `monitoring.metrics_addr`, `monitoring.health_check_addr`, `monitoring.enable_pprof`. Added: `monitoring.metrics.addr` and `monitoring.health_checks.addr`, each inside the block whose `enabled` flag governs it, both defaulting to loopback. Same ports, so a same-host scrape survives the upgrade; the host is what changed. `enable_pprof`/`profile_port` are removed rather than wired. Nothing read either, and `pkg/profiling` — the only pprof server here — has no importer, binds every interface too, and serves mutating /memory/gc and /memory/free with no auth. Filed as #245. Bind errors now propagate. Both servers used to bind on a goroutine and log, which contradicts #192's claim that non-fatal was right for observability: `enabled: false` is already how you ask for no endpoint, and an operator who asked for one and did not get it finds out when a probe fails. `OBJECTFS_METRICS_ENABLED` was documented in two places and assigned nothing — #202's shape in the setting that closes an endpoint rather than the one that moves it. Now wired, with a new `OBJECTFS_HEALTH_ENABLED`. Both parse strictly: these govern unauthenticated endpoints that default to on, so coercing a typo is wrong whichever direction it picks. The test gap is the more interesting half. `TestStartMetricsBindsTheEndpoint` scraped 127.0.0.1 and passed against a wildcard bind, because a wildcard answers on loopback too — the tests asserted that something was listening, never that it was listening where configured. `Collector.Addr()` now reports the bound address, and the regression tests assert both that it equals what was configured and that the endpoint does *not* answer on a routable non-loopback address of the host. Verified by mutation: restoring the `":"+port` bind fails both halves while the old-shaped test stays green. internal/config 87.7% → 90.4%; validateListenAddr to 100%.
#192's third gap, which the address work did not close. `grep -rn health_port docs/ README.md configs/ examples/` returned nothing: the knob existed, was read, changed behavior, and was named in no shipped documentation. That is still true of the addresses that replaced it — they are in the two example config files and in package docs, neither of which is where someone looks to find out what a mount publishes. README gains a *Metrics and health endpoints* section: both addresses, the `curl` that reaches each, the four environment overrides, `enabled: false` as the only spelling of off, why port 0 is rejected rather than read as off, and that a Prometheus scrape of localhost:8080 needs no change on upgrade. Its YAML block is checked against the live schema by TestDocumentedConfigYAMLMatchesTheSchema, so it cannot drift into describing keys the loader does not have. docs/index.md listed "Health monitoring: health endpoint and internal checks" with nowhere to point a probe. It now names the address each endpoint is on and links the README section and SECURITY.md. Also corrects validateListenAddr's own doc comment, which described the pre-fix behavior in the present tense — "both servers bind on a goroutine and log the error" stopped being true in the same change that added the validation. What the check actually buys now is where the failure is reported: net.Listen can only say "invalid port", naming neither the setting nor the file, and it says it after the backend is constructed. The non-numeric-port error message carried the same stale claim. Refs #192
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.
Closes #202, #211, #212, and #192's validation half.
These are one code path, not four issues. The listener endpoints bound a hardcoded wildcard, and the settings that would have changed them were inert.
Why a port could not be fixed in place
A port cannot name an interface.
fmt.Sprintf(":%d", port)was the only bind it could produce, so every value ofmonitoring.metrics_portpublished an unauthenticated endpoint on every interface (#211).A port also cannot say "off" without overloading zero, and the two blocks overloaded it in opposite directions:
health_port: 0disabled its listener, whilemetrics_port: 0was treated as unset, defaulted back to 8080, and bound it (#212). Two adjacent fields spelled "off" differently, and the metrics one failed in the direction that leaves a port open.Meanwhile
monitoringdeclaredmetrics_addrandhealth_check_addr, defaulted them, documented them — and read neither (#202). So an operator who sethealth_check_addr: 127.0.0.1:8081to keep a diagnostic endpoint off the network got a wildcard bind and no warning: the live setting could not express a host, and the expressive setting was dead.An address subsumes a port, so keeping both would preserve the disagreement.
What changed
Removed:
global.metrics_port,global.health_port,global.profile_port,monitoring.metrics_addr,monitoring.health_check_addr,monitoring.enable_pprof.Added:
monitoring.metrics.addrandmonitoring.health_checks.addr— each inside the block whoseenabledflag governs it, both defaulting to loopback (127.0.0.1:8080,127.0.0.1:8081). Same ports, so an existing same-host Prometheus scrape survives the upgrade; the host is what changed. Both endpoints are on by default and neither is authenticated: between them they report per-operation counts, error rates, sizes and timings, and/healthreports component names and error strings.Removed rather than deprecated, because strict decoding then names the key and line to edit. A key kept as an ignored field means an operator's listener settings silently stop applying on upgrade.
enable_pprof/profile_portare removed rather than wired. Nothing read either. The one pprof server in the tree ispkg/profiling's, which has no importer, also binds every interface, and serves mutating/memory/gcand/memory/freewith no authentication — binding a third unauthenticated listener inside the change that stops binding two of them was the wrong trade on the strength of a boolean nothing read. Filed as #245.Bind errors propagate. Both servers bound on a goroutine and logged. That deliberately contradicts #192's reasoning that non-fatal was "the right call for observability":
enabled: falseis already how you ask for no endpoint, and an operator who asked for one and did not get it finds out when a liveness probe starts failing.Validation catches what a listener reports badly.
net.SplitHostPortaccepts"99999", so the 1–65535 range is checked explicitly and the error names the field.health_port: 99999used to reachnet.Listenfrom YAML unchecked. Names likelocalhostare allowed — the shape is checked, not the resolution.OBJECTFS_METRICS_ENABLEDis now wired, along with a newOBJECTFS_HEALTH_ENABLED. The former was documented incmd/objectfs/doc.goandOBJECTFS.mdand assigned nothing — #202's shape in the setting that closes an endpoint rather than the one that moves it. Both parse strictly and fail startup naming the variable, where the feature-flag variables coerce anything but"true"to false: these govern unauthenticated endpoints that default to on, so silent coercion is wrong whichever direction it picks.The test gap
The more interesting half.
TestStartMetricsBindsTheEndpointscraped127.0.0.1and passed against a wildcard bind — because a wildcard bind answers on loopback too. The tests asserted that something was listening, never that it was listening where the configuration said.Collector.Addr()now reports the bound address, and three new regression tests (metrics, health, adapter) assert two things:0.0.0.0or[::]here;Verified by mutation. Restoring the
":"+portbind fails both halves (bound [::]:61260, configured 127.0.0.1:61260, and/metrics answered on 192.168.6.94) while the old-shapedTestScrapeServesTheDocumentedPathstays green — demonstrating the gap the issue describes. Deleting the SDK'scfg.Monitoring.Metrics.Addr = c.opts.metricsAddrmapping fails the new SDK tests, including the guard that refuses a fixture equal to the field's default.Gates
go build ./...,go vet ./...(and-tags=e2e) cleango test -race ./...— 33 packages, all greengolangci-lint run --new-from-merge-base=origin/main— 0 issuesscripts/coverage-gate.sh— every floor met;internal/config87.7% → 90.4%,validateListenAddrto 100%Doc and config surfaces repointed together, so strict decoding does not reject a file this repo ships or documents:
examples/config.yaml,configs/example.yaml,SECURITY.md,OBJECTFS.md,cmd/objectfs/doc.go,internal/config/doc.go,internal/metrics/doc.go,docs-platform/guide/getting-started.md, all three SDKs, andtests/{unit,integration,e2e}_test.go.