limit number of buckets to 500k (#15668)

500k is a reasonable limit for any single MinIO
cluster deployment, in future we may increase this
value.

However for now we are going to keep this limit.
This commit is contained in:
Harshavardhana 2022-09-09 03:06:34 -07:00 committed by GitHub
parent 87f0c8e7e8
commit b579163802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 228 additions and 198 deletions

View File

@ -176,6 +176,7 @@ const (
ErrBucketAlreadyOwnedByYou
ErrInvalidDuration
ErrBucketAlreadyExists
ErrTooManyBuckets
ErrMetadataTooLarge
ErrUnsupportedMetadata
ErrMaximumExpires
@ -684,6 +685,11 @@ var errorCodes = errorCodeMap{
Description: "The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.",
HTTPStatusCode: http.StatusBadRequest,
},
ErrTooManyBuckets: {
Code: "TooManyBuckets",
Description: "You have attempted to create more buckets than allowed",
HTTPStatusCode: http.StatusBadRequest,
},
ErrBucketNotEmpty: {
Code: "BucketNotEmpty",
Description: "The bucket you tried to delete is not empty",

File diff suppressed because one or more lines are too long

View File

@ -769,6 +769,14 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
return
}
// check if client is attempting to create more buckets than allowed maximum.
if currBuckets := globalBucketMetadataSys.Count(); currBuckets+1 > maxBuckets {
apiErr := errorCodes.ToAPIErr(ErrTooManyBuckets)
apiErr.Description = fmt.Sprintf("You have attempted to create %d buckets than allowed %d", currBuckets+1, maxBuckets)
writeErrorResponse(ctx, w, apiErr, r.URL)
return
}
opts := MakeBucketOptions{
Location: location,
LockEnabled: objectLockEnabled,

View File

@ -45,6 +45,14 @@ type BucketMetadataSys struct {
metadataMap map[string]BucketMetadata
}
// Count returns number of bucket metadata map entries.
func (sys *BucketMetadataSys) Count() int {
sys.RLock()
defer sys.RUnlock()
return len(sys.metadataMap)
}
// Remove bucket metadata from memory.
func (sys *BucketMetadataSys) Remove(bucket string) {
if globalIsGateway {

View File

@ -53,6 +53,9 @@ const (
// Maximum size for user-defined metadata - See: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
maxUserDataSize = 2 * 1024
// maxBuckets upto 500000 for any MinIO deployment.
maxBuckets = 500 * 1000
)
// ReservedMetadataPrefix is the prefix of a metadata key which

View File

@ -7,7 +7,6 @@ For best deployment experience MinIO recommends operating systems RHEL/CentOS 8.
| Item | Specification |
|:----------------------------------------------------------------|:--------------|
| Maximum number of servers per cluster | no-limit |
| Maximum number of federated clusters | no-limit |
| Minimum number of servers | 02 |
| Minimum number of drives per server when server count is 1 | 02 |
| Minimum number of drives per server when server count is 2 or 3 | 01 |
@ -20,9 +19,9 @@ For best deployment experience MinIO recommends operating systems RHEL/CentOS 8.
| Item | Specification |
|:--------------------------------------------------------------------------------|:----------------------------------------------|
| Maximum number of buckets | no-limit |
| Maximum number of buckets | 500000 |
| Maximum number of objects per bucket | no-limit |
| Maximum object size | 5 TiB |
| Maximum object size | 50 TiB |
| Minimum object size | 0 B |
| Maximum object size per PUT operation | 5 TiB |
| Maximum number of parts per upload | 10,000 |
@ -52,8 +51,13 @@ We found the following APIs to be redundant or less useful outside of AWS S3. If
## Object name restrictions on MinIO
- Object names that contain characters `^*|\/&";` are unsupported on Windows platform or any other file systems that do not support filenames with special charaters. **This list is non exhaustive, it depends on the operating system and filesystem under use - please consult your operating system vendor**. MinIO recommends using Linux based deployments for production workloads.
- Objects should not have conflicting objects as parent objects, applications using this behavior should change their behavior and use proper unique keys, for example situations such as following conflicting key patterns are not supported.
- Object name restrictions on MinIO are governed by OS and filesystem limitations. For example object names that contain characters `^*|\/&";` are unsupported on Windows platform or any other file systems that do not support filenames with special charaters.
> **This list is non exhaustive, it depends on the operating system and filesystem under use - please consult your operating system vendor for a more comprehensiv list**.
MinIO recommends using Linux operating system for for production workloads.
- Objects must not have conflicting objects as parent objects, applications using this behavior should change their behavior and use non-conflicting unique keys, for example situations such as following conflicting key patterns are not supported.
```
PUT <bucketname>/a/b/1.txt