Skip to content

[AIRFLOW-1985] Impersonation fixes for using run_as_user#2991

Closed
edgarRd wants to merge 1 commit into
apache:masterfrom
edgarRd:erod-impersonation-fix
Closed

[AIRFLOW-1985] Impersonation fixes for using run_as_user#2991
edgarRd wants to merge 1 commit into
apache:masterfrom
edgarRd:erod-impersonation-fix

Conversation

@edgarRd
Copy link
Copy Markdown
Contributor

@edgarRd edgarRd commented Jan 30, 2018

JIRA

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Making sure all tasks have the proper configuration by copying it into a
temporary file.

  • [AIRFLOW-1985] Airflow home and python path to BashOperator

BashOperators should have the context of the AIRFLOW_HOME and PYTHONPATH
as other tasks have.

Make sure you have checked all steps below.

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

Impersonation unit tests included. Integration tests were also done in a staging environment.

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
    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"
  • Passes git diff upstream/master -u -- "*.py" | flake8 --diff

@edgarRd
Copy link
Copy Markdown
Contributor Author

edgarRd commented Jan 30, 2018

@aoen @yrqls21 PTAL

@Fokko
Copy link
Copy Markdown
Contributor

Fokko commented Jan 31, 2018

Please rebase against master to trigger a new build. The CI should be fixed.

@edgarRd edgarRd force-pushed the erod-impersonation-fix branch from 3b8a4cf to 55994f7 Compare January 31, 2018 18:47
@edgarRd
Copy link
Copy Markdown
Contributor Author

edgarRd commented Jan 31, 2018

@Fokko Done. Thanks!

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 31, 2018

Codecov Report

Merging #2991 into master will increase coverage by 0.18%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2991      +/-   ##
==========================================
+ Coverage   72.96%   73.14%   +0.18%     
==========================================
  Files         176      177       +1     
  Lines       12375    12394      +19     
==========================================
+ Hits         9029     9066      +37     
+ Misses       3346     3328      -18
Impacted Files Coverage Δ
airflow/models.py 87.07% <ø> (ø) ⬆️
airflow/executors/base_executor.py 95.16% <ø> (ø) ⬆️
airflow/utils/log/file_task_handler.py 87.05% <100%> (ø) ⬆️
airflow/jobs.py 80.01% <100%> (+0.51%) ⬆️
airflow/operators/bash_operator.py 91.22% <100%> (+0.84%) ⬆️
airflow/utils/configuration.py 100% <100%> (ø)
airflow/task/task_runner/base_task_runner.py 79.31% <100%> (+8.99%) ⬆️
airflow/utils/helpers.py 54.02% <0%> (+2.87%) ⬆️
... and 1 more

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 6f00f72...38eb7d1. Read the comment docs.

Comment thread airflow/executors/base_executor.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit format like your other TODOs:

TODO(edgarRd): AIRFLOW-1444:

Comment thread airflow/executors/base_executor.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: /Adding cfg_path as a way to/cfg_path is needed to

Comment thread airflow/jobs.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a bit unclear what this is referring to, and the line of code sited could change. I think it's fine to just remove this comment

Comment thread airflow/jobs.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this line needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe so, otherwise cfg_path used further down in call executor.queue_task_instance(...) would not be defined if the flow does not go through the following if statement.

Comment thread airflow/operators/bash_operator.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's provide more context (no pun intended) around what kind of context this is referring to (i.e. what should run in the same context as what)

Comment thread airflow/operators/bash_operator.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Example would be helpful here, e.g. PythonOperator where airflow is imported

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What cleans this up? If it's not cleaned up, seems like a good place for a context manager.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried using a context manager, but this file is actually removed by the receiving new process so triggered by the task runner: https://github.com/apache/incubator-airflow/blob/master/airflow/bin/cli.py#L395 so, the context does not work for this case.
This is usually a bad pattern because the run command in the cli (a new process) is removing a file it does not maintain, making it harder for the caller (the parent process) to clean up the files the it actually creates / maintains. Fixing that design is out of scope of this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@edgarRd can you at least create a JIRA for that issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@edgarRd edgarRd force-pushed the erod-impersonation-fix branch from 55994f7 to e96dfd2 Compare February 7, 2018 20:29
* [AIRFLOW-1985] Changes to propagate config in subdags

* [AIRFLOW-1985] Make sure tasks running have the config

Making sure all tasks have the proper configuration by copying it into a
temporary file.

* [AIRFLOW-1985] Airflow home and python path to BashOperator

BashOperators should have the context of the AIRFLOW_HOME and PYTHONPATH
as other tasks have.
@edgarRd edgarRd force-pushed the erod-impersonation-fix branch from e96dfd2 to 38eb7d1 Compare February 7, 2018 21:30
@aoen
Copy link
Copy Markdown
Contributor

aoen commented Feb 7, 2018

LGTM

@asfgit asfgit closed this in a0deb50 Feb 7, 2018
aliceabe pushed a commit to aliceabe/incubator-airflow that referenced this pull request Jan 3, 2019
Changes to propagate config in
subdags, and make sure tasks running have the
config.

Making sure all tasks have the proper
configuration by copying it into a
temporary file.

BashOperators should have the context of the
AIRFLOW_HOME and PYTHONPATH
as other tasks have.

Closes apache#2991 from edgarRd/erod-impersonation-fix
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.

5 participants