Implement CLIENT SETNAME for Redis connections (#9876)

Add note about CLIENT SETNAME needing auth
This commit is contained in:
Michael Mayr 2020-06-19 22:28:28 +02:00 committed by GitHub
parent 9626a981bc
commit 53f0cc1340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)