mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
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:
@@ -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
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user