Skip to content

api/quota: One set of limits for every tenant, with 2 profiles - #136

Merged
l-nmch merged 1 commit into
mainfrom
feat/one-set-of-limits
Nov 11, 2026
Merged

l-nmch merged 1 commit into
mainfrom
feat/one-set-of-limits

Conversation

@l-nmch

@l-nmch l-nmch commented Nov 11, 2026

Copy link
Copy Markdown
Member

What changes

Every tenant has the same limits now that the Tenant composition of Hangar ignores spec.plan (phorge-fr/Hangar#465, merged and live). The API reads one set of limits instead of the plan of the tenant.

Instances vCPU Memory Disk Networks Profiles
2 2 4 GiB 128 GiB 2 2
  • internal/quota: PerTenant replaces the Plans table and LimitsOf. CheckInstance and CheckNetwork lose their plan argument and their messages no longer say "by its plan small" (this tenant has 2 networks out of 2 allowed: delete one first). New CheckProfile: a third profile is refused with 409, quota_exceeded and this tenant has 2 profiles out of 2 allowed (s, m and l do not count): delete one first. The check is made by the API before anything is created, since Incus has no limit for profiles.
  • The profiles are in limits and used of GET /v1/tenants/{t}/quota. Only the profiles the users made are counted: the built-in s, m and l are not in the list, are not counted and are not touched.
  • GET /v1/limits keeps profile.maxPerTenant, now the quota's 2 for every deployment.
  • The numbers are written twice, here and in the Tenant composition: TestTheLimitsAreTheOnesOfTheTenantComposition says the same numbers as the composition (including the project disk limit of 132096 MiB).
  • OpenAPI, limits-and-quotas.md, tenants.md, networks.md, images-and-instances.md, configuration.md and endpoints.md follow. The messages of Incus refusals told in problems no longer mention a plan.

Decisions

  • MAX_PROFILES_PER_TENANT is removed. It was a required setting (0 meant no limit), so a deployment had to set it. The quota's 2 replaces it: one source for the limit, the same for every tenant, and the setting could only have made the API disagree with it. The API no longer reads or requires it: a deployment that still sets it starts as before, the variable is ignored. Removing it from the deployment is a follow-up for Hangar (harmless until then).
  • The plan of a tenant is kept as it is read today, and is deprecated: it stays in the body of a tenant, in the create and patch bodies and in the quota answer, until the console stops using it (a later step of the epic). A creation without a plan works. A plan other than small on creation, and any plan on PATCH, were 403 already and still are, with a sentence that says there is no choice of plan any more. No plan changes any limit: a test shows a small and a large tenant with the same limits.

Not verified here

Run with fake stores only (go test -race ./...). The integration tests against a cluster were not run, and nothing was written to a cluster.

Closes #131

Every tenant has the same limits (2 instances, 2 vCPU, 4 GiB, 128 GiB of
disk, 2 networks) now that the Tenant composition ignores spec.plan. The API
reads one set from internal/quota instead of the plan of the tenant, checks
a third network as before, and refuses a third profile with a 409
quota_exceeded. The quota answer and GET /v1/limits carry the profiles.

MAX_PROFILES_PER_TENANT is no longer read: the limit is the quota's 2.
A deployment that still sets it starts as before.

The plan of a tenant is kept as it is read and is deprecated: it limits
nothing.
@l-nmch l-nmch added this to the 2027-Q1 milestone Nov 11, 2026
@l-nmch l-nmch added the area/api Phorge API and console label Nov 11, 2026
@l-nmch l-nmch self-assigned this Nov 11, 2026
@l-nmch
l-nmch merged commit 77f1bf0 into main Nov 11, 2026
14 checks passed
@l-nmch
l-nmch deleted the feat/one-set-of-limits branch November 11, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Phorge API and console

Projects

None yet

Development

Successfully merging this pull request may close these issues.

One plan for every tenant in the API: the limits, 2 networks, 2 profiles

1 participant