Skip to content

feat(api): serve real stats from a background sampler - #55

Merged
mattmattox merged 1 commit into
mainfrom
claude/api-stats-provider-260e40
Nov 10, 2026
Merged

mattmattox merged 1 commit into
mainfrom
claude/api-stats-provider-260e40

Conversation

@mattmattox

@mattmattox mattmattox commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Mount now sets a stats provider, so /api/v1/stats/* stops answering 503 and /metrics exports cache, journal, TRIM, lock, cluster and capacity values.

Reviewer notes:

  • /metrics needs no auth, so requests only read a snapshot. Counters refresh every 1s; the bitmap and node registry are read every 15s.
  • The API's sfb fields describe block allocation, but SFB containers are disabled, so /stats/sfb answers 404 and there are no sfb_* metrics. Capacity is goclusterfs_fs_{size,free}_bytes.
  • goclusterfs_journal_state changed meaning: the old open value never occurred.
  • feat(api): add gfsctl, a web dashboard and cluster endpoints (unfinished) #52 adds ClusterNodes/ClusterLocks to StatsProvider; the Sampler needs them once both land.

Testing on .68: lint 0 issues, race unit 20/20 packages, TestAPIStatsReportLiveValues and TestAPIServesHealthOnLoopback pass (load 341).

🤖 Generated with Claude Code

/api/v1/stats/* answered 503 and /metrics had no filesystem metrics because
mount never set a stats provider. internal/stats now has a Sampler that
copies the cache, lock, journal and TRIM counters every second and reads the
block bitmap and node registry every 15 seconds. Requests, including the
unauthenticated /metrics, only load the latest snapshot. /api/v1/status
takes its capacity from the same snapshot instead of scanning the bitmap per
request.

- lock.Manager.Stats: held keys, waiting Acquire calls, hint cache size
- trim.Stats: failed discard ranges, last discard time, batch size
- node.Registry.Slots no longer holds the registry mutex across 64 reads
- SFB stays disabled: /stats/sfb answers 404 and no sfb_* metrics
- goclusterfs_journal_state maps clean/dirty/recovering/corrupt; the old
  "open" value never occurred
- new goclusterfs_fs_size_bytes and goclusterfs_fs_free_bytes
- removes the unused stats.Collector

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit 4d7b9a5 into main Nov 10, 2026
10 checks passed
mattmattox added a commit that referenced this pull request Nov 10, 2026
…nts honest (#58)

Review follow-ups for #55:
- The sampler reads the block bitmap and node registry only while requests
  read capacity or cluster data; an idle mount no longer scans the bitmap
  every 15 seconds. The first request after a quiet period starts a read.
- pending_locks counts only Acquire calls whose first attempt found the
  lock taken, not every uncontended acquire in flight.
- TRIM no longer counts EOPNOTSUPP/ENOTTY ranges as discarded. The device
  is marked unsupported and trim_enabled reports false. A flush the bitmap
  guard refuses now counts as an error.
- Rename the cache stats variable that shadowed the stats package.
- The two API integration tests are high priority with Docker/VM TODOs.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant