From 53f0cc13408b11d96140a5ba3936693e1ce77305 Mon Sep 17 00:00:00 2001 From: Michael Mayr Date: Fri, 19 Jun 2020 22:28:28 +0200 Subject: [PATCH] Implement CLIENT SETNAME for Redis connections (#9876) Add note about CLIENT SETNAME needing auth --- pkg/event/target/redis.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/event/target/redis.go b/pkg/event/target/redis.go index 26d75869d..fdb093e87 100644 --- a/pkg/event/target/redis.go +++ b/pkg/event/target/redis.go @@ -267,11 +267,17 @@ func NewRedisTarget(id string, args RedisArgs, doneCh <-chan struct{}, loggerOnc return nil, err } - if args.Password == "" { - return conn, nil + if args.Password != "" { + if _, err = conn.Do("AUTH", args.Password); err != nil { + cErr := conn.Close() + targetID := event.TargetID{ID: id, Name: "redis"} + loggerOnce(context.Background(), cErr, targetID) + return nil, err + } } - if _, err = conn.Do("AUTH", args.Password); err != nil { + // Must be done after AUTH + if _, err = conn.Do("CLIENT", "SETNAME", "MinIO"); err != nil { cErr := conn.Close() targetID := event.TargetID{ID: id, Name: "redis"} loggerOnce(context.Background(), cErr, targetID)