mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
feat(api): add repository quota enforcement middleware (#3923)
Adds a configurable maximum repository count per registry instance. When maxRepos is set on StorageConfig, manifest pushes that would create a new repository beyond the limit are rejected with HTTP 429 TOOMANYREQUESTS. Pushes to existing repositories are always allowed. Implemented as an always-available feature in pkg/api (not a build-tag extension). MaxRepos is a field on StorageConfig, enabled when > 0. - repoQuotaMiddleware on the dist-spec router intercepts manifest PUTs. New-repo pushes are serialized with a sync.Mutex to prevent concurrent requests from exceeding the limit. - Adds CountRepos(ctx) to the MetaDB interface with efficient implementations: BoltDB (Stats().KeyN), Redis (HLen), DynamoDB (Scan with Select=COUNT). - Config.IsQuotaEnabled() added, wired into controller.go metaDB init. - Four integration tests (enforcement, concurrency, disabled, unconfigured) and backend-specific CountRepos tests for BoltDB, Redis, and DynamoDB. Signed-off-by: Bachir Khiati <bachir.khiati@gmail.com>
This commit is contained in:
@@ -91,6 +91,16 @@ Orphan blobs are removed if they are older than gcDelay.
|
||||
"gcDelay": "2h"
|
||||
```
|
||||
|
||||
To limit the maximum number of repositories that can be created, set:
|
||||
|
||||
```
|
||||
"maxRepos": 10
|
||||
```
|
||||
|
||||
When the limit is reached, pushes that would create a new repository are
|
||||
rejected with HTTP 429. Pushes to existing repositories are always allowed.
|
||||
Setting maxRepos to 0 or omitting it disables enforcement.
|
||||
|
||||
It is also possible to store and serve images from multiple filesystems with
|
||||
their own repository paths, dedupe and garbage collection settings with:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user