Skip to content

Commit 3b64844

Browse files
authored
kafka.net: Raise UnknownBrokerIdError when connection fails because node_id is not in metadata (#2876)
1 parent 0a8f664 commit 3b64844

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

kafka/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class NodeNotReadyError(KafkaError):
7979
retriable = True
8080

8181

82+
class UnknownBrokerIdError(KafkaError):
83+
pass
84+
85+
8286
class QuotaViolationError(KafkaError):
8387
pass
8488

kafka/net/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ async def _connect(self, node, conn):
210210

211211
def get_connection(self, node_id, pop_on_close=True, refresh_metadata_on_err=True):
212212
if node_id is None:
213-
raise Errors.NodeNotReadyError()
213+
raise Errors.NodeNotReadyError('No node_id provided')
214214
elif self.connection_delay(node_id) > 0:
215215
raise Errors.NodeNotReadyError(node_id)
216216
elif node_id in self._conns:
217217
return self._conns[node_id]
218218
node = self.cluster.broker_metadata(node_id)
219219
if node is None:
220-
raise Errors.NodeNotReadyError(node_id)
220+
raise Errors.UnknownBrokerIdError(node_id)
221221
conn = KafkaConnection(self._net, node_id=node_id, broker_version_data=self.broker_version_data, **self.config)
222222
if pop_on_close:
223223
conn.close_future.add_both(lambda _: self._conns.pop(node.node_id, None))

0 commit comments

Comments
 (0)