Accept BLOCKED and WAITING_FOR_RETRY Databricks run states - #69193
Conversation
…tabricks.py Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
|
Got this from Claude:
Not sure how doable this is, but leaving it here just in case. |
|
I'll take a look at that in a follow up, @uranusjr |
Was generative AI tooling used to co-author this PR?
Forked off of: #69174
What
RunState(the class that parses a Databricks run state) raisesAirflowException("Unexpected life cycle state")for any life-cycle state outside its hardcodedRUN_LIFE_CYCLE_STATESallowlist. That allowlist is a hand maintained duplicate of theRunLifeCycleStateenum and has drifted: it is missingBLOCKEDandWAITING_FOR_RETRY, both of which the enum (and the Databricks API) define.Why it matters
BLOCKEDandWAITING_FOR_RETRYare normal in-flight states:BLOCKED- the run cannot start yet because it is gated (max concurrent runs, a dependency, queueing). Routine forDatabricksRunNowOperator, which triggers existing jobs that are often concurrency- or dependency-gated.WAITING_FOR_RETRY- a task failed and Databricks is waiting to retry it.Because
RunStaterejects them, an operator polling a run that enters either state fails withAirflowExceptioninstead of continuing to wait. This affects the normal (synchronous) poll loop andget_run_statefor bothDatabricksSubmitRunOperatorandDatabricksRunNowOperator, on clean runs today - no crash or retry required to hit it.Fix
Add
BLOCKEDandWAITING_FOR_RETRYtoRunState.RUN_LIFE_CYCLE_STATESso they parse as valid states. No change tois_terminal: it already lists onlyTERMINATED/SKIPPED/INTERNAL_ERROR, so both new states are correctly treated as non-terminal and the poll loop keeps waiting until the run actually finishes.Backcompat
No behavior change other than not crashing: a run in one of these two states is now parsed and polled through instead of raising. Nothing that previously succeeded changes. The strict "unknown state raises" behavior is retained for genuinely unrecognized states.
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.