[AIRFLOW-1383] Add no_dag_reset option to airflow clear command#2420
[AIRFLOW-1383] Add no_dag_reset option to airflow clear command#2420chronitis wants to merge 4 commits intoapache:masterfrom lifesum:airflow-1383
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2420 +/- ##
======================================
Coverage 78.1% 78.1%
======================================
Files 201 201
Lines 16464 16464
======================================
Hits 12859 12859
Misses 3605 3605
Continue to review full report at Codecov.
|
airflow/bin/cli.py
Outdated
There was a problem hiding this comment.
Rather than having to do reset_dag_runs=not args.no_dag_reset at the call site, would we do something like "store_false", metavar="reset_dag_runs", default=True)?
There was a problem hiding this comment.
metavar was not what I meant.
'reset_dag_runs': Arg(... "store_false", default=True) was what I meant.
There was a problem hiding this comment.
Not possible without further changes; the Arg() namedtuple doesn't include dest, and the generated variable name is not set by the dictionary key; you'd have to do --reset_dag_runs=0 or something similar, which seems unnecessarily ugly.
tests/core.py
Outdated
There was a problem hiding this comment.
I feel that some assertion that the flag does what we expect is needed here please.
(Late review, sorry!)
|
@ashb I've extended the test to assert the state of a created DAG run before and after clearing, which should cover the intended functionality. I haven't changed the CLI option - as per the comment above, the current One of the kubernetes tests failed for reasons that look unrelated and probably transitory. All the other tests passed. |
|
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. |
The underlying DAG.clear() function has a parameter reset_dag_runs (default True) which controlls whether DAG runs for which a task was cleared will be set to state=RUNNING. The current CLI doesn't expose this option; this adds a flag (no_dag_reset) which prevents runs being set to RUNNING after clearing, for cases where it is desirable to clear jobs but not immediately have them re-running.
With --no_dag_reset, the state of the DAG should not change to RUNNING after calling clear.
|
@ashb did you miss this one? |
|
I may be wrong, but I think we have supported something similar in 4c6f1fd |
Dear Airflow maintainers,
Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
JIRA
Description
The CLI command
airflow cleardoes not expose any way to set thereset_dag_runsparameter of the underlyingDAG.clear()method.This means that
airflow clearwill always cause affected DAG runs to be set tostate=RUNNING, and immediately try and re-run the cleared tasks. In some circumstances it might not be desirable to immediately re-run everything.Tests
A simple test for the CLI syntax is added to
tests/core.pyCommits