Repository navigation
Description
pkg/api/server.go is 547 lines declaring 12 routes — mount lifecycle, mount
listing, object listing, metrics, health, config — and nothing in the
repository imports it:
$ grep -rn 'objectfs/pkg/api' --include='*.go' . | grep -v '^./pkg/api/'
(no output)
cmd/objectfs/main.go does not construct it. No make target starts it. Its
only exercise is pkg/api/server_test.go, 905 lines testing handlers no
process ever serves — so the package has coverage and no reachability, which
is the combination that makes dead code look maintained.
Why this is worth a separate issue
It came up while resolving #336. docs-platform's ApiPlayground component
offered seven endpoints; six of them — /api/v1/metrics, /api/v1/mount,
/api/v1/mount/{mount_point}, /api/v1/mounts, /api/v1/storage/objects,
and a second health route — do not exist in any reachable form. They looked
plausible precisely because pkg/api declares routes with those shapes. A
package that declares an HTTP surface nobody serves is a source of
documentation that cannot be checked against behaviour, because there is no
behaviour.
The real HTTP surface of a running mount is two endpoints:
| endpoint | served by | address from |
|---|---|---|
/metrics |
internal/metrics/collector.go:171 |
monitoring.metrics.addr |
/health |
internal/health/checker.go:532 |
monitoring.health_checks.addr |
The decision this needs
Not "delete it" by default — unlike pkg/profiling (#245), this one is a
plausible future feature rather than a security liability, and it starts no
listener on its own. Three options:
- Wire it up behind an explicit config key, with the same loopback
default and the same unauthenticated-listener warning/healthand
/metricscarry in SECURITY.md. Note thatpkg/api/server.go:389is one
of the outstanding errcheck sites, so it does not currently pass the lint
bar for shipped code. - Delete it, as pkg/profiling has no importer and serves unauthenticated mutating endpoints: delete it, or make it safe to enable #245 did, on the argument that 1,452 lines with no
importer are a liability and the two real endpoints cover the operational
need. - Mark it explicitly — a
doc.gosaying it is unreachable scaffolding
and what wiring it up would require, in the style of
internal/fuse/filesystem.go's EROFS stub or
internal/distributed/gossip.go:823-828.
Filing rather than deciding, because option 1 is a real feature decision:
whether ObjectFS should offer a control-plane API at all is not a cleanup
question.
Activity
chore: delete pkg/api, twelve routes nothing served (#367)
chore: delete pkg/api, twelve routes nothing served (#367) (#396)