Skip to content

Commit 6ed1daa

Browse files
committed
admin client: check_version only if needed, node_id kwarg for controller
1 parent 6467a53 commit 6ed1daa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kafka/admin/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,13 @@ def __init__(self, **configs):
213213
metric_group_prefix='admin',
214214
**self.config
215215
)
216-
self._client.check_version(timeout=(self.config['api_version_auto_timeout_ms'] / 1000))
217216

218217
# Get auto-discovered version from client if necessary
219218
if self.config['api_version'] is None:
220219
self.config['api_version'] = self._client.config['api_version']
220+
else:
221+
# need to run check_version for get_api_versions()
222+
self._client.check_version(timeout=(self.config['api_version_auto_timeout_ms'] / 1000))
221223

222224
self._closed = False
223225
self._refresh_controller_id()
@@ -292,7 +294,7 @@ def _refresh_controller_id(self, timeout_ms=30000):
292294
time.sleep(1)
293295
continue
294296
# verify the controller is new enough to support our requests
295-
controller_version = self._client.check_version(controller_id, timeout=(self.config['api_version_auto_timeout_ms'] / 1000))
297+
controller_version = self._client.check_version(node_id=controller_id, timeout=(self.config['api_version_auto_timeout_ms'] / 1000))
296298
if controller_version < (0, 10, 0):
297299
raise IncompatibleBrokerVersion(
298300
"The controller appears to be running Kafka {}. KafkaAdminClient requires brokers >= 0.10.0.0."

0 commit comments

Comments
 (0)