From c22c5871f8ef283b220dc5b5a7c93fdfde45e373 Mon Sep 17 00:00:00 2001 From: Pere Miquel Brull Date: Tue, 27 Jun 2023 12:32:08 +0200 Subject: [PATCH] Update logging messages for JWT tokens (#12169) --- ingestion/src/metadata/ingestion/api/workflow.py | 6 ++++-- .../src/metadata/ingestion/connections/test_connections.py | 5 +++-- .../openmetadata_managed_apis/workflows/ingestion/common.py | 6 ++++-- .../workflows/ingestion/data_insight.py | 5 ++--- .../workflows/ingestion/es_reindex.py | 5 ++--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ingestion/src/metadata/ingestion/api/workflow.py b/ingestion/src/metadata/ingestion/api/workflow.py index 3448b062e8b..e68f9e2ee9c 100644 --- a/ingestion/src/metadata/ingestion/api/workflow.py +++ b/ingestion/src/metadata/ingestion/api/workflow.py @@ -315,8 +315,10 @@ class Workflow(WorkflowStatusMixin): ) else: raise InvalidWorkflowJSONException( - "The serviceConnection is not informed and we cannot retrieve it from the API" - f" by searching for the service name [{service_name}]. Does this service exist in OpenMetadata?" + f"Error getting the service [{service_name}] from the API. If it exists in OpenMetadata," + " make sure the ingestion-bot JWT token is valid and that the Workflow is deployed" + " with the latest one. If this error persists, recreate the JWT token and" + " redeploy the Workflow." ) except InvalidWorkflowJSONException as exc: raise exc diff --git a/ingestion/src/metadata/ingestion/connections/test_connections.py b/ingestion/src/metadata/ingestion/connections/test_connections.py index 0f3d81996ba..738293c7e73 100644 --- a/ingestion/src/metadata/ingestion/connections/test_connections.py +++ b/ingestion/src/metadata/ingestion/connections/test_connections.py @@ -245,8 +245,9 @@ def test_connection_steps( if not test_connection_definition: raise SourceConnectionException( - f"Test connection definition for {test_connection_def_fqn} not found please review the Server Configuration" - f" of the Workflow configuration. Check that the Security Configuration has been set up correctly." + f"Test connection definition for {test_connection_def_fqn} not found! Make sure the" + " ingestion-bot JWT token is valid and that the Workflow is deployed with the latest one." + " If this error persists, recreate the JWT token and redeploy the Workflow." ) steps = [ diff --git a/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/common.py b/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/common.py index 54b84de1e3a..27a927a188f 100644 --- a/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/common.py +++ b/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/common.py @@ -83,9 +83,11 @@ class GetServiceException(Exception): def __init__(self, service_type: str, service_name: str): self.message = ( - f"Could not get service from type {service_type}. This means that the" + f"Could not get service from type [{service_type}]. This means that the" " OpenMetadata client running in the Airflow host had issues getting" - f" the service {service_name}. Validate your ingestion-bot authentication." + f" the service [{service_name}]. Make sure the ingestion-bot JWT token" + " is valid and that the Workflow is deployed with the latest one. If this error" + " persists, recreate the JWT token and redeploy the Workflow." ) super().__init__(self.message) diff --git a/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/data_insight.py b/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/data_insight.py index f51caf4bf68..8b70c1b75b5 100644 --- a/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/data_insight.py +++ b/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/data_insight.py @@ -17,6 +17,7 @@ from airflow import DAG from openmetadata_managed_apis.utils.logger import set_operator_logger from openmetadata_managed_apis.workflows.ingestion.common import ( ClientInitializationError, + GetServiceException, build_dag, ) from openmetadata_managed_apis.workflows.ingestion.elasticsearch_sink import ( @@ -83,9 +84,7 @@ def build_data_insight_workflow_config( ) if not openmetadata_service: - raise ValueError( - "Could not retrieve the OpenMetadata service! This should not happen." - ) + raise GetServiceException(service_type="metadata", service_name="OpenMetadata") sink = build_elasticsearch_sink( openmetadata_service.connection.config, ingestion_pipeline diff --git a/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/es_reindex.py b/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/es_reindex.py index f89ce954c38..9a48391ad8b 100644 --- a/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/es_reindex.py +++ b/openmetadata-airflow-apis/openmetadata_managed_apis/workflows/ingestion/es_reindex.py @@ -14,6 +14,7 @@ ElasticSearch reindex DAG function builder from airflow import DAG from openmetadata_managed_apis.workflows.ingestion.common import ( ClientInitializationError, + GetServiceException, build_dag, metadata_ingestion_workflow, ) @@ -56,9 +57,7 @@ def build_es_reindex_workflow_config( entity=MetadataService, fqn=ingestion_pipeline.service.fullyQualifiedName ) if not openmetadata_service: - raise ValueError( - "Could not retrieve the OpenMetadata service! This should not happen." - ) + raise GetServiceException(service_type="metadata", service_name="OpenMetadata") sink = Sink(type="metadata-rest", config={})