Skip to content

Conversation

@amoghrajesh
Copy link
Contributor

To make ResourceVersion a singleton, it doesn't have to import Singleton from utils. Using the __new__ pattern instead. Guidance from here: https://www.geeksforgeeks.org/python/singleton-pattern-in-python-a-complete-guide/

I will deprecate the singleton library from utils in a parallel PR.

Test to verify that it works fine before and after:

from airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils import ResourceVersion
rv1 = ResourceVersion()
rv2 = ResourceVersion()
rv3 = ResourceVersion()
rv1 == rv2 == rv3
Out[3]: True
rv1.resource_version["namespace1"] = "12345"
rv2.resource_version["namespace1"] == "12345"
rv3.resource_version["namespace1"] == "12345"
Out[4]: True
import gc
instances = [obj for obj in gc.get_objects()
             if type(obj).__name__ == 'ResourceVersion']
instances
Out[6]: [<airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.ResourceVersion at 0x1119ea3c0>]

^ 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.

@boring-cyborg boring-cyborg bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues labels Jan 9, 2026
@amoghrajesh amoghrajesh requested review from ashb, kaxil and potiuk January 9, 2026 13:22
@amoghrajesh amoghrajesh self-assigned this Jan 9, 2026
@amoghrajesh amoghrajesh merged commit f4d681c into apache:main Jan 9, 2026
104 checks passed
@amoghrajesh amoghrajesh deleted the get-rid-of-singleton-ke branch January 9, 2026 14:42
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.

2 participants