Could you please help on the following issue
facing an issue with conn_id isn’t defined error with Airflow 2.7.2 version. but this connection is already present in the connection list.
This issue is happening intermittently, and this error resulted into DAG import error on the airflow UI Screen.
enter image description here
Exception logs
<code> File "/opt/airflow/plugins/domainp/utils/utilities.py", line 112, in on_retry_callback
retry_duration_limit = float(get_config_macro(task_ins, "retry_tasks_failed_within_seconds"))
File "/opt/airflow/plugins/domainp/utils/config.py", line 204, in get_config_macro
config = get_configs_macro(
File "/opt/airflow/plugins/domainp/utils/config.py", line 245, in get_configs_macro
filter_entries(get_pgcc_config(dataset_pcd_rendered, prefix), prefix)
File "/opt/airflow/plugins/domainp/utils/config.py", line 276, in get_pgcc_config
grpc_hook = GrpcServiceHook("shared_service_conn")
File "/opt/airflow/plugins/domainp/service/hooks/service.py", line 20, in __init__
self.conn = self.get_connection(self.conn_id)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/hooks/base.py", line 72, in get_connection
conn = Connection.get_connection_from_secrets(conn_id)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/models/connection.py", line 477, in get_connection_from_secrets
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.exceptions.AirflowNotFoundException: The conn_id `shared_service_conn` isn't defined
the Connection fetch code:
class GrpcServiceHook(BaseHook):
"""Grpc service hook"""
</code>
<code> File "/opt/airflow/plugins/domainp/utils/utilities.py", line 112, in on_retry_callback
retry_duration_limit = float(get_config_macro(task_ins, "retry_tasks_failed_within_seconds"))
File "/opt/airflow/plugins/domainp/utils/config.py", line 204, in get_config_macro
config = get_configs_macro(
File "/opt/airflow/plugins/domainp/utils/config.py", line 245, in get_configs_macro
filter_entries(get_pgcc_config(dataset_pcd_rendered, prefix), prefix)
File "/opt/airflow/plugins/domainp/utils/config.py", line 276, in get_pgcc_config
grpc_hook = GrpcServiceHook("shared_service_conn")
File "/opt/airflow/plugins/domainp/service/hooks/service.py", line 20, in __init__
self.conn = self.get_connection(self.conn_id)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/hooks/base.py", line 72, in get_connection
conn = Connection.get_connection_from_secrets(conn_id)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/models/connection.py", line 477, in get_connection_from_secrets
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.exceptions.AirflowNotFoundException: The conn_id `shared_service_conn` isn't defined
the Connection fetch code:
class GrpcServiceHook(BaseHook):
"""Grpc service hook"""
</code>
File "/opt/airflow/plugins/domainp/utils/utilities.py", line 112, in on_retry_callback
retry_duration_limit = float(get_config_macro(task_ins, "retry_tasks_failed_within_seconds"))
File "/opt/airflow/plugins/domainp/utils/config.py", line 204, in get_config_macro
config = get_configs_macro(
File "/opt/airflow/plugins/domainp/utils/config.py", line 245, in get_configs_macro
filter_entries(get_pgcc_config(dataset_pcd_rendered, prefix), prefix)
File "/opt/airflow/plugins/domainp/utils/config.py", line 276, in get_pgcc_config
grpc_hook = GrpcServiceHook("shared_service_conn")
File "/opt/airflow/plugins/domainp/service/hooks/service.py", line 20, in __init__
self.conn = self.get_connection(self.conn_id)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/hooks/base.py", line 72, in get_connection
conn = Connection.get_connection_from_secrets(conn_id)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/models/connection.py", line 477, in get_connection_from_secrets
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.exceptions.AirflowNotFoundException: The conn_id `shared_service_conn` isn't defined
the Connection fetch code:
class GrpcServiceHook(BaseHook):
"""Grpc service hook"""
Connection retrieve code
<code>def __init__(self, conn_id) -> None:
super().__init__()
self.conn_id = conn_id
self.conn = self.get_connection(self.conn_id)
</code>
<code>def __init__(self, conn_id) -> None:
super().__init__()
self.conn_id = conn_id
self.conn = self.get_connection(self.conn_id)
</code>
def __init__(self, conn_id) -> None:
super().__init__()
self.conn_id = conn_id
self.conn = self.get_connection(self.conn_id)
Please provide suggestions
New contributor
Anil Reddaboina is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.