-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure a WatchedSubprocess redacts only its values and not parent processes' #48527
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Guess i have to write some tests, but majority of the work is complete here. |
ashb
approved these changes
Mar 29, 2025
Co-authored-by: Ash Berlin-Taylor <[email protected]>
kaxil
reviewed
Mar 29, 2025
kaxil
reviewed
Mar 29, 2025
kaxil
reviewed
Mar 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall lgtm -- added few comments
Test failure isnt related |
kaxil
approved these changes
Mar 29, 2025
shubham-pyc
pushed a commit
to shubham-pyc/airflow
that referenced
this pull request
Apr 2, 2025
nailo2c
pushed a commit
to nailo2c/airflow
that referenced
this pull request
Apr 4, 2025
simonprydden
pushed a commit
to simonprydden/airflow
that referenced
this pull request
Apr 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If you have noticed some of the recent logs by running tasks from the latest main, branch they somewhat look like:
This problem is because we mask the "password" of SQLA when running in breeze (which is
airflow
), here: https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/settings.py#L372Although this might seem like a trivial problem for breeze, it isn't. There is a bigger problem here because we SHOULDNT be redacting the SQLA stuff at all for the "subprocess" that task sdk supervisor launches, and the reason for that is the subprocess has not access to the DB at ALL!!
Solution
Solving this by introducing a new "reset" method on secrets masker that will reset the current patterns and replacer in it
What that does basically is it treats the masker as a new instance, which is what i want: https://github.com/apache/airflow/blob/main/task-sdk/src/airflow/sdk/execution_time/secrets_masker.py#L330-L352
Adding a condition while adding the
mask_logs
log processor to the logger. We control that using thesending_to_supervisor
flag now. If we are sending to supervisor, then DO NOT add themask_logs
as it will be already masked by the supervisor and no need to remask it.This will not impact any existing behaviour as you might think because all calls will still go through: https://github.com/apache/airflow/blob/main/task-sdk/src/airflow/sdk/execution_time/secrets_masker.py#L83-L94
This same functionality needs to be extended to the dag processor as well as triggerer which use the task sdk supervisor now. The subprocess shan't have access to the parent process' masking.
Testing
Scenario 1: Retrieving a conneciton inside a task and trying to print its password, which is "password"
Connection:
DAG:
Scenario 2: Trying to do the same with conneciton but at global level
DAG:
^ 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.