Skip to content
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

KubernetesPodOperator new callbacks and allow multiple callbacks #44357

Merged
merged 15 commits into from
Jan 27, 2025

Conversation

johnhoran
Copy link
Contributor


I would like to have multiple callbacks in the kubernetes pod operator, and add two new callbacks. on_manifest_finalization would allow the callback to make changes just before the manifest is turned into a pod.
on_pod_wrapup would happen after the calls to on_pod_completion but just before the pod is deleted.

Adding both of these plus allowing multiple callbacks would allow you to do things in the kubernetes pod operator akin to how it approaches XComs but in a modular way. My use case here is I'm running DBT in kpo, and I want to do multiple things to the DBT artefacts after the DBT job has run, I could use on_manifest_finalization to insert an alpine sidecar with volumes mounted with the same intention as the XCom sidecar, where the sidecar keeps the volumes alive as files are extracted from it. on_pod_wrapup would allow me to insert a single sidecar and have multiple callbacks run their on_pod_completion before on_pod_wrapup kills the sidecar.

Copy link
Contributor

@amoghrajesh amoghrajesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start!
Can you add few test cases that test more scenarios of more than 1 callback?

  1. Few sync callbacks
  2. Few async
  3. Combination of both - trying to assert for order

@amoghrajesh amoghrajesh self-requested a review December 17, 2024 06:00
@johnhoran johnhoran requested a review from amoghrajesh January 21, 2025 11:11
@potiuk
Copy link
Member

potiuk commented Jan 26, 2025

Some static checks to solve after rebase

@potiuk
Copy link
Member

potiuk commented Jan 26, 2025

Note: We are in the process of moving all providers to a new structure - as part of #46045 so if you would like to avoid having to resolve conflicts, speedy fix and rebase is something that you might want to do @johnhoran

@potiuk
Copy link
Member

potiuk commented Jan 26, 2025

See also devlist announcement: https://lists.apache.org/thread/dzbj5yx5kwpbwyr5yscp4wnlsp6p9v8l

@eladkal
Copy link
Contributor

eladkal commented Jan 27, 2025

I fixed the static checks but the PR has conflicts @johnhoran can you please revase and resolve them?

@eladkal
Copy link
Contributor

eladkal commented Jan 27, 2025

Failures are on papermill provider, not related to this PR

@potiuk potiuk merged commit cc5f2f9 into apache:main Jan 27, 2025
68 of 69 checks passed
Copy link

boring-cyborg bot commented Jan 27, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@potiuk
Copy link
Member

potiuk commented Jan 27, 2025

Failures are on papermill provider, not related to this PR

Yep. already fixed in main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:cncf-kubernetes Kubernetes provider related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants