Skip to content

Conversation

@Ferdinanddb
Copy link
Contributor

@Ferdinanddb Ferdinanddb commented Nov 24, 2025

  • Cache the launcher object used to create and delete Kubernetes objects related to Spark.
  • Minor changes on how to retrieve the Kubernetes resource name associated to the Spark job.
  • Add unit tests.

closes: #58228
related: #56291

This PR should fix the issues mentioned above by caching the launcher object being used to create and delete Kubernetes objects. Without this PR:

  • If the worker pod gets killed and the parameter reattach_on_restart=True is set, the self.launcher is never instantiated and so the error mentioned in the issues is raised.
  • When deferrable=True, the worker pod might get deleted while the job is deferred, and when the worker pod is used again to handle the deletion of the pod at the end, then the error mentioned in the issues is raised because the self.launcher is never instantiated.

^ 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.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

…hange to improve how pod name is retrieved in spark_kubernetes.py, add unit tests
@boring-cyborg boring-cyborg bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues labels Nov 24, 2025
Copy link
Contributor

@Nataneljpwd Nataneljpwd left a comment

Choose a reason for hiding this comment

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

Minor nitpicks, other than that seems good!

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, looks good to me!

@jscheffl jscheffl changed the title fix(cncf-kubernetes): make the launcher a cached_property and minor c… Make the launcher a cached_property and minor change to improve how pod name is retrieved Nov 29, 2025
@jscheffl
Copy link
Contributor

Adjusted title for better changelog, we do not use conventional commits.

@jscheffl jscheffl merged commit d409ba9 into apache:main Nov 29, 2025
94 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 29, 2025

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

RoyLee1224 pushed a commit to RoyLee1224/airflow that referenced this pull request Dec 3, 2025
…od name is retrieved (apache#58646)

* fix(cncf-kubernetes): make the launcher a cached_property and minor change to improve how pod name is retrieved in spark_kubernetes.py, add unit tests

* chore: use removesuffix to set self.name and job_name variables as suggested by @Nataneljpwd
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
…od name is retrieved (apache#58646)

* fix(cncf-kubernetes): make the launcher a cached_property and minor change to improve how pod name is retrieved in spark_kubernetes.py, add unit tests

* chore: use removesuffix to set self.name and job_name variables as suggested by @Nataneljpwd
itayweb pushed a commit to itayweb/airflow that referenced this pull request Dec 6, 2025
…od name is retrieved (apache#58646)

* fix(cncf-kubernetes): make the launcher a cached_property and minor change to improve how pod name is retrieved in spark_kubernetes.py, add unit tests

* chore: use removesuffix to set self.name and job_name variables as suggested by @Nataneljpwd
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 (k8s) provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SparkKubernetesOperator error related to self.launcher

3 participants