-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Raise error when DagRun
fails while running dag test
#36517
Conversation
8919958
to
3df3eba
Compare
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.
I am a bit wondering why we add another CLI parameter. If the DAG test fails and exit code 0 is returned I'd rather see this as a bug.
Is there a reason adding a new CLI param? Please convince me. Else it would even be leaner w/o additional parameter
I agree with @jscheffl. The default behavior of the cli command should be the status of the DAG run/runs. |
Once concern is backwards compatibility (and I think that's where @kaxil's solution came from). But yeah, I think you are right @jscheffl @dirrao - probably return value is not teally compatibility promise (and we can treat it as bugfix). We've already done the same in #35378 (and It was me who proposed skipping the flag and treating it as bugfix :D ... Now I remember . |
So if we had it two times already would be even a good "quality excercise" to double check that all CLI commands exit with a proper error code in case of error :-D |
Yeah I tried to think more on it to keep backwards-compat but I think we are ok -- will remove the param and make it the default behavior |
**Motivation**: Currently, when using `airflow dags test`, there is no easy way to know programmatically if a DagRun fails since the state is not stored in DB. The way to do know relies on log lines as below: ```bash state=$(airflow dags test exception_dag | grep "DagRun Finished" | awk -F, '{for(i=1;i<=NF;i++) if ($i ~ / state=/) print $i}' | awk -F= '{print $2}') if [[ $state == "failed" ]]; then exit 1 else exit 0 fi ``` This PR adds `--fail-on-dagrun-failure` flag to `airflow dags test` command which will return an exit code of 1 if DagRun fails and makes it easy to integrate in CI for testing.
3df3eba
to
d76891e
Compare
@jscheffl Done |
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.
Thanks for the fix!
DagRun
fails when running dag test
DagRun
fails while running dag test
The failed test is unrelated to the PR and succeeds locally:
|
**Motivation**: Currently, when using `airflow dags test`, there is no easy way to know programmatically if a DagRun fails since the state is not stored in DB. The way to do know relies on log lines as below: ```bash state=$(airflow dags test exception_dag | grep "DagRun Finished" | awk -F, '{for(i=1;i<=NF;i++) if ($i ~ / state=/) print $i}' | awk -F= '{print $2}') if [[ $state == "failed" ]]; then exit 1 else exit 0 fi ``` This PR adds will return an exit code 1 when `airflow dags test` command if DagRun fails and makes it easy to integrate in CI for testing. (cherry picked from commit 383ad31)
Motivation:
Currently, when using
airflow dags test
, there is no easy way to know programmatically if a DagRun fails since the state is not stored in DB. The way to do know relies on log lines as below:This PR will return an exit code 1 when
airflow dags test
command if DagRun fails and makes it easy to integrate in CI for testing.