Skip to content

Re-enable logging during broker version check #1430

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

Merged
merged 1 commit into from
Mar 9, 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
13 changes: 1 addition & 12 deletions kafka/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ def check_version(self, timeout=2, strict=False):

Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...
"""
log.info('Probing node %s broker version', self.node_id)
# Monkeypatch some connection configurations to avoid timeouts
override_config = {
'request_timeout_ms': timeout * 1000,
Expand All @@ -877,17 +878,6 @@ def check_version(self, timeout=2, strict=False):
from kafka.protocol.admin import ApiVersionRequest, ListGroupsRequest
from kafka.protocol.commit import OffsetFetchRequest, GroupCoordinatorRequest

# Socket errors are logged as exceptions and can alarm users. Mute them
from logging import Filter

class ConnFilter(Filter):
def filter(self, record):
if record.funcName == 'check_version':
return True
return False
log_filter = ConnFilter()
log.addFilter(log_filter)

test_cases = [
# All cases starting from 0.10 will be based on ApiVersionResponse
((0, 10), ApiVersionRequest[0]()),
Expand Down Expand Up @@ -967,7 +957,6 @@ def connect():
else:
raise Errors.UnrecognizedBrokerVersion()

log.removeFilter(log_filter)
for key in stashed:
self.config[key] = stashed[key]
return version
Expand Down