From 2a18768418e496bbca46bc0d119f51b4e5304448 Mon Sep 17 00:00:00 2001 From: SumanMaharana Date: Mon, 9 Dec 2024 13:29:12 +0530 Subject: [PATCH] Minor: Fix kafkaconnect test connection --- .../source/pipeline/kafkaconnect/client.py | 29 ++++++++++--------- .../pipeline/kafkaconnect/connection.py | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/client.py b/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/client.py index e3a414b0e491..3390d500b67c 100644 --- a/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/client.py +++ b/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/client.py @@ -61,15 +61,22 @@ def get_cluster_info(self) -> Optional[dict]: """ Get the version and other details of the Kafka Connect cluster. """ - try: - result = self.client.get_cluster_info() - return result - - except Exception as exc: - logger.debug(traceback.format_exc()) - logger.error(f"Unable to get cluster info :{exc}") + result = self.client.get_cluster_info() + return result - return None + def get_connectors_list( + self, + expand: str = None, + pattern: str = None, + state: str = None, + ) -> dict: + """ + Get the list of connectors from Kafka Connect cluster. + """ + result = self.client.list_connectors( + expand=expand, pattern=pattern, state=state + ) + return result def get_connectors( self, @@ -85,12 +92,8 @@ def get_connectors( pattern (str): Only list connectors that match the regex pattern. state (str): Only list connectors that match the state. """ - try: - result = self.client.list_connectors( - expand=expand, pattern=pattern, state=state - ) - return result + return self.get_connectors_list(expand=expand, pattern=pattern, state=state) except Exception as exc: logger.debug(traceback.format_exc()) logger.error(f"Unable to get connectors list {exc}") diff --git a/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/connection.py b/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/connection.py index 38ea63920f0b..268b69bbac0f 100644 --- a/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/connection.py +++ b/ingestion/src/metadata/ingestion/source/pipeline/kafkaconnect/connection.py @@ -51,7 +51,7 @@ def test_connection( test_fn = { "GetClusterInfo": client.get_cluster_info, - "GetPipelines": client.get_connectors, + "GetPipelines": client.get_connectors_list, "GetPlugins": client.get_connector_plugins, }