Add ChainRetryPolicy to common.compat for Airflow 3.3 - #73553
Merged
Merged
Conversation
kaxil
marked this pull request as draft
September 22, 2026 13:56
kaxil
force-pushed
the
chain-retry-policy-compat
branch
2 times, most recently
from
September 22, 2026 14:16
aa37750 to
569c3fd
Compare
vatsrahul1001
approved these changes
Sep 22, 2026
kaxil
force-pushed
the
chain-retry-policy-compat
branch
from
September 22, 2026 14:57
569c3fd to
3ef58ce
Compare
Airflow 3.4 added ChainRetryPolicy to the Task SDK. Retry policies exist since 3.3, so a Dag on 3.3 can now import the chain, and the other retry policy names, from airflow.providers.common.compat.sdk. On 3.4 and later the compat module returns the SDK class; on 3.3 a copy in this provider stands in for it.
kaxil
force-pushed
the
chain-retry-policy-compat
branch
from
September 22, 2026 16:30
3ef58ce to
9551ee5
Compare
kaxil
marked this pull request as ready for review
September 22, 2026 17:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #73508, which added
ChainRetryPolicyto the Task SDK in Airflow 3.4. Retry policies themselves arrived in 3.3, so a Dag on 3.3 can run a chain as long as the class comes from somewhere. This makesairflow.providers.common.compat.sdkthat place: where the SDK has the class (3.4 and later) the compat module returns the SDK class, on 3.3 a copy in this provider stands in for it, and on 3.2 and below the name is absent, as retry policies are.The other retry policy names (
RetryPolicy,RetryDecision,RetryAction,RetryRule,ExceptionRetryPolicy) are exported from the same module, so a chain is one import line. Those map straight to the SDK on every version that has them.The tests ran on
main(Airflow 3.4.0), where compat resolves to the SDK class, and against a released Airflow 3.3.2 with Task SDK 1.3.2 and this provider installed from a wheel, where compat resolves to the copy. The behaviour tests import the copy directly and one drives it through the worker's own_evaluate_retry_policy, so both run on both versions.Design rationale
A copy in compat, rather than raising the Common AI floor to 3.4. Common AI floors
apache-airflow>=3.0.0; requiring 3.4 for one class would drop 3.0 to 3.3 for the whole provider, and it would still leave every other Dag author on 3.3 without the chain. Vendoring the class privately inside Common AI would serve one consumer. The compat provider exists for this gap and already carries class copies (the lineage entities) and polyfills, so a copy here serves any Dag on 3.3 through one import line. The cost is that the copy stays in the package until 3.3 leaves compat's support window, which is why the tests compare the source of both classes and fail on drift.Resolved through the existing lazy import map, not a version gate at import time. The compat sdk module resolves names on first access. Adding map entries means importing
airflow.providers.common.compat.sdkgains no new eager import, and the SDK path is listed first, so wherever the SDK has the class the copy is never imported. The copy importsRetryPolicy,RetryDecisionandRetryActionfrom the SDK rather than duplicating them, so it produces SDK decisions and is a subclass of the SDK base; the worker only callsevaluateand only ahas_retry_policyflag is serialized, so nothing can tell the two classes apart.Gated on 3.3 like the other 3-only names. On Airflow 2 and on 3.0 to 3.2 the import raises
ImportError, the wayDownstreamTasksSkippeddoes there. A provider that supports those versions and imports any of the six names at module level has to guard the import, as Common AI already does for its SDK retry imports.The Common AI retry guide will point 3.3 users at this import once it is in a compat release.
Live run on Airflow 3.3.2
A released Airflow 3.3.2 (Task SDK 1.3.2) under Breeze with this provider installed from a wheel, and a Dag whose only retry-policy imports come from
airflow.providers.common.compat.sdk. One chain for every task: a rule set that fails aPermissionError, a deliberately broken policy that raises, then a floor that retries aConnectionErrorafter 15 seconds. Each task logs the class it is running, which on 3.3.2 is the copy in this provider.rules_first__403PermissionErrorExceptionRetryPolicy: never retry a 403floor__connection_refusedConnectionErrorExceptionRetryPolicy: floor (after ExceptionRetryPolicy: no decision; BrokenPolicy: raised RuntimeError)nothing_decides__value_errorValueErrorretriesapplyno policy decided (ExceptionRetryPolicy: no decision; BrokenPolicy: raised RuntimeError; ExceptionRetryPolicy: no decision){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.