redis / redis-rb

A Ruby client library for Redis
MIT License
3.98k stars 1.03k forks source link

ERR Client sent AUTH, but no password is set #855

Closed alexesDev closed 5 years ago

alexesDev commented 5 years ago

I tried to use https://cloud.yandex.com/docs/managed-redis/ and got ERR Client sent AUTH, but no password is set becouse sentinel get-master-addr-by-name must be call without password.

Is this a bug?

Monkey patch: https://gist.github.com/alexesDev/5b0fe8006775cb27a877b5a3766465c9

supercaracal commented 5 years ago

Could you inform me of your environment?

  1. Are you using the client version 4.1.1?
  2. What the managed Redis server's version is?
  3. Are you specifying the password option in the client?
  4. Are you configuring the requirepass and masterauth options in the servers?
  5. Are you configuring the sentinel auth-pass option in the sentinel nodes?
alexesDev commented 5 years ago
  1. Are you using the client version 4.1.1? Yes

    bundle list | grep redis 
    * redis (4.1.1)
  2. What the managed Redis server's version is? redis_version:5.0.4

  3. Are you specifying the password option in the client? Yes

    Sidekiq.configure_server do |config|
    config.redis = {
    url: 'redis://my-instance-name',
    password: 'my-password',
    sentinels: [{ host: ..., port: ... }],
    }
    end

    4 and 5. I cannot see config files.

alexesDev commented 5 years ago

Сonnection instructions for other languages

#!/bin/bash
host=$(redis-cli -h ****.mdb.yandexcloud.net -p 26379 sentinel get-master-addr-by-name my-instance name | head -n 1)
redis-cli -h $host -a %(password) ping
const Redis = require('ioredis');
const redis = new Redis({
    sentinels: [
        {host: '***.mdb.yandexcloud.net', port: 26379}
    ],
    name: 'my-instance',
    password: '<password>',
    role: 'master'
});

redis.set('foo', 'bar');

Managed Service for Redis guarantees operation only with certain DBMS clients, but you are free to use other clients without restrictions.

The following clients are supported:

supercaracal commented 5 years ago
No Sentinel Auth Master or Slave Auth redis-rb
1 enabled enabled The client works fine only if both passwords are same.
2 enabled disabled There might be no use case.
3 disabled enabled There is a bug.
4 disabled disabled The client works fine.

I guess your env might be No.3.

I think it might be better to separate the password option into 2 types like as follows. (feature request)

sentinels = [{ host: '127.0.0.1', port: 6400, password: 'foo' },
             { host: '127.0.0.1', port: 6401, password: 'foo' }]

redis = Redis.new(host: 'mymaster', sentinels: sentinels, role: :master, password: 'bar')

or

sentinels = [{ host: '127.0.0.1', port: 6400 },
             { host: '127.0.0.1', port: 6401 }]

redis = Redis.new(host: 'mymaster', sentinels: sentinels, role: :master, sentinel_password: 'foo', password: 'bar')

But we are able to take workaround with error handling like your gist.

https://github.com/redis/redis-rb/blob/e0dfbeff297202f5bdfbb80a1dd0a9f1848d957e/lib/redis/client.rb#L575-L603