Skip to content

[AIRFLOW-4194] Set dag_run state to failed when user terminate backfill#5016

Merged
feng-tao merged 1 commit intoapache:masterfrom
milton0825:backfill-terminated-by-user
Apr 2, 2019
Merged

[AIRFLOW-4194] Set dag_run state to failed when user terminate backfill#5016
feng-tao merged 1 commit intoapache:masterfrom
milton0825:backfill-terminated-by-user

Conversation

@milton0825
Copy link
Copy Markdown
Contributor

@milton0825 milton0825 commented Apr 1, 2019

Make sure you have checked all steps below.

Jira

Description

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

Currently when user terminates backfill job, the DagRuns stays in the running state, which occupy the slots in max_active_runs. We should set the DagRun state to FAILED.

Tests

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

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.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
    • If you implement backwards incompatible changes, please leave a note in the Updating.md so we can assign it to a appropriate release

Code Quality

  • Passes flake8

@milton0825 milton0825 changed the title [AIRFLOW-4194] Set dag_run state to failed when user terminate backfill [AIRFLOW-4194][WIP] Set dag_run state to failed when user terminate backfill Apr 1, 2019
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #5016 into master will increase coverage by 65.38%.
The diff coverage is 81.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #5016       +/-   ##
===========================================
+ Coverage    10.6%   75.99%   +65.38%     
===========================================
  Files         461      461               
  Lines       29968    29978       +10     
===========================================
+ Hits         3179    22782    +19603     
+ Misses      26789     7196    -19593
Impacted Files Coverage Δ
airflow/jobs.py 78.84% <81.81%> (+66.58%) ⬆️
airflow/plugins_manager.py 86.91% <0%> (+0.93%) ⬆️
airflow/executors/dask_executor.py 2% <0%> (+2%) ⬆️
airflow/exceptions.py 100% <0%> (+2.56%) ⬆️
airflow/config_templates/airflow_local_settings.py 76.47% <0%> (+2.94%) ⬆️
airflow/utils/operator_resources.py 86.95% <0%> (+4.34%) ⬆️
...etes_request_factory/kubernetes_request_factory.py 72.11% <0%> (+4.8%) ⬆️
airflow/executors/__init__.py 63.46% <0%> (+5.76%) ⬆️
airflow/settings.py 84.25% <0%> (+11.81%) ⬆️
airflow/_vendor/nvd3/ipynb.py 14.28% <0%> (+14.28%) ⬆️
... and 361 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 75c633e...b6648ba. Read the comment docs.

@milton0825 milton0825 changed the title [AIRFLOW-4194][WIP] Set dag_run state to failed when user terminate backfill [AIRFLOW-4194] Set dag_run state to failed when user terminate backfill Apr 1, 2019
@milton0825
Copy link
Copy Markdown
Contributor Author

PTAL @ashb @feng-tao

Comment thread airflow/jobs.py Outdated
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.

Do we need the SystemExit here?

Copy link
Copy Markdown
Contributor Author

@milton0825 milton0825 Apr 2, 2019

Choose a reason for hiding this comment

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

In case of sigterm? actually we don't raise SystemExit in case of SIGTERM in backfill

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.

updated the PR to handle SIGTERM

@feng-tao
Copy link
Copy Markdown
Member

feng-tao commented Apr 2, 2019

Will need to refresh my memory on why I did it in https://github.com/apache/airflow/pull/3562/files instead of your way :)

@milton0825 milton0825 force-pushed the backfill-terminated-by-user branch from b6648ba to 2d120e3 Compare April 2, 2019 06:22
Comment thread airflow/jobs.py Outdated
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.

cool, save lots of unnecessary code...

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.

\OwO/

Copy link
Copy Markdown
Member

@feng-tao feng-tao left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread airflow/jobs.py Outdated
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.

an empty line in between.

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.

fixed.

@milton0825 milton0825 force-pushed the backfill-terminated-by-user branch from 2d120e3 to 5d71c3e Compare April 2, 2019 06:32
@Fokko
Copy link
Copy Markdown
Contributor

Fokko commented Apr 2, 2019

I see a sad mypy, but it looks unrelated:


Collecting mypy
  Using cached https://files.pythonhosted.org/packages/88/11/8092fdd9cf4c507e6c799bf663e713a5418beb9fda422df810f72641224c/mypy-0.670-py3-none-any.whl
Collecting mypy-extensions<0.5.0,>=0.4.0 (from mypy)
  Using cached https://files.pythonhosted.org/packages/4d/72/8d54e2b296631b9b14961d583e56e90d9d7fba8a240d5ce7f1113cc5e887/mypy_extensions-0.4.1-py2.py3-none-any.whl
Collecting typed-ast<1.4.0,>=1.3.1 (from mypy)
  Using cached https://files.pythonhosted.org/packages/15/d6/a7ce9cd898c218ee79352f7636991868d4165f881621d8c48df886fa5865/typed_ast-1.3.1-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: mypy-extensions, typed-ast, mypy
Successfully installed mypy-0.670 mypy-extensions-0.4.1 typed-ast-1.3.1
45.01s$ mypy airflow tests
tests/contrib/hooks/test_gcp_text_to_speech_hook.py:30: error: Name 'mock' already defined (by an import)
tests/contrib/hooks/test_gcp_text_to_speech_hook.py:32: error: Incompatible types in assignment (expression has type "None", variable has type Module)
tests/contrib/hooks/test_gcp_speech_to_text_hook.py:30: error: Name 'mock' already defined (by an import)
tests/contrib/hooks/test_gcp_speech_to_text_hook.py:32: error: Incompatible types in assignment (expression has type "None", variable has type Module)
tests/contrib/operators/test_gcp_text_to_speech_operator.py:33: error: Name 'mock' already defined (by an import)
tests/contrib/operators/test_gcp_text_to_speech_operator.py:35: error: Incompatible types in assignment (expression has type "None", variable has type Module)
tests/contrib/operators/test_gcp_speech_to_text_operator.py:30: error: Name 'mock' already defined (by an import)
tests/contrib/operators/test_gcp_speech_to_text_operator.py:32: error: Incompatible types in assignment (expression has type "None", variable has type Module)
The command "mypy airflow tests" exited with 1.

@milton0825
Copy link
Copy Markdown
Contributor Author

@feng-tao
Copy link
Copy Markdown
Member

feng-tao commented Apr 2, 2019

the issue is fixed in master which is unrelated to this pr. merge it now.

@feng-tao feng-tao merged commit 8ca3541 into apache:master Apr 2, 2019
@milton0825 milton0825 deleted the backfill-terminated-by-user branch April 13, 2019 19:03
cthenderson pushed a commit to cthenderson/apache-airflow that referenced this pull request Apr 16, 2019
andriisoldatenko pushed a commit to andriisoldatenko/airflow that referenced this pull request Jul 26, 2019
wmorris75 pushed a commit to modmed-external/incubator-airflow that referenced this pull request Jul 29, 2019
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