Repository navigation
Make start_date in Context nullable - #58175
Conversation
8717e45 to
cb643c4
Compare
o-nikolas
left a comment
There was a problem hiding this comment.
Can you add a unit test that covers this please!
|
It seems like a unit test wouldn't be very useful here and I think we should test for this case once either deadline callbacks on executor or full context in triggerer is implemented (cc @ferruzzi). I also don't see other unit tests just for the API specs |
|
Hey @kaxil and @amoghrajesh! I would ideally like to get an approval from either of you to ensure I'm not missing any unintended consequences of this change |
potiuk
left a comment
There was a problem hiding this comment.
It looks good to me, but I would love to have the "experts" in the area to confirm it :)
ferruzzi
left a comment
There was a problem hiding this comment.
Same as Jarek. Seems like a good change to me, but I don't have a full context on Context to know about any side-effects.
amoghrajesh
left a comment
There was a problem hiding this comment.
Change makes sense, but we will have to have a cadywn migration for this.
Take a situation of using older task sdk client (v3.1) and new API server (v3.2 assuming this change is for that version). The scenario I have in mind a combination of backfills with max_active_runs. If multiple runs are created with backfills and max_active_runs set, there is a chance that later run starts before an earlier run and the earlier run is still in queued. If the later run is doing ti.get_previous_dagrun(state='queued'), theres a chance it might return None and the task crashing because the datamodel for that task cannot take None.
So we should add a cadwyn migration for this one, use this as a reference: https://github.com/apache/airflow/blob/main/contributing-docs/19_execution_api_versioning.rst
|
Any update here? |
I'm going to take this one over; I'll try to get it done next week |
cb643c4 to
f7e3752
Compare
|
One very long week later 🙈 @amoghrajesh @uranusjr First time working with a cadwyn migration. I based it off the examples and the unit tests pass, but I'm not sure how to manually test it. Can you have a look when you get time? |
amoghrajesh
left a comment
There was a problem hiding this comment.
@ferruzzi the versioning looks good, but just to gain more confidence you can try running a situation where:
- Deploy changes in this PR for API server
- Undo changes for task sdk OR run old version of task sdk (pre 3.2)
- Run a dag that triggers / touches this flow
f7e3752 to
508e9c4
Compare
|
Feedback from Opus: PR Review: Make DagRun
|
| Area | Risk | Rationale |
|---|---|---|
| Breaking old Task SDK clients | None | Cadwyn converter provides run_after fallback |
| Breaking current deadline alerts | None | Current callbacks don't use full Context |
| Future deadline callbacks | Low | Type change is in place; just needs context population |
| Codegen drift | Low | If _generated.py was regenerated, no risk; if hand-edited, will be overwritten |
Summary
Solid preparatory change for the Deadline Alerts feature. The core logic is correct, backward compatibility is handled properly, and the test coverage is good. The only actionable suggestion is adding a test for the direct DagRun endpoint's backward compat path. Everything else is nit-level.
If a deadline is missed before a DagRun is started (could be queued for a very long time), there would be an exception when creating the Context because start_date is currently non-nullable.
Co-authored-by: Amogh Desai <[email protected]>"
508e9c4 to
a714368
Compare
amoghrajesh
left a comment
There was a problem hiding this comment.
Thanks @ferruzzi! LGTM +1
Feel free to validate it functionally once before merge as you mentioned earlier :)
* Make start_date in Context nullable If a deadline is missed before a DagRun is started (could be queued for a very long time), there would be an exception when creating the Context because start_date is currently non-nullable. * Add cadwyn migration for nullable DagRun.start_date * more explicit downgrade Co-authored-by: Amogh Desai <[email protected]>" * merge conflict static checks --------- Co-authored-by: ferruzzi <[email protected]>
If a deadline is missed before a DagRun is started (could be queued for a very long time), there would be an exception when creating the Context because start_date is currently non-nullable.
Note: this doesn't affect the current implementation of deadline alerts because the full context is currently not included in the context passed to deadline callbacks. Only deadline related info and the DagRun API response is included (which already allows for nullable
start_dateas we would expect). This change would be needed for future once there's deadline callbacks running in the executor and improved (full) context included for callbacks running on the triggerer.^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.