Skip to content

Move secrets_masker patch to conftest and use as fixture - #48901

Closed
gopidesupavan wants to merge 3 commits into
apache:mainfrom
gopidesupavan:use-secrets-masker-fixture
Closed

Move secrets_masker patch to conftest and use as fixture#48901
gopidesupavan wants to merge 3 commits into
apache:mainfrom
gopidesupavan:use-secrets-masker-fixture

Conversation

@gopidesupavan

Copy link
Copy Markdown
Member

As mentioned @kaxil in slack its causing issue when we run. failing to load secrets_masker.

pytest task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocess::test_reading_from_pipes

___________________________________________________________________________________ TestWatchedSubprocess.test_reading_from_pipes ____________________________________________________________________________________
task-sdk/tests/task_sdk/execution_time/test_supervisor.py:165: in test_reading_from_pipes
    rc = proc.wait()
task-sdk/src/airflow/sdk/execution_time/supervisor.py:761: in wait
    self._monitor_subprocess()
task-sdk/src/airflow/sdk/execution_time/supervisor.py:819: in _monitor_subprocess
    alive = self._service_subprocess(max_wait_time=max_wait_time) is None
task-sdk/src/airflow/sdk/execution_time/supervisor.py:653: in _service_subprocess
    need_more = socket_handler(key.fileobj)
task-sdk/src/airflow/sdk/execution_time/supervisor.py:1066: in cb
    gen.send(line)
task-sdk/src/airflow/sdk/execution_time/supervisor.py:1126: in forward_to_log
    log.log(level, msg, chan=chan)
/usr/local/lib/python3.10/site-packages/structlog/_native.py:179: in log
    return self._proxy_to_logger(name, event, **kw)
/usr/local/lib/python3.10/site-packages/structlog/_base.py:222: in _proxy_to_logger
    args, kw = self._process_event(method_name, event, event_kw)
/usr/local/lib/python3.10/site-packages/structlog/_base.py:173: in _process_event
    event_dict = proc(self._logger, method_name, event_dict)
task-sdk/src/airflow/sdk/log.py:109: in mask_logs
    event_dict = redact(event_dict)  # type: ignore[assignment]
task-sdk/src/airflow/sdk/execution_time/secrets_masker.py:117: in redact
    return _secrets_masker().redact(value, name, max_depth)
task-sdk/src/airflow/sdk/execution_time/secrets_masker.py:125: in _secrets_masker
    raise RuntimeError(
E   RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@gopidesupavan

Copy link
Copy Markdown
Member Author
image

@kaxil kaxil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That still fails for me when I run:

pytest task-sdk/tests --verbosity=0 --strict-markers --durations=100 --maxfail=50 --color=yes --junitxml=/files/test_result-all-none.xml --timeouts-order=moi --setup-timeout=60 --execution-timeout=60 --teardown-timeout=60 --disable-warnings -rfEX --skip-db-tests --ignore-glob=*/tests/system/* --ignore-glob=airflow-core/tests/integration/* --ignore-glob=providers/apache/cassandra/tests/integration/* --ignore-glob=providers/apache/drill/tests/integration/* --ignore-glob=providers/apache/hive/tests/integration/* --ignore-glob=providers/apache/kafka/tests/integration/* --ignore-glob=providers/apache/pinot/tests/integration/* --ignore-glob=providers/google/tests/integration/* --ignore-glob=providers/microsoft/mssql/tests/integration/* --ignore-glob=providers/mongo/tests/integration/* --ignore-glob=providers/openlineage/tests/integration/* --ignore-glob=providers/qdrant/tests/integration/* --ignore-glob=providers/redis/tests/integration/* --ignore-glob=providers/trino/tests/integration/* --ignore-glob=providers/ydb/tests/integration/* --warning-output-path=/files/warnings-all-none.txt --ignore=helm-tests --with-db-init --ignore=providers/cloudant/tests/ -n auto --no-cov --no-db-cleanup

FAILED task-sdk/tests/task_sdk/definitions/test_xcom_arg.py::test_xcom_convert_to_kwargs_fails_task - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/definitions/test_xcom_arg.py::test_xcom_map_error_fails_task - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocessKill::test_kill_process_custom_signal - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocessKill::test_kill_escalation_path[SIGINT-success-without-escalation] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocessKill::test_kill_escalation_path[SIGINT-escalates-to-SIGTERM] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestListenerOvertime::test_overtime_slow_listener_instance[super_basic_run-hello-2.0-True-listener0] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestListenerOvertime::test_overtime_slow_listener_instance[super_basic_run-hello-5.0-False-listener1] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocessKill::test_kill_escalation_path[SIGINT-escalates-to-SIGTERM-then-SIGKILL] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocessKill::test_kill_escalation_path[SIGTERM-escalates-to-SIGKILL] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocessKill::test_kill_escalation_path[SIGKILL-success-without-escalation] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
FAILED task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestHandleRequest::test_handle_requests[get_variable] - RuntimeError: Logging Configuration Error! No SecretsMasker found! If you have custom logging, please make sure you configure it taking airflow configuration as a base as explained at https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/logging-tasks.html#advanced-configuration
==================================

@gopidesupavan

Copy link
Copy Markdown
Member Author

pytest task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocess::test_reading_from_pipes

Ah it should work, as its require in may tests, better to set fixture to autouse.

@kaxil

kaxil commented Apr 8, 2025

Copy link
Copy Markdown
Member

pytest task-sdk/tests/task_sdk/execution_time/test_supervisor.py::TestWatchedSubprocess::test_reading_from_pipes

Ah it should work, as its require in may tests, better to set fixture to autouse.

Yeah, I have unblocked myself by doing this:

https://github.com/astronomer/airflow/blob/2e2db3dc1838cfb27aa7a8a8c996c2661d8c75f7/task-sdk/tests/conftest.py#L129-L133

in #48896

Comment thread task-sdk/tests/task_sdk/definitions/test_secrets_masker.py Outdated
@kaxil

kaxil commented Apr 8, 2025

Copy link
Copy Markdown
Member

I don;t think we need it after the change in https://github.com/astronomer/airflow/blob/2e2db3dc1838cfb27aa7a8a8c996c2661d8c75f7/task-sdk/tests/conftest.py#L129-L133

Closing it for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants