Skip to content

pinning the api_version in KafkaAdminClient can fail #1675

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

Closed
jeffwidman opened this issue Dec 12, 2018 · 4 comments
Closed

pinning the api_version in KafkaAdminClient can fail #1675

jeffwidman opened this issue Dec 12, 2018 · 4 comments

Comments

@jeffwidman
Copy link
Contributor

jeffwidman commented Dec 12, 2018

This is crashing when I try to pin the version in ipython, looks like a problem with the api_version stuff:

In [6]: ka = KafkaAdminClient(bootstrap_servers="kafka01.stg.local", api_version=(0,11,0))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-1a8b163b5b87> in <module>()
----> 1 ka = KafkaAdminClient(bootstrap_servers="kafka01.stg.local", api_version=(0,11,0))

/Users/jeffwidman/.virtualenvs/datadog-kp-dev/lib/python2.7/site-packages/kafka/admin/client.pyc in __init__(self, **configs)
    200
    201         self._closed = False
--> 202         self._refresh_controller_id()
    203         log.debug("KafkaAdminClient started.")
    204

/Users/jeffwidman/.virtualenvs/datadog-kp-dev/lib/python2.7/site-packages/kafka/admin/client.pyc in _refresh_controller_id(self)
    244     def _refresh_controller_id(self):
    245         """Determine the Kafka cluster controller."""
--> 246         version = self._matching_api_version(MetadataRequest)
    247         if 1 <= version <= 6:
    248             request = MetadataRequest[version]()

/Users/jeffwidman/.virtualenvs/datadog-kp-dev/lib/python2.7/site-packages/kafka/admin/client.pyc in _matching_api_version(self, operation)
    225         """
    226         version = min(len(operation) - 1,
--> 227                       self._client.get_api_versions()[operation[0].API_KEY][1])
    228         if version < self._client.get_api_versions()[operation[0].API_KEY][0]:
    229             # max library version is less than min broker version. Currently,

TypeError: 'NoneType' object has no attribute '__getitem__'

Version pinning is working fine on kafka.client_async.KafkaClient

@hatcherfang
Copy link

+1

@bmailhe
Copy link

bmailhe commented Jul 9, 2019

Hi, I have the same issue
adminclient = kafka.admin.KafkaAdminClient(bootstrap_servers = BOOTSTRAP , request_timeout_ms=2000, api_version=(0,11,0))
results in :
Traceback (most recent call last): File "~/.PyCharmCE2018.1/config/scratches/pythonKafka.py", line 22, in <module> adminclient = kafka.admin.KafkaAdminClient(bootstrap_servers = BOOTSTRAP , request_timeout_ms=2000, api_version=API_VERSIONS) File "/usr/local/lib/python3.6/site-packages/kafka/admin/client.py", line 205, in __init__ self._refresh_controller_id() File "/usr/local/lib/python3.6/site-packages/kafka/admin/client.py", line 249, in _refresh_controller_id version = self._matching_api_version(MetadataRequest) File "/usr/local/lib/python3.6/site-packages/kafka/admin/client.py", line 230, in _matching_api_version self._client.get_api_versions()[operation[0].API_KEY][1]) TypeError: 'NoneType' object is not subscriptable
It works well if I remove the api_version.
I use kafka-python 1.4.6

@ian28223
Copy link
Contributor

TypeError: 'NoneType' object is not subscriptable is fixed with 1.4.7 (98ebff8)

but would now raise IncompatibleBrokerVersion since self._client.get_api_versions() always returns None. My PR to fix that here #1953

@jeffwidman
Copy link
Contributor Author

Above PR's are merged and released as of 2.0.0, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants