Ensure that address familly proto is given with IPv6 address on the memcache_pool backend
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oslo.cache |
New
|
Undecided
|
Herve Beraud |
Bug Description
Hello,
Description
===========
To setup a memcached based backend we need to pass the `memcache_servers` parameter to oslo.config [1].
This parameter can be consumed by the following backends:
- dogpile.
- oslo_cache.
The memcache_pool backend is based on python-memcached, this one is waiting for the `servers` [2] as a list of servers addresses at format <url|ip>:<port>.
The `memcache_servers` parameter [1] in oslo.cache's config will be passed to the memcache_pool backend as the `urls` argument.
This param (url) will be passed to the python-memcached library to create a client as a positional argument [3] which correspond to the `servers` param [2].
However python-memcached to create the client socket with given servers expect to get the address familly (the `proto`) given in the passed urls (the servers param) [5].
It could be an issue if an url at IPv6 format is given without the `proto` specified inside her [4], then the socket will be initialized with a wrong address familly and the connection with the server will be not established. In this case the socket will be intialized with an IPv6 format and an `AF_INET` [7] address familly, which correspond to an IPv4 familly address where normally it should use an `AF_INET6` [6][8] which is designed for IPv6 addresses.
python-memcached wait for this proto in the given servers to initialize the socket with the right address familly [6][7].
Working examples:
-----------------
memcache_
memcache_
*Not* working examples:
-------
memcache_
memcache_
memcache_
To summarize, the python-memcached library waiting for of proto inet6 to intialize the socket with the `AF_INET6` constant for the address familly.
If the `proto` is not passed then the socket will be intialized with the `AF_INET` constant [6] for the address familly.
Real examples
=============
Without the proto given
-------
memcache_
```
[root@controller-1 keystone]# netstat -natp |grep 11211 |grep keys
[root@controller-1 keystone]#
```
With the proto given
-------
memcache_
```
[root@controller-1 keystone]# netstat -natp |grep 11211 |grep key
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
tcp6 0 0 fd00:fd00:
```
Workaround
==========
As you can observe above this is not an issue if the `proto` is given in the memcache_servers:
```
memcache_
```
So if you faced similar issue you could easily fix that by simply put the proto in your urls.
Solutions & improvements
=======
Warning: the solution need to take care to be only focused on the `memcache_pool` backend to avoid side effects on the `dogpile.cache` backend which is based on pylibmc and bmemcached and which surely handle given urls in a different way.
First, it could be worth to put some examples in the oslo.cache's doc with details on how to pass proper `memcache_servers` for the `memcache_pool` backend and to speak about address familly and proto.
Second, also it could be worth on the oslo.cache side to test some IPv6 regexes on the given urls to looking for the proto and to be aware if it isn't given. Some sort of regexes which will surround the case where an IPv6 is given without the proto part and to improve the python-memcached regexes [1]. We can easily force the proto if it's was not given by users when we detect IPv6 addresses format.
It could avoid the previous example where connection between the client and the memcache server is not established.
Third, some new regexes could be added to python-memcached too to take care of this case and directly handle these case at the root position.
Also I think a couple of unit tests and functional tests could help us to surround this kind of issue.
Thoughts?
[1] https:/
[2] https:/
[3] https:/
[4] https:/
[5] https:/
[6] https:/
[7] https:/
[8] https:/
Changed in oslo.cache: | |
assignee: | nobody → Herve Beraud (herveberaud) |