Skip to content
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

[AIRFLOW-4448] Don't bake ENV and _cmd into tmp config for non-sudo #4050

Merged
merged 1 commit into from
May 7, 2019

Conversation

ashb
Copy link
Member

@ashb ashb commented Oct 14, 2018

Make sure you have checked all steps below.

Jira

Description

If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in ps) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.

Tests

  • My PR adds the following unit tests: added some tests to tests/configuration.py.

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added.

Code Quality

  • Passes git diff upstream/master -u -- "*.py" | flake8 --diff

@ashb
Copy link
Member Author

ashb commented Oct 14, 2018

I haven't thought enough if this will mess up with the Kubernetes Executor, so someone familair with that (@Fokko? @tedmiston?) should take a look at this.

@Fokko
Copy link
Contributor

Fokko commented Oct 15, 2018

@ashb I just checked the Kubeternetes tests, and they seem to pass. Why do you think it messes up the Kubeternetes part? cc @dimberman

@ashb
Copy link
Member Author

ashb commented Oct 16, 2018

It was more I wasn't sure how the Kubernetes Executor etc worked, and if something was going to mess up as a result of that change it would be that.

Copy link
Member

@XD-DENG XD-DENG left a comment

Choose a reason for hiding this comment

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

Two minor typos in your comments.

airflow/task/task_runner/base_task_runner.py Outdated Show resolved Hide resolved
airflow/task/task_runner/base_task_runner.py Outdated Show resolved Hide resolved
@ashb ashb force-pushed the dont-bake-env-into-tmp-config branch from cd59ec5 to 0df13ac Compare October 24, 2018 12:28
@ms32035
Copy link
Contributor

ms32035 commented Oct 24, 2018

@ashb, has this branch been intentionally pushed to the apache repo, or just a mistake?

@ashb
Copy link
Member Author

ashb commented Oct 24, 2018

@ms32035 Yes it was intentional. Do you think there's a reason not to have it here?

@ms32035
Copy link
Contributor

ms32035 commented Oct 24, 2018

Not really. It was just so different from all other, that it made me wonder

@ashb ashb force-pushed the dont-bake-env-into-tmp-config branch from 0df13ac to b005425 Compare October 26, 2018 15:33
@ashb
Copy link
Member Author

ashb commented Oct 26, 2018

@bolkedebruin PTAL

tests/configuration.py Outdated Show resolved Hide resolved
@stale
Copy link

stale bot commented Dec 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Dec 13, 2018
@ashb ashb removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Dec 13, 2018
@ashb ashb force-pushed the dont-bake-env-into-tmp-config branch from b005425 to be38843 Compare December 15, 2018 15:41
@ashb
Copy link
Member Author

ashb commented Dec 15, 2018

@Fokko updated (and rebased). PTAL.

@ashb ashb force-pushed the dont-bake-env-into-tmp-config branch from be38843 to c3dc3b4 Compare January 14, 2019 12:43
@dimberman
Copy link
Contributor

@ashb just pinging on this since it seems like a pretty good addition :).

@ashb ashb force-pushed the dont-bake-env-into-tmp-config branch from c3dc3b4 to 17bf3d1 Compare April 30, 2019 19:51
@ashb
Copy link
Member Author

ashb commented Apr 30, 2019

@dimberman Turns out we forget our own PRs sometimes too 😁. Rebased, hopefully it's good now.

@ashb ashb dismissed XD-DENG’s stale review April 30, 2019 19:54

Fixed typos.

@codecov-io
Copy link

codecov-io commented Apr 30, 2019

Codecov Report

Merging #4050 into master will increase coverage by 0.04%.
The diff coverage is 80.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4050      +/-   ##
==========================================
+ Coverage   78.54%   78.59%   +0.04%     
==========================================
  Files         469      469              
  Lines       29981    30077      +96     
==========================================
+ Hits        23550    23639      +89     
- Misses       6431     6438       +7
Impacted Files Coverage Δ
airflow/utils/configuration.py 100% <100%> (ø) ⬆️
airflow/task/task_runner/base_task_runner.py 73.33% <50%> (-1.25%) ⬇️
airflow/configuration.py 91.87% <82.6%> (+0.05%) ⬆️
airflow/models/taskinstance.py 92.42% <0%> (-0.18%) ⬇️
airflow/contrib/operators/bigquery_operator.py 94.21% <0%> (+0.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f926249...9918541. Read the comment docs.

@ashb ashb changed the title [AIRFLOW-3178] Don't bake ENV and _cmd into tmp config for non-sudo [AIRFLOW-4448] Don't bake ENV and _cmd into tmp config for non-sudo Apr 30, 2019
If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in `ps`) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.
@ashb ashb force-pushed the dont-bake-env-into-tmp-config branch from 17bf3d1 to 9918541 Compare April 30, 2019 21:39
@ashb
Copy link
Member Author

ashb commented Apr 30, 2019

@dimberman Update to new jira too since the previous one was part of 1.10.1. PTAL

@dimberman
Copy link
Contributor

@ashb LGTM!

@dimberman dimberman merged commit 670f2ed into master May 7, 2019
JCoder01 pushed a commit to JCoder01/airflow that referenced this pull request May 14, 2019
…pache#4050)

If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in `ps`) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.
@potiuk potiuk deleted the dont-bake-env-into-tmp-config branch May 19, 2019 12:10
ashb added a commit that referenced this pull request May 30, 2019
…4050)

If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in `ps`) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.

(cherry picked from commit 670f2ed)
andriisoldatenko pushed a commit to andriisoldatenko/airflow that referenced this pull request Jul 26, 2019
…pache#4050)

If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in `ps`) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.
wmorris75 pushed a commit to modmed/incubator-airflow that referenced this pull request Jul 29, 2019
…pache#4050)

If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in `ps`) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.
dharamsk pushed a commit to postmates/airflow that referenced this pull request Aug 8, 2019
…pache#4050)

If we are running tasks via sudo then AIRFLOW__ config env vars won't be
visible anymore (without them showing up in `ps`) and we likely might
not have permission to run the _cmd's specified to find the passwords.

But if we are running as the same user then there is no need to "bake"
those options in to the temporary config file -- if the operator decided
they didn't want those values appearing in a config file on disk, then
lets do our best to respect that.

(cherry picked from commit 670f2ed)
xyu added a commit to xyu/airflow that referenced this pull request Feb 12, 2022
When sending configs to Airflow workers we materialize a temp config file. In apache#18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: apache#20092
Related to: apache#18772 apache#4050
potiuk pushed a commit that referenced this pull request Mar 15, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050
ephraimbuddy pushed a commit that referenced this pull request Mar 16, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 20, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 24, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
ephraimbuddy pushed a commit that referenced this pull request Mar 26, 2022
* Filter out default configs when overrides exist.

When sending configs to Airflow workers we materialize a temp config file. In #18772 a feature was added so that `_cmd` generated secrets are not written to the files in some cases instead favoring maintaining the raw `_cmd` settings. Unfortunately during materializing of the configs via `as_dict()` Airflow defaults are generated and materialized as well including defaults for the non `_cmd` versions of some settings. And due to Airflow setting precedence stating bare versions of settings winning over `_cmd` versions it results in `_cmd` settings being discarded:
https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html

This change checks `_cmd`, env, and secrets when materializing configs via `as_dict()` so that if the bare versions of the values is exactly the same as Airflow defaults and we have "hidden" / special versions of these configs that are trying to be set we remove the bare versions so that the correct version can be used.

Fixes: #20092
Related to: #18772 #4050

(cherry picked from commit e07bc63)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants