amoghrajesh commented on code in PR #57744:
URL: https://github.com/apache/airflow/pull/57744#discussion_r2538198369
##########
task-sdk/src/airflow/sdk/definitions/dag.py:
##########
@@ -1171,23 +1172,32 @@ def test(
import re
import time
from contextlib import ExitStack
+ from unittest.mock import patch
from airflow import settings
- from airflow.configuration import secrets_backend_list
from airflow.models.dagrun import DagRun, get_or_create_dagrun
from airflow.sdk import DagRunState, timezone
- from airflow.secrets.local_filesystem import LocalFilesystemBackend
from airflow.serialization.serialized_objects import SerializedDAG
from airflow.utils.types import DagRunTriggeredByType, DagRunType
exit_stack = ExitStack()
if conn_file_path or variable_file_path:
- local_secrets = LocalFilesystemBackend(
- variables_file_path=variable_file_path,
connections_file_path=conn_file_path
+ backend_kwargs = {}
+ if conn_file_path:
+ backend_kwargs["connections_file_path"] = conn_file_path
+ if variable_file_path:
+ backend_kwargs["variables_file_path"] = variable_file_path
+
+ exit_stack.enter_context(
+ patch.dict(
+ os.environ,
+ {
+ "AIRFLOW__SECRETS__BACKEND":
"airflow.secrets.local_filesystem.LocalFilesystemBackend",
+ "AIRFLOW__SECRETS__BACKEND_KWARGS":
json.dumps(backend_kwargs),
+ },
+ )
Review Comment:
Prior to this change were patching this: `from airflow.configuration import
secrets_backend_list`, and `secrets_backend_list` was a global variable. I have
moved that inside `ensure_secrets_loaded` which doesn't allow it to be patched
now, I did it to allow global state pollution.
So to achieve similar results, we are populating the env vars instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]