Fix SparkKubernetesOperator with deferrable=True falling through to KubernetesPodOperator.execute() creating a spurious pod#66448
Merged
shahar1 merged 3 commits intoMay 6, 2026
Conversation
…etesPodOperator.execute() (apache#66437)
…remove newsfragment
Contributor
Author
|
@SameerMesiah97 Updated based on your review feedback:
CI running — please re-review when ready. |
shahar1
approved these changes
May 6, 2026
|
Thanks for the fix. I have a question regarding this issue: I encountered this issue in the deployed environment, but I was unable to reproduce it locally. Because of that, I created the issue to investigate further and have a discussion around it. I’m not fully clear on how this PR addresses the issue, especially since it could not be reproduced in a local environment. Also, as @SameerMesiah97 asked earlier, could you please confirm whether the author of the PR was able to reproduce the issue before working on the fix? I don’t think there was a response to that question earlier. |
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.
Fixes #66437
What does this PR do?
When
SparkKubernetesOperatorwas used withdeferrable=True, after callingexecute_async(context)there was noreturnstatement, so execution fellthrough to
super().execute(context)(i.e.KubernetesPodOperator.execute()).That path attempted to create a bare Kubernetes Pod with no container image,
producing a 422 Unprocessable Entity error from the API even though the
SparkApplication CR had already been submitted successfully.
Root cause
SparkKubernetesOperator.execute()calledself.execute_async(context)in thedeferrable=Truebranch but had noreturnafter it, causing fall-through toreturn super().execute(context).Fix
Added a single
returnstatement immediately afterself.execute_async(context)in the
if self.deferrable:branch. The non-deferrable path is unchanged.Tests
test_deferrable_does_not_fall_through_to_kpo_execute: asserts that withdeferrable=True,execute_asyncis called andKubernetesPodOperator.executeis never called.
test_non_deferrable_calls_kpo_execute: asserts that withdeferrable=False,KubernetesPodOperator.executeis still called as before.Tests added
Newsfragment added (
providers/cncf/kubernetes/newsfragments/66437.bugfix.rst)Closes SparkKubernetesOperator with deferrable=True falls through to KubernetesPodOperator.execute() creating a spurious pod #66437