Distinguish a bad --redis-password from any other Redis error (#11893)

This commit is contained in:
dHannasch
2020-11-13 16:39:44 -07:00
committed by GitHub
parent 4f5d6274af
commit 9fbeefd604
2 changed files with 28 additions and 0 deletions
+11
View File
@@ -608,6 +608,17 @@ def wait_for_redis_to_start(redis_ip_address, redis_port, password=None):
"Waiting for redis server at {}:{} to respond...".format(
redis_ip_address, redis_port))
redis_client.client_list()
# If the Redis service is delayed getting set up for any reason, we may
# get a redis.ConnectionError: Error 111 connecting to host:port.
# Connection refused.
# Unfortunately, redis.ConnectionError is also the base class of
# redis.AuthenticationError. We *don't* want to obscure a
# redis.AuthenticationError, because that indicates the user provided a
# bad password. Thus a double except clause to ensure a
# redis.AuthenticationError isn't trapped here.
except redis.AuthenticationError as authEx:
raise RuntimeError("Unable to connect to Redis at {}:{}.".format(
redis_ip_address, redis_port)) from authEx
except redis.ConnectionError:
# Wait a little bit.
time.sleep(delay)