This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new dd59e3e63e Remove sensitive information from Celery executor warning
(#34954)
dd59e3e63e is described below
commit dd59e3e63e0db349f40f8d1c91e7f6ef252caa4b
Author: Hussein Awala <[email protected]>
AuthorDate: Sun Oct 15 22:20:20 2023 +0200
Remove sensitive information from Celery executor warning (#34954)
---
airflow/providers/celery/executors/default_celery.py | 9 +++++----
tests/providers/celery/executors/test_celery_executor.py | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/airflow/providers/celery/executors/default_celery.py
b/airflow/providers/celery/executors/default_celery.py
index 6af4c1cd20..633d090ada 100644
--- a/airflow/providers/celery/executors/default_celery.py
+++ b/airflow/providers/celery/executors/default_celery.py
@@ -132,9 +132,10 @@ except Exception as e:
f"all necessary certs and key ({e})."
)
-if re2.search("rediss?://|amqp://|rpc://", result_backend):
+match_not_recommended_backend = re2.search("rediss?://|amqp://|rpc://",
result_backend)
+if match_not_recommended_backend:
log.warning(
- "You have configured a result_backend of %s, it is highly recommended "
- "to use an alternative result_backend (i.e. a database).",
- result_backend,
+ "You have configured a result_backend using the protocol `%s`,"
+ " it is highly recommended to use an alternative result_backend (i.e.
a database).",
+ match_not_recommended_backend.group(0).strip("://"),
)
diff --git a/tests/providers/celery/executors/test_celery_executor.py
b/tests/providers/celery/executors/test_celery_executor.py
index b9aa48b05b..236054ead3 100644
--- a/tests/providers/celery/executors/test_celery_executor.py
+++ b/tests/providers/celery/executors/test_celery_executor.py
@@ -330,3 +330,19 @@ def test_send_tasks_to_celery_hang(register_signals):
# multiprocessing.
results = executor._send_tasks_to_celery(task_tuples_to_send)
assert results == [(None, None, 1) for _ in task_tuples_to_send]
+
+
+@conf_vars({("celery", "result_backend"):
"rediss://test_user:test_password@localhost:6379/0"})
+def test_celery_executor_with_no_recommended_result_backend(caplog):
+ import importlib
+
+ from airflow.providers.celery.executors.default_celery import log
+
+ with caplog.at_level(logging.WARNING, logger=log.name):
+ # reload celery conf to apply the new config
+ importlib.reload(default_celery)
+ assert "test_password" not in caplog.text
+ assert (
+ "You have configured a result_backend using the protocol `rediss`,"
+ " it is highly recommended to use an alternative result_backend
(i.e. a database)."
+ ) in caplog.text