mirror of
https://github.com/minio/minio.git
synced 2025-05-21 17:43:48 -04:00
cache: fix commit value lookup in config (#13551)
This commit is contained in:
parent
3dfcca68e6
commit
7c33a33ef3
11
internal/config/cache/config.go
vendored
11
internal/config/cache/config.go
vendored
@ -27,6 +27,13 @@ import (
|
|||||||
"github.com/minio/pkg/ellipses"
|
"github.com/minio/pkg/ellipses"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// WriteBack allows staging and write back of cached content for single object uploads
|
||||||
|
WriteBack = "writeback"
|
||||||
|
// WriteThrough allows caching multipart uploads to disk synchronously
|
||||||
|
WriteThrough = "writethrough"
|
||||||
|
)
|
||||||
|
|
||||||
// Config represents cache config settings
|
// Config represents cache config settings
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Enabled bool `json:"-"`
|
Enabled bool `json:"-"`
|
||||||
@ -39,7 +46,7 @@ type Config struct {
|
|||||||
WatermarkLow int `json:"watermark_low"`
|
WatermarkLow int `json:"watermark_low"`
|
||||||
WatermarkHigh int `json:"watermark_high"`
|
WatermarkHigh int `json:"watermark_high"`
|
||||||
Range bool `json:"range"`
|
Range bool `json:"range"`
|
||||||
CacheCommitMode string `json:"commit_mode"`
|
CacheCommitMode string `json:"commit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON - implements JSON unmarshal interface for unmarshalling
|
// UnmarshalJSON - implements JSON unmarshal interface for unmarshalling
|
||||||
@ -157,7 +164,7 @@ func parseCacheExcludes(excludes string) ([]string, error) {
|
|||||||
|
|
||||||
func parseCacheCommitMode(commitStr string) (string, error) {
|
func parseCacheCommitMode(commitStr string) (string, error) {
|
||||||
switch strings.ToLower(commitStr) {
|
switch strings.ToLower(commitStr) {
|
||||||
case "writeback", "writethrough":
|
case WriteBack, WriteThrough:
|
||||||
return strings.ToLower(commitStr), nil
|
return strings.ToLower(commitStr), nil
|
||||||
default:
|
default:
|
||||||
return "", config.ErrInvalidCacheCommitValue(nil).Msg("cache commit value must be `writeback` or `writethrough`")
|
return "", config.ErrInvalidCacheCommitValue(nil).Msg("cache commit value must be `writeback` or `writethrough`")
|
||||||
|
4
internal/config/cache/lookup.go
vendored
4
internal/config/cache/lookup.go
vendored
@ -56,7 +56,7 @@ const (
|
|||||||
DefaultAfter = "0"
|
DefaultAfter = "0"
|
||||||
DefaultWaterMarkLow = "70"
|
DefaultWaterMarkLow = "70"
|
||||||
DefaultWaterMarkHigh = "80"
|
DefaultWaterMarkHigh = "80"
|
||||||
DefaultCacheCommit = "writethrough"
|
DefaultCacheCommit = WriteThrough
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultKVS - default KV settings for caching.
|
// DefaultKVS - default KV settings for caching.
|
||||||
@ -223,7 +223,7 @@ func LookupConfig(kvs config.KVS) (Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, err
|
return cfg, err
|
||||||
}
|
}
|
||||||
if cfg.After > 0 && cfg.CacheCommitMode != "" {
|
if cfg.After > 0 && cfg.CacheCommitMode != WriteThrough {
|
||||||
err := errors.New("cache after cannot be used with commit writeback")
|
err := errors.New("cache after cannot be used with commit writeback")
|
||||||
return cfg, config.ErrInvalidCacheSetting(err)
|
return cfg, config.ErrInvalidCacheSetting(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user