sharding: better handle get_shard_ranges failures

The contract for ReplConnection.replicate() is that if we can get a
response, we return it, and if we can't (because of a timeout, or a
socket error, or some other http_client error like BadStatusLine), we
return None to indicate the error.

Previously, _fetch_and_merge_shard_ranges() always assumed the
response would have a `status` attribute and raise an AttributeError
when response was None. Now it will treat that case like other
get_shard_range failures.

Change-Id: I023b8a46c06e9a2755b5aa890a7992ef9633cba9
This commit is contained in:
Tim Burke 2019-04-25 12:57:16 -07:00
parent d147ab84e0
commit bc5f4c0611

View File

@ -138,7 +138,7 @@ class ContainerReplicator(db_replicator.Replicator):
def _fetch_and_merge_shard_ranges(self, http, broker):
with Timeout(self.node_timeout):
response = http.replicate('get_shard_ranges')
if is_success(response.status):
if response and is_success(response.status):
broker.merge_shard_ranges(json.loads(
response.data.decode('ascii')))