mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
set max versions to be IntMax to avoid premature failures (#19360)
let users/customers set relevant values make default value to be non-applicable.
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -155,7 +156,7 @@ var (
|
||||
},
|
||||
config.KV{
|
||||
Key: apiObjectMaxVersions,
|
||||
Value: "10000",
|
||||
Value: "9223372036854775807",
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -178,7 +179,7 @@ type Config struct {
|
||||
GzipObjects bool `json:"gzip_objects"`
|
||||
RootAccess bool `json:"root_access"`
|
||||
SyncEvents bool `json:"sync_events"`
|
||||
ObjectMaxVersions int `json:"object_max_versions"`
|
||||
ObjectMaxVersions int64 `json:"object_max_versions"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON - Validate SS and RRS parity when unmarshalling JSON.
|
||||
@@ -317,16 +318,20 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
|
||||
|
||||
maxVerStr := env.Get(EnvAPIObjectMaxVersions, "")
|
||||
if maxVerStr == "" {
|
||||
maxVerStr = env.Get(EnvAPIObjectMaxVersionsLegacy, kvs.GetWithDefault(apiObjectMaxVersions, DefaultKVS))
|
||||
maxVerStr = env.Get(EnvAPIObjectMaxVersionsLegacy, kvs.Get(apiObjectMaxVersions))
|
||||
}
|
||||
maxVersions, err := strconv.Atoi(maxVerStr)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
if maxVerStr != "" {
|
||||
maxVersions, err := strconv.ParseInt(maxVerStr, 10, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
if maxVersions <= 0 {
|
||||
return cfg, fmt.Errorf("invalid object max versions value: %v", maxVersions)
|
||||
}
|
||||
cfg.ObjectMaxVersions = maxVersions
|
||||
} else {
|
||||
cfg.ObjectMaxVersions = math.MaxInt64
|
||||
}
|
||||
if maxVersions <= 0 {
|
||||
return cfg, fmt.Errorf("invalid object max versions value: %v", maxVersions)
|
||||
}
|
||||
cfg.ObjectMaxVersions = maxVersions
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user