Final changes to config sub-system (#8600)

- Introduces changes such as certain types of
  errors that can be ignored or which need to 
  go into safe mode.
- Update help text as per the review
This commit is contained in:
Harshavardhana
2019-12-04 15:32:37 -08:00
committed by kannappanr
parent 794eb54da8
commit c9940d8c3f
65 changed files with 605 additions and 1033 deletions
+10 -10
View File
@@ -23,30 +23,30 @@ var (
Help = config.HelpKVS{
config.HelpKV{
Key: Drives,
Description: `List of mounted drives or directories delimited by ","`,
Type: "csv",
},
config.HelpKV{
Key: Exclude,
Description: `List of wildcard based cache exclusion patterns delimited by ","`,
Optional: true,
Description: `comma separated mountpoints e.g. "/optane1,/optane2"`,
Type: "csv",
},
config.HelpKV{
Key: Expiry,
Description: `Cache expiry duration in days. eg: "90"`,
Description: `cache expiry duration in days e.g. "90"`,
Optional: true,
Type: "number",
},
config.HelpKV{
Key: Quota,
Description: `Maximum permitted usage of the cache in percentage (0-100)`,
Description: `limit cache drive usage in percentage e.g. "90"`,
Optional: true,
Type: "number",
},
config.HelpKV{
Key: Exclude,
Description: `comma separated wildcard exclusion patterns e.g. "bucket/*.tmp,*.exe"`,
Optional: true,
Type: "csv",
},
config.HelpKV{
Key: config.Comment,
Description: "A comment to describe the 'cache' settings",
Description: config.DefaultComment,
Optional: true,
Type: "sentence",
},
-4
View File
@@ -34,10 +34,6 @@ func SetCacheConfig(s config.Config, cfg Config) {
return
}
s[config.CacheSubSys][config.Default] = config.KVS{
config.KV{
Key: config.State,
Value: config.StateOn,
},
config.KV{
Key: Drives,
Value: strings.Join(cfg.Drives, cacheDelimiter),
+7 -27
View File
@@ -32,7 +32,6 @@ const (
MaxUse = "maxuse"
Quota = "quota"
EnvCacheState = "MINIO_CACHE_STATE"
EnvCacheDrives = "MINIO_CACHE_DRIVES"
EnvCacheExclude = "MINIO_CACHE_EXCLUDE"
EnvCacheExpiry = "MINIO_CACHE_EXPIRY"
@@ -47,10 +46,6 @@ const (
// DefaultKVS - default KV settings for caching.
var (
DefaultKVS = config.KVS{
config.KV{
Key: config.State,
Value: config.StateOff,
},
config.KV{
Key: Drives,
Value: "",
@@ -74,6 +69,12 @@ const (
cacheDelimiter = ","
)
// Enabled returns if cache is enabled.
func Enabled(kvs config.KVS) bool {
drives := kvs.Get(Drives)
return drives != ""
}
// LookupConfig - extracts cache configuration provided by environment
// variables and merge them with provided CacheConfiguration.
func LookupConfig(kvs config.KVS) (Config, error) {
@@ -84,28 +85,7 @@ func LookupConfig(kvs config.KVS) (Config, error) {
}
drives := env.Get(EnvCacheDrives, kvs.Get(Drives))
if len(drives) > 0 {
// Drives is not-empty means user wishes to enable this explicitly, but
// check if ENV is set to false to disable caching.
stateBool, err := config.ParseBool(env.Get(EnvCacheState, config.StateOn))
if err != nil {
return cfg, err
}
if !stateBool {
return cfg, nil
}
} else {
// Check if cache is explicitly disabled
stateBool, err := config.ParseBool(env.Get(EnvCacheState, kvs.Get(config.State)))
if err != nil {
if kvs.Empty() {
return cfg, nil
}
return cfg, err
}
if stateBool {
return cfg, config.Error("'drives' key cannot be empty to enable caching")
}
if len(drives) == 0 {
return cfg, nil
}