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

Improving errors logging in async offsets fetcher #304

Merged
merged 4 commits into from
Jan 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions frontera/contrib/messagebus/kafka/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def offsets(self, partitions, timestamp):
refresh_future = self._client.cluster.request_update()
self._client.poll(future=refresh_future, sleep=True)
ok = False
log.warning("Got exception %s and kept the loop.", future.exception)
break
if ok:
return offsets
Expand All @@ -201,16 +202,17 @@ def _send_offset_request(self, partitions, timestamp):
if node_id is None:
log.debug("Partition %s is unknown for fetching offset,"
" wait for metadata refresh", partition)
return Future().failure(Errors.StaleMetadata(partition))
return [Future().failure(Errors.StaleMetadata(partition))]
elif node_id == -1:
log.debug("Leader for partition %s unavailable for fetching offset,"
" wait for metadata refresh", partition)
return Future().failure(Errors.LeaderNotAvailableError(partition))
return [Future().failure(Errors.LeaderNotAvailableError(partition))]
nodes_per_partitions.setdefault(node_id, []).append(partition)

# Client returns a future that only fails on network issues
# so create a separate future and attach a callback to update it
# based on response error codes

futures = []
for node_id, partitions in six.iteritems(nodes_per_partitions):
request = OffsetRequest[0](
Expand All @@ -219,7 +221,10 @@ def _send_offset_request(self, partitions, timestamp):
future_request = Future()
_f = self._client.send(node_id, request)
_f.add_callback(self._handle_offset_response, partitions, future_request)
_f.add_errback(lambda e: future_request.failure(e))
def errback(e):
log.error("Offset request errback error %s", e)
future_request.failure(e)
_f.add_errback(errback)
futures.append(future_request)
return futures

Expand Down