Skip to content

feat: add per-space storage quotas with admin API#32

Merged
skgbafa merged 5 commits intomainfrom
feat/per-space-quotas
Mar 11, 2026
Merged

feat: add per-space storage quotas with admin API#32
skgbafa merged 5 commits intomainfrom
feat/per-space-quotas

Conversation

@skgbafa
Copy link
Copy Markdown
Contributor

@skgbafa skgbafa commented Mar 11, 2026

Summary

  • Add QuotaCache for per-space storage limits with in-memory overrides and optional billing sidecar integration
  • Add admin API endpoints (/admin/quota/*) for managing per-space quotas, protected by TINYCLOUD_ADMIN_SECRET
  • Replace global storage limit with per-space quotas in invoke route
  • Return HTTP 402 (Payment Required) when storage quota exceeded
  • Use constant-time comparison for admin auth via subtle crate

Details

Quota Resolution Priority

  1. In-memory override (set via admin API)
  2. Quota sidecar lookup (if TINYCLOUD_QUOTA_URL set)
  3. Default config limit
  4. No limit (unlimited)

Admin Endpoints

  • PUT /admin/quota/<space_id> — Set quota override
  • GET /admin/quota/<space_id> — Get quota info + current usage
  • DELETE /admin/quota/<space_id> — Remove override (reverts to default)
  • GET /admin/quota — List all overrides

Environment Variables

  • TINYCLOUD_ADMIN_SECRET — Required for admin API access
  • TINYCLOUD_QUOTA_URL — Optional billing sidecar URL for quota lookups

Test plan

  • Verify admin endpoints with valid/invalid auth
  • Test quota enforcement during invoke
  • Test billing sidecar fallback when unavailable
  • Verify 402 response when quota exceeded

skgbafa added 4 commits March 11, 2026 08:52
The quota system is not billing-specific — any tinycloud operator can use
it. Rename TINYCLOUD_BILLING_URL → TINYCLOUD_QUOTA_URL, and expose the
configured quota URL in the /version endpoint so SDKs can discover it.
Both endpoints return the same NodeInfo payload including quota_url.
New SDKs use /info, older clients continue to work via /version.
@skgbafa skgbafa merged commit a5ecad7 into main Mar 11, 2026
13 checks passed
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