Skip to content

Commit

Permalink
Remove sensitive information from Celery executor warning (#34954)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-awala committed Oct 15, 2023
1 parent 94f1441 commit dd59e3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
9 changes: 5 additions & 4 deletions airflow/providers/celery/executors/default_celery.py
Expand Up @@ -132,9 +132,10 @@ def _get_celery_ssl_active() -> bool:
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("://"),
)
16 changes: 16 additions & 0 deletions tests/providers/celery/executors/test_celery_executor.py
Expand Up @@ -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

0 comments on commit dd59e3e

Please sign in to comment.