Make cncf.kubernetes model deserialization picklable in-cluster#68848
Open
ephraimbuddy wants to merge 1 commit into
Open
Make cncf.kubernetes model deserialization picklable in-cluster#68848ephraimbuddy wants to merge 1 commit into
ephraimbuddy wants to merge 1 commit into
Conversation
The kubernetes client (v36) attaches the process-global in-cluster Configuration to every model it deserializes, and that Configuration's refresh_api_key_hook is an unpicklable local closure. Any deserialized model that later gets pickled -- for example a pod_override placed on the KubernetesExecutor multiprocessing queue -- then crashes. Deserialize through an ApiClient built with a fresh Configuration in the provider's model-deserialization paths so the resulting models (and every nested object) stay picklable regardless of the kubernetes client version: PodGenerator.deserialize_model_dict, KubernetesJobOperator.deserialize_job_template_file, and the backcompat _convert_from_dict converter.
1 task
amoghrajesh
requested changes
Jun 23, 2026
amoghrajesh
left a comment
Contributor
There was a problem hiding this comment.
Something's up with the diff here, its same as: #68831, requesting changes on this one too to be careful
Comment on lines
+112
to
+114
| import pickle | ||
|
|
||
| from kubernetes.client import Configuration |
Comment on lines
+39
to
+41
| # A fresh Configuration() keeps the deserialized model picklable: in-cluster, the kubernetes | ||
| # client (v36) would otherwise stamp the global Configuration, whose refresh_api_key_hook is | ||
| # an unpicklable local closure, onto the model and every nested object. |
Contributor
There was a problem hiding this comment.
This same comment seems to repeat 3 times - in here, in job.py and in pod_generator.py, one place is enough.
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.
The kubernetes client (v36) attaches the process-global in-cluster Configuration to every model it deserializes, and that Configuration's refresh_api_key_hook is an unpicklable local closure. Any deserialized model that later gets pickled -- for example a pod_override placed on the KubernetesExecutor multiprocessing queue -- then crashes.
Deserialize through an ApiClient built with a fresh Configuration in the provider's model-deserialization paths so the resulting models (and every nested object) stay picklable regardless of the kubernetes client version: PodGenerator.deserialize_model_dict, KubernetesJobOperator.deserialize_job_template_file, and the backcompat _convert_from_dict converter.
Was generative AI tooling used to co-author this PR?
claude opus 4.8
{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.