You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2025/06/30 10:51:42 UTC

(airflow) branch v3-0-test updated: [v3-0-test] Remove unnecessary logs while retrieving connections / variables (#51786) (#51826)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new adbfd5b0262 [v3-0-test] Remove unnecessary logs while retrieving connections / variables (#51786) (#51826)
adbfd5b0262 is described below

commit adbfd5b026218c8b4046dc7fc76f835052e271b2
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Mon Jun 30 16:21:26 2025 +0530

    [v3-0-test] Remove unnecessary logs while retrieving connections / variables (#51786) (#51826)
    
    (cherry picked from commit 23ecee8c08dc1bc5e5e12151ccd3eb39632d739d)
    
    Co-authored-by: Amogh Desai <am...@gmail.com>
---
 task-sdk/src/airflow/sdk/execution_time/context.py | 24 +++++++++++++---------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/task-sdk/src/airflow/sdk/execution_time/context.py b/task-sdk/src/airflow/sdk/execution_time/context.py
index 40890d05cc2..744b3b08886 100644
--- a/task-sdk/src/airflow/sdk/execution_time/context.py
+++ b/task-sdk/src/airflow/sdk/execution_time/context.py
@@ -125,7 +125,8 @@ def _get_connection(conn_id: str) -> Connection:
     # enabled only if SecretCache.init() has been called first
 
     # iterate over configured backends if not in cache (or expired)
-    for secrets_backend in ensure_secrets_backend_loaded():
+    backends = ensure_secrets_backend_loaded()
+    for secrets_backend in backends:
         try:
             conn = secrets_backend.get_connection(conn_id=conn_id)
             if conn:
@@ -137,10 +138,11 @@ def _get_connection(conn_id: str) -> Connection:
                 type(secrets_backend).__name__,
             )
 
-    log.debug(
-        "Connection not found in any of the configured Secrets Backends. Trying to retrieve from API server",
-        conn_id=conn_id,
-    )
+    if backends:
+        log.debug(
+            "Connection not found in any of the configured Secrets Backends. Trying to retrieve from API server",
+            conn_id=conn_id,
+        )
 
     # TODO: This should probably be moved to a separate module like `airflow.sdk.execution_time.comms`
     #   or `airflow.sdk.execution_time.connection`
@@ -166,8 +168,9 @@ def _get_variable(key: str, deserialize_json: bool) -> Any:
     from airflow.sdk.execution_time.supervisor import ensure_secrets_backend_loaded
 
     var_val = None
+    backends = ensure_secrets_backend_loaded()
     # iterate over backends if not in cache (or expired)
-    for secrets_backend in ensure_secrets_backend_loaded():
+    for secrets_backend in backends:
         try:
             var_val = secrets_backend.get_variable(key=key)  # type: ignore[assignment]
             if var_val is not None:
@@ -184,10 +187,11 @@ def _get_variable(key: str, deserialize_json: bool) -> Any:
                 type(secrets_backend).__name__,
             )
 
-    log.debug(
-        "Variable not found in any of the configured Secrets Backends. Trying to retrieve from API server",
-        key=key,
-    )
+    if backends:
+        log.debug(
+            "Variable not found in any of the configured Secrets Backends. Trying to retrieve from API server",
+            key=key,
+        )
 
     # TODO: This should probably be moved to a separate module like `airflow.sdk.execution_time.comms`
     #   or `airflow.sdk.execution_time.variable`