From 2f564437ae45383eb486dff00b31832042230b82 Mon Sep 17 00:00:00 2001 From: Poorna Krishnamoorthy Date: Mon, 30 Nov 2020 20:53:27 -0800 Subject: [PATCH] Disallow writeback caching with cache_after (#11002) fixes #10974 --- cmd/config/cache/lookup.go | 4 ++++ cmd/config/errors.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/cmd/config/cache/lookup.go b/cmd/config/cache/lookup.go index 6e8ea6f2e..297bc90a4 100644 --- a/cmd/config/cache/lookup.go +++ b/cmd/config/cache/lookup.go @@ -222,6 +222,10 @@ func LookupConfig(kvs config.KVS) (Config, error) { if err != nil { return cfg, err } + if cfg.After > 0 && cfg.CommitWriteback { + err := errors.New("cache after cannot be used with commit writeback") + return cfg, config.ErrInvalidCacheSetting(err) + } } return cfg, nil diff --git a/cmd/config/errors.go b/cmd/config/errors.go index e6483cc4b..01bcf0b1a 100644 --- a/cmd/config/errors.go +++ b/cmd/config/errors.go @@ -108,6 +108,11 @@ var ( "MINIO_CACHE_COMMIT: Valid expected value is `writeback` or `writethrough`", ) + ErrInvalidCacheSetting = newErrFn( + "Incompatible cache setting", + "Please check the passed value", + "MINIO_CACHE_AFTER cannot be used with MINIO_CACHE_COMMIT setting", + ) ErrInvalidRotatingCredentialsBackendEncrypted = newErrFn( "Invalid rotating credentials", "Please set correct rotating credentials in the environment for decryption",