Skip to content

Commit adbfd5b

Browse files
[v3-0-test] Remove unnecessary logs while retrieving connections / variables (#51786) (#51826)
(cherry picked from commit 23ecee8) Co-authored-by: Amogh Desai <[email protected]>
1 parent c32210a commit adbfd5b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

task-sdk/src/airflow/sdk/execution_time/context.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def _get_connection(conn_id: str) -> Connection:
125125
# enabled only if SecretCache.init() has been called first
126126

127127
# iterate over configured backends if not in cache (or expired)
128-
for secrets_backend in ensure_secrets_backend_loaded():
128+
backends = ensure_secrets_backend_loaded()
129+
for secrets_backend in backends:
129130
try:
130131
conn = secrets_backend.get_connection(conn_id=conn_id)
131132
if conn:
@@ -137,10 +138,11 @@ def _get_connection(conn_id: str) -> Connection:
137138
type(secrets_backend).__name__,
138139
)
139140

140-
log.debug(
141-
"Connection not found in any of the configured Secrets Backends. Trying to retrieve from API server",
142-
conn_id=conn_id,
143-
)
141+
if backends:
142+
log.debug(
143+
"Connection not found in any of the configured Secrets Backends. Trying to retrieve from API server",
144+
conn_id=conn_id,
145+
)
144146

145147
# TODO: This should probably be moved to a separate module like `airflow.sdk.execution_time.comms`
146148
# or `airflow.sdk.execution_time.connection`
@@ -166,8 +168,9 @@ def _get_variable(key: str, deserialize_json: bool) -> Any:
166168
from airflow.sdk.execution_time.supervisor import ensure_secrets_backend_loaded
167169

168170
var_val = None
171+
backends = ensure_secrets_backend_loaded()
169172
# iterate over backends if not in cache (or expired)
170-
for secrets_backend in ensure_secrets_backend_loaded():
173+
for secrets_backend in backends:
171174
try:
172175
var_val = secrets_backend.get_variable(key=key) # type: ignore[assignment]
173176
if var_val is not None:
@@ -184,10 +187,11 @@ def _get_variable(key: str, deserialize_json: bool) -> Any:
184187
type(secrets_backend).__name__,
185188
)
186189

187-
log.debug(
188-
"Variable not found in any of the configured Secrets Backends. Trying to retrieve from API server",
189-
key=key,
190-
)
190+
if backends:
191+
log.debug(
192+
"Variable not found in any of the configured Secrets Backends. Trying to retrieve from API server",
193+
key=key,
194+
)
191195

192196
# TODO: This should probably be moved to a separate module like `airflow.sdk.execution_time.comms`
193197
# or `airflow.sdk.execution_time.variable`

0 commit comments

Comments
 (0)