Skip to content

feat(#136): add operator endpoint to update tenant quotas#145

Merged
dennisonbertram merged 2 commits intomainfrom
issue-136-quota-endpoint
Mar 22, 2026
Merged

feat(#136): add operator endpoint to update tenant quotas#145
dennisonbertram merged 2 commits intomainfrom
issue-136-quota-endpoint

Conversation

@dennisonbertram
Copy link
Owner

Summary

  • Adds PATCH /v1/tenants/{tenantID}/quotas authenticated via bootstrap token
  • Supports partial updates: max_services, max_databases, max_builds_concurrent, max_env_vars_per_service
  • Validation with hard caps (100/50/10/500) and positive-value checks
  • AUDIT logging on quota changes
  • New migration state_014_quota_columns.sql adds max_builds_concurrent and max_env_vars_per_service columns

Closes #136

Test plan

  • 15 tests: partial/full update, validation, auth, AUDIT logging, edge cases
  • go build ./... passes
  • go test ./... passes (pre-existing flaky test unrelated)

🤖 Generated with Claude Code

dennisonbertram and others added 2 commits March 22, 2026 07:42
Adds PATCH /v1/tenants/{tenantID}/quotas authenticated via bootstrap
token so operators can adjust per-tenant resource limits without
direct DB access. Supports partial updates (only non-nil fields are
written), validates positive values within hard caps (services=100,
databases=50, builds=10, env_vars=500), and logs all changes at
AUDIT level.

Includes migration state_014 adding max_builds_concurrent and
max_env_vars_per_service columns to tenant_quotas.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffeed365ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +705 to +706
setClauses = append(setClauses, "max_builds_concurrent = ?")
args = append(args, *req.MaxBuildsConcurrent)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wire max_builds_concurrent into build scheduling

This handler accepts and stores max_builds_concurrent, but the runtime build path never consults tenant quotas: internal/builder/builder.go still uses fixed concurrency (buildSem capacity 3) and a hard per-tenant single-build gate in acquireTenant (return false if one build is active). That means operators can PATCH this field successfully yet tenant build concurrency behavior does not change, so the new quota is effectively non-functional.

Useful? React with 👍 / 👎.

Comment on lines +709 to +710
setClauses = append(setClauses, "max_env_vars_per_service = ?")
args = append(args, *req.MaxEnvVarsPerService)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce max_env_vars_per_service in env var writes

The endpoint persists max_env_vars_per_service, but env-var mutation paths still use static validation and do not read tenant quotas (for example, internal/api/services.go hard-caps len(vars) at 100, and internal/services/services.go validation checks key/value format only). In practice, a tenant can be configured to a lower env-var quota via this PATCH and still set more vars than allowed, so the new quota field is not actually enforced.

Useful? React with 👍 / 👎.

@dennisonbertram dennisonbertram merged commit 108c7c8 into main Mar 22, 2026
1 check failed
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.

feat: add operator endpoint to update tenant quotas

1 participant