From 0c404403a4c7d4840d8a36845452abbf390cfd27 Mon Sep 17 00:00:00 2001 From: Ken Haines Date: Mon, 16 Dec 2019 21:24:37 -0800 Subject: [PATCH 1/3] adding TLS and password options to RedisCache config Signed-off-by: Ken Haines --- pkg/chunk/cache/redis_cache.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/chunk/cache/redis_cache.go b/pkg/chunk/cache/redis_cache.go index 43e14dba3fc..57756c015cd 100644 --- a/pkg/chunk/cache/redis_cache.go +++ b/pkg/chunk/cache/redis_cache.go @@ -25,6 +25,8 @@ type RedisConfig struct { Expiration time.Duration `yaml:"expiration,omitempty"` MaxIdleConns int `yaml:"max_idle_conns,omitempty"` MaxActiveConns int `yaml:"max_active_conns,omitempty"` + Password string `yaml:"password"` + EnableTLS bool `yaml:"enable_tls"` } // RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet @@ -34,6 +36,8 @@ func (cfg *RedisConfig) RegisterFlagsWithPrefix(prefix, description string, f *f f.DurationVar(&cfg.Expiration, prefix+"redis.expiration", 0, description+"How long keys stay in the redis.") f.IntVar(&cfg.MaxIdleConns, prefix+"redis.max-idle-conns", 80, description+"Maximum number of idle connections in pool.") f.IntVar(&cfg.MaxActiveConns, prefix+"redis.max-active-conns", 0, description+"Maximum number of active connections in pool.") + f.StringVar(&cfg.Password, prefix+"redis.password", "", "password to use when connecting to redis.") + f.BoolVar(&cfg.EnableTLS, prefix+"redis.enable-tls", false, "enables connecting to redis with TLS.") } // NewRedisCache creates a new RedisCache @@ -44,7 +48,15 @@ func NewRedisCache(cfg RedisConfig, name string, pool *redis.Pool) *RedisCache { MaxIdle: cfg.MaxIdleConns, MaxActive: cfg.MaxActiveConns, Dial: func() (redis.Conn, error) { - c, err := redis.Dial("tcp", cfg.Endpoint) + options := make([]redis.DialOption, 0, 2) + if cfg.EnableTLS { + options = append(options, redis.DialUseTLS(true)) + } + if cfg.Password != "" { + options = append(options, redis.DialPassword(cfg.Password)) + } + + c, err := redis.Dial("tcp", cfg.Endpoint, options...) if err != nil { return nil, err } From 8629fd3df44c2472a940b16172837fb762412671 Mon Sep 17 00:00:00 2001 From: Ken Haines Date: Mon, 16 Dec 2019 22:42:57 -0800 Subject: [PATCH 2/3] Updated CHANGELOG.md Signed-off-by: Ken Haines --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b283010275d..f51a7e2104f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * [FEATURE] The distributor can now drop labels from samples (similar to the removal of the replica label for HA ingestion) per user via the `distributor.drop-label` flag. #1726 * [FEATURE] Added `global` ingestion rate limiter strategy. Deprecated `-distributor.limiter-reload-period` flag. #1766 * [FEATURE] Added support for Microsoft Azure blob storage to be used for storing chunk data. #1913 +* [ENHANCEMENT] Added `password` and `enableTLS` options to redis cache configuration. Enables usage of Microsoft Azure Cache for Redis service. * [BUGFIX] Fixed unnecessary CAS operations done by the HA tracker when the jitter is enabled. #1861 ## 0.4.0 / 2019-12-02 From 566ba5d395806971ec41c43635401a0d81b90381 Mon Sep 17 00:00:00 2001 From: Ken Haines Date: Mon, 6 Jan 2020 08:10:39 -0800 Subject: [PATCH 3/3] documentation corrections from PR feedback Signed-off-by: Ken Haines --- CHANGELOG.md | 2 +- pkg/chunk/cache/redis_cache.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f51a7e2104f..468faf89ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ * [FEATURE] The distributor can now drop labels from samples (similar to the removal of the replica label for HA ingestion) per user via the `distributor.drop-label` flag. #1726 * [FEATURE] Added `global` ingestion rate limiter strategy. Deprecated `-distributor.limiter-reload-period` flag. #1766 * [FEATURE] Added support for Microsoft Azure blob storage to be used for storing chunk data. #1913 -* [ENHANCEMENT] Added `password` and `enableTLS` options to redis cache configuration. Enables usage of Microsoft Azure Cache for Redis service. +* [ENHANCEMENT] Added `password` and `enable_tls` options to redis cache configuration. Enables usage of Microsoft Azure Cache for Redis service. * [BUGFIX] Fixed unnecessary CAS operations done by the HA tracker when the jitter is enabled. #1861 ## 0.4.0 / 2019-12-02 diff --git a/pkg/chunk/cache/redis_cache.go b/pkg/chunk/cache/redis_cache.go index 57756c015cd..c6cbc662006 100644 --- a/pkg/chunk/cache/redis_cache.go +++ b/pkg/chunk/cache/redis_cache.go @@ -36,8 +36,8 @@ func (cfg *RedisConfig) RegisterFlagsWithPrefix(prefix, description string, f *f f.DurationVar(&cfg.Expiration, prefix+"redis.expiration", 0, description+"How long keys stay in the redis.") f.IntVar(&cfg.MaxIdleConns, prefix+"redis.max-idle-conns", 80, description+"Maximum number of idle connections in pool.") f.IntVar(&cfg.MaxActiveConns, prefix+"redis.max-active-conns", 0, description+"Maximum number of active connections in pool.") - f.StringVar(&cfg.Password, prefix+"redis.password", "", "password to use when connecting to redis.") - f.BoolVar(&cfg.EnableTLS, prefix+"redis.enable-tls", false, "enables connecting to redis with TLS.") + f.StringVar(&cfg.Password, prefix+"redis.password", "", description+"Password to use when connecting to redis.") + f.BoolVar(&cfg.EnableTLS, prefix+"redis.enable-tls", false, description+"Enables connecting to redis with TLS.") } // NewRedisCache creates a new RedisCache