You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "sjyangkevin (via GitHub)" <gi...@apache.org> on 2026/03/12 15:18:34 UTC
[PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
sjyangkevin opened a new pull request, #63454:
URL: https://github.com/apache/airflow/pull/63454
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
related: #62887
### Summary
This PR implements executor callback support for KubernetesExecutor, continuing the work started in #61153 and #62645. Synchronous callbacks are routed to an executor to run as workloads.
### Approach
Callbacks run as Kubernetes pods, the same isolation model used for tasks. The workload (an ExecuteCallback JSON payload) is passed to the `execute_workload` entrypoint that tasks use, and the pod's exit code determines success or failure.
The implementation threads callbacks through the existing executor pipeline with annotation-based discrimination to distinguish callback pods from task pods:
- Callback pods carry a `callback_id` annotation instead of `dag_id`/`task_id`/`try_number`
- The watcher branches on this annotation to extract the right key type
- `_change_state()` dispatches on key type (str = callback, TaskInstanceKey = task)
Callback pod lifecycle
```
Scheduler
└── _process_workloads(ExecuteCallback)
└── task_queue.put(KubernetesJob(callback_key, [workload], None, None))
AirflowKubernetesScheduler.run_next()
└── _run_next_callback()
└── pod: python -m airflow.sdk.execution_time.execute_workload
--json-string <ExecuteCallback JSON>
annotations: {callback_id: <uuid>}
labels: {airflow-worker: <job_id>}
KubernetesJobWatcher (sees callback_id annotation → passes CallbackKey)
└── result_queue.put(KubernetesResults(callback_key, state, ...))
KubernetesExecutor._change_state()
└── isinstance(key, str) → _change_callback_state()
└── event_buffer[key] = CallbackState.SUCCESS / FAILED
```
Currently `execute_workload.py` calls `execute_callback_workload()` inline in the pod process. Once `supervise_callback()` from (#62645) is merged, need to update `_execute_callback()` in `execute_workload.py`
### Follow-ups
- Pod adoption on scheduler restart: Orphaned callback pods after a scheduler restart are not currently adopted (unlike task pods).
- Callback revocation: No revoke_callback() support yet — callbacks can't be cancelled mid-flight.
- supervise_callback() integration: Pending #62645; see above.
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->
- [X] Yes (please specify the tool below)
Generated-by: [Claude Code (claude-opus-4-6)] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
* Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "sjyangkevin (via GitHub)" <gi...@apache.org>.
sjyangkevin commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-4340296323
I wonder if there is a way i could re-open this PR as a draft (didn't see this option). I've pushed some updates to the branch, and working on testing it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "sjyangkevin (via GitHub)" <gi...@apache.org>.
sjyangkevin commented on code in PR #63454:
URL: https://github.com/apache/airflow/pull/63454#discussion_r3006529733
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:
##########
@@ -312,13 +323,16 @@ def sync(self) -> None:
try:
key = task.key
self.kube_scheduler.run_next(task)
- self.task_publish_retries.pop(key, None)
+ if not isinstance(key, str):
Review Comment:
Thanks for the feedback, I've resolved the first two comments but there are some issues in my local checks preventing me to push.
For the use of `isinstance(key, str)`, there are some mypy issues when use `isinstance(key, WorkloadKey)`. Will have a deeper look into this, to make sure I am handling the different types of workloads properly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-4296204373
@sjyangkevin This draft PR has had no activity for 3 weeks. Closing to keep the queue clean.
You are welcome to reopen and continue when you're ready. If you'd like to pick it back up, please rebase onto the current `main` branch first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "sjyangkevin (via GitHub)" <gi...@apache.org>.
sjyangkevin commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-4376646488
Yeah, I wasn't able to see this option. I am running k8s tests, and will tag a maintainer once the tests are done.
<img width="900" height="324" alt="Screenshot from 2026-05-05 00-58-26" src="https://github.com/user-attachments/assets/cda601b4-5062-4814-8d94-ecb5408fb1a6" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "sjyangkevin (via GitHub)" <gi...@apache.org>.
sjyangkevin commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-5075777085
Hi @JH-A-Kim , a few updates have been introduced after the PR opened. As mentioned https://github.com/apache/airflow/pull/63454#issuecomment-5061564735, there are two k8s tests failed after rebasing. You can take the branch and follow the instruction here to run the tests to re-produce the failure. https://github.com/apache/airflow/blob/main/contributing-docs/testing/k8s_tests.rst
I think there might be a few tweaks needed to make the callback routine work with the new changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "sjyangkevin (via GitHub)" <gi...@apache.org>.
sjyangkevin commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-4453191082
> Just link back to this one for visibilit
Sure, let me open a new PR and link back to this. I also facing some issues when trying to run k8s test locally while setting the the cluster locally and upload the image.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "JH-A-Kim (via GitHub)" <gi...@apache.org>.
JH-A-Kim commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-5073632975
> > Hey @sjyangkevin! What's the status on this feature? We're waiting on callback executor support for K8s to migrate SLAs for our production services, is there anything I can do to help?
>
> Hi, I wasn’t able to get a chance to finish it. After rebasing recently, two existing k8s integration tests failed and that need to be resolved. Also, unit test failing and resolution needed, context described in #68195
Hi @sjyangkevin I actually made a pr from your pr #68195 to try and fix the problems you outlined and I think I got a fix working! Just waiting on reviews for the time being if you would like you can take a look! #70148
And @ferruzzi asked me to see how I can help to finish this feature out so please let me know what still needs to be worked on and anything else I should know!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "joopica (via GitHub)" <gi...@apache.org>.
joopica commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-5060455499
Hey @sjyangkevin! What's the status on this feature? We're waiting on callback executor support for K8s to migrate SLAs for our production services, is there anything I can do to help?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-4373040699
> I wonder if there is a way i could re-open this PR as a draft (didn't see this option). I've pushed some updates to the branch, and working on testing it.
@sjyangkevin
Don't you see an option like this at the bottom:
<img width="572" height="78" alt="image" src="https://github.com/user-attachments/assets/74a509c6-dd36-4108-833a-7ef98c38ed50" />
If not, you can tag a maintainer to reopen the pull request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-4435562215
Interesting, I can't reopen it either. The button is greyed out and when I hover over it I see "The feat/kubernetes-executor-callback-supprt branc was force-pushed or recreated" I think you are going to have to rebase your local branch then open a new one. Just link back to this one for visibility and tag me in the new one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed pull request #63454: feat(kubernetes): add executor callback support to KubernetesExecutor
URL: https://github.com/apache/airflow/pull/63454
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(kubernetes): add executor callback support to KubernetesExecutor [airflow]
Posted by "sjyangkevin (via GitHub)" <gi...@apache.org>.
sjyangkevin commented on PR #63454:
URL: https://github.com/apache/airflow/pull/63454#issuecomment-5061564735
> Hey @sjyangkevin! What's the status on this feature? We're waiting on callback executor support for K8s to migrate SLAs for our production services, is there anything I can do to help?
Hi, I wasn’t able to get a chance to finish it soon. After rebasing recently, two existing k8s integration tests failed and that need to be resolved. Also, unit test failing and resolution needed on #68195
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org