Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to initialize redis driver #966

Closed
GibeomOh opened this issue Aug 29, 2018 · 7 comments
Closed

Unable to initialize redis driver #966

GibeomOh opened this issue Aug 29, 2018 · 7 comments

Comments

@GibeomOh
Copy link

Hi, I am currently using an elasticsearch driver based on version 4.2.
I got an error while installing redis to compare performance with other drivers while upgrading to version 4.3 and upgrading the es driver.
There is no problem in version 4.2, but only in 4.3.
Please check the above problem.

Which version of Gnocchi are you using

gnocchi-4.3.2.dev1

How to reproduce your problem

After installing gnocchi 4.3 version, run gnocchi upgrade or start the process.

What is the result that you get

I received an error from gnocchi.

ERROR    gnocchi.utils: Unable to initialize storage driver

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/tenacity/__init__.py", line 279, in call
    result = fn(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/gnocchi-4.3.2.dev1-py2.7.egg/gnocchi/storage/__init__.py", line 102, in get_driver
    conf.storage)
  File "/usr/lib/python2.7/site-packages/gnocchi-4.3.2.dev1-py2.7.egg/gnocchi/storage/redis.py", line 56, in __init__
    self._client, self._scripts = redis.get_client(conf, self._SCRIPTS)
  File "/usr/lib/python2.7/site-packages/redis/client.py", line 992, in __getitem__
    raise KeyError(name)
KeyError: 0

What is result that you expected

The error should not occur in the same way as in 4.2.

@sileht
Copy link
Member

sileht commented Aug 29, 2018

Can you add more detail about your redis setup ? redis version ? redis url you use in gnocchi.conf ?

Also the version show a modified version of Gnocchi, did you check with an unmodified version 4.3.2.

@GibeomOh
Copy link
Author

GibeomOh commented Aug 29, 2018

I installed it via yum and make in CentOS 7 environment.
Redis was tested in versions 2.9 and 4.0 and the settings are:
redis_url = redis://10.xxx.xxx.xxx:26379?sentinel=mymaster&sentinel_fallback=10.xxx.xxx.xxx:26379&sentinel_fallback=10.xxx.xxx.xxx:26379

And redis setting also specified db.
ex> mymaster&db=0

Also gnocchi is used the code in the stable/4.3 branch. And the code used is pure code that only clones and does not have an elasticsearch driver.

@GibeomOh
Copy link
Author

GibeomOh commented Aug 29, 2018

If I set the redis store setting instead of using the redis centinel setting, it is no problem. Is my centinel setting wrong?

@jd
Copy link
Member

jd commented Aug 29, 2018

Likely. The erro seems to indicate it can't find the database '0' which is the default one used by the Redis client. Did you check with redis-cli?

@jd jd added the question label Aug 29, 2018
@GibeomOh
Copy link
Author

GibeomOh commented Aug 29, 2018

There are databases from 0 to 15 in redis db. If database 0 was not found and an error occurred, would not have version 4.2 or if sentinel setting.

@GibeomOh
Copy link
Author

GibeomOh commented Aug 29, 2018

Oh.. I found the cause...
When sentinel is used, get_client need to give 2 return values. but it is supposed to give only 1, which seems to be a problem.

    if 'sentinel' in kwargs:
        sentinel_hosts = [
            tuple(fallback.split(':'))
            for fallback in kwargs.get('sentinel_fallback', [])
        ]
        sentinel_hosts.insert(0, (kwargs['host'], kwargs['port']))
        sentinel_server = sentinel.Sentinel(
            sentinel_hosts,
            socket_timeout=kwargs.get('socket_timeout'))
        sentinel_name = kwargs['sentinel']
        del kwargs['sentinel']
        if 'sentinel_fallback' in kwargs:
            del kwargs['sentinel_fallback']
        client = sentinel_server.master_for(sentinel_name, **kwargs)
        # The master_client is a redis.StrictRedis using a
        # Sentinel managed connection pool.
    else:
        client = redis.StrictRedis(**kwargs)

    if scripts is not None:
        scripts = {
            name: client.register_script(code)
            for name, code in six.iteritems(scripts)
        }

    return client, scripts

@jd
Copy link
Member

jd commented Sep 6, 2018

Nice catch @GibeomOh

@jd jd added bug and removed question labels Sep 6, 2018
jd added a commit to jd/gnocchi that referenced this issue Sep 6, 2018
@mergify mergify bot closed this as completed in #972 Sep 10, 2018
mergify bot pushed a commit that referenced this issue Sep 10, 2018
mergify bot pushed a commit that referenced this issue Sep 10, 2018
Fixes #966

(cherry picked from commit c8be638)
mergify bot pushed a commit that referenced this issue Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants