CLUSTER SLOTS may report inaccessible IP addresses
Problem: Starting aredis against a cluster which is accessible using an external IP address, but uses internal IP addresses results in the first attempt to execute a command hanging.
This is unexpected as e.g. redis-cli or the non-async Python redis library succeed in this case.
Problem is in nodemanager.py::initialize
E.g. with '98.108.0.203' being the external ip address of a node in the cluster:
(Pdb) self.orig_startup_nodes |
[{'host': '98.108.0.203', 'port': 6379}]
(Pdb) cluster_slots
{(0, 5460): [{'host': '172.17.0.71', 'port': 6379, 'node_id': 'cdf6d9a121...', 'server_type': 'master'}, {'host': '172.17.0.110', 'port': 6380, 'node_id': '500e5459..', 'server_type': 'slave'}], (10923, 16383): [{'host': '172.17.0.110', 'port': 6379, 'node_id': '06e0c49ee..', 'server_type': 'master'}, {'host': '172.17.0.72', 'port': 6380, 'node_id': '7296007..', 'server_type': 'slave'}], (5461, 10922): [{'host': '172.17.0.72', 'port': 6379, 'node_id': '6fcb292f..', 'server_type': 'master'}, {'host': '172.17.0.71', 'port': 6380, 'node_id': 'f510758273..', 'server_type': 'slave'}]}
In this case, the execution hangs on await node_require_full_coverage(node) as it's attempting to make a connection to an IP address that doesn't exist (from the client point of view).
I'm not sure what the solution would be here, maybe to raise an exception if orig_startup_nodes are not present in the cluster_slots?
(In earlier debugging I also couldn't find a timeout parameter that I could supply in order to produce a stack trace to figure out where the hanging was happening)
If there was a possibility of a remapping config, there's a few other instances of calls to cluster_nodes that would have to get the same treatment, e.g. https://github.com/NoneGG/aredis/blob/master/aredis/commands/iter.py#L84