Skip to content

Regenerate the asyncio client with dependency-free lazy imports - #2647

Merged
kubernetes-prow[bot] merged 8 commits into
kubernetes-client:masterfrom
tamird:prototype/modern-asyncio-generator
Jul 28, 2026
Merged

Regenerate the asyncio client with dependency-free lazy imports#2647
kubernetes-prow[bot] merged 8 commits into
kubernetes-client:masterfrom
tamird:prototype/modern-asyncio-generator

Conversation

@tamird

@tamird tamird commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Regenerate kubernetes.aio with the OpenAPI Generator v7 aiohttp backend and dependency-free Python templates from OpenAPITools/openapi-generator#24402. The asynchronous and synchronous client implementations remain independent.

Apply Kubernetes authentication, TLS, watch, WebSocket, and PATCH adaptations in the generator-owned postprocessing from kubernetes-client/gen#306, and remove twelve obsolete downstream patches for the v6 client.

The generated metadata records 7.25.0-SNAPSHOT; v7.24.0 is the latest published release: https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.24.0. The remaining prerequisite is merging the generator change so this client can be reproduced from upstream.

/kind feature

Regenerate the asynchronous Kubernetes Python client with dependency-free lazy imports.

@kubernetes-prow kubernetes-prow Bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 23, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog July 23, 2026 00:39
@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 23, 2026
@tamird

tamird commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

/kind feature

— tamirdex

@kubernetes-prow kubernetes-prow Bot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jul 23, 2026
@tamird

tamird commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

/assign @yliaog

@tamird

tamird commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog The Job-deletion end-to-end failure is fixed at its generator source in kubernetes-client/gen#306, which builds on the synchronous foundation in kubernetes-client/gen#305, and regenerated in a07ca37. Validation is green for Python 3.10–3.14 on that exact head: https://github.com/tamird/kubernetes-python/actions/runs/29979418887.

The upstream validation and real-cluster end-to-end workflows cannot start until a repository maintainer approves the fork runs: https://github.com/kubernetes-client/python/actions/runs/29979421215 and https://github.com/kubernetes-client/python/actions/runs/29979421210. Could you approve them? The upstream end-to-end suite has not yet run on the corrected head.

— tamirdex

@tamird tamird changed the title Regenerate the asyncio client with the modern Python generator Regenerate the asyncio client with dependency-free lazy imports Jul 27, 2026
tamird added 8 commits July 27, 2026 21:41
Python 3.10 raises TypeError when inspecting AsyncMock, preventing asynchronous Watch from falling back to the documented resource type. Treat unsupported signatures like missing annotations and add a regression covering the affected callable.
Autospec a real asynchronous API operation so watch tests expose the same inspectable callable signature as generated clients. Model aiohttp response close and release as synchronous methods, and restore direct return-type inspection without test-specific production behavior.
Kubernetes may return the deleted resource or Status for the same successful delete. Regenerate the asyncio APIs and their documentation from the corrected Swagger contract, including a real-HTTP Job deletion regression.
Generate the synchronous APIs and documentation from the same corrected Kubernetes deletion contract as the asyncio client. Cover deleted Job responses with a real-HTTP regression.
Update the canonical Kubernetes Swagger to describe individual deletion responses consistently with the regenerated synchronous and asyncio clients. Collection deletes and accurately typed resource responses remain unchanged.
@tamird
tamird force-pushed the prototype/modern-asyncio-generator branch from 86dab51 to 55ea200 Compare July 28, 2026 02:50
@tamird

tamird commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog I rebased 55ea200 onto the now-merged #2652, so the asyncio client inherits the dependency-free synchronous generator, urllib3 security floor, and generator source recorded in kubernetes-client/gen#306. The asyncio output is unchanged; this is the existing eight-commit change on the current master. Fresh validation and end-to-end checks must run on this new head; successful checks on the previous head do not establish its result.

[tamirdex]

@yliaog

yliaog commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

the PR description: "#2652 must land first because importing kubernetes.aio initializes the synchronous client."

why is that? async client and sync client should be independent

@tamird

tamird commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog The clients are independent. The sentence refers to Python package initialization: importing kubernetes.aio first executes kubernetes/__init__.py, which eagerly imports the synchronous client:

from . import client
from . import config
from . import dynamic
from . import watch
from . import stream
from . import utils
from . import leaderelection
from . import informer
. The asyncio package itself imports only kubernetes.aio modules:
import kubernetes.aio.client as client
import kubernetes.aio.config as config
import kubernetes.aio.dynamic as dynamic
import kubernetes.aio.stream as stream
import kubernetes.aio.utils as utils
import kubernetes.aio.watch as watch
__all__ = ["client", "config", "dynamic", "stream", "utils", "watch"]
.

The synchronous change has already merged, this branch is rebased onto it, and both validation and end-to-end checks now pass. My wording incorrectly made parent-package initialization sound like a dependency between the clients.

[tamirdex]

@yliaog

yliaog commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

the import latency is on par

$ git checkout master
Switched to branch 'master'

$ time python -c 'import kubernetes.aio.client; print(kubernetes.aio.client.file)'
/usr/local/google/home/yliao/prj/client-python/kubernetes/aio/client/init.py

real 0m1.326s
user 0m1.033s
sys 0m0.318s

$ git checkout pr-2647
$ time python -c 'import kubernetes.aio.client; print(kubernetes.aio.client.file)'
/usr/local/google/home/yliao/prj/client-python/kubernetes/aio/client/init.py

real 0m1.105s
user 0m0.914s
sys 0m0.212s

@yliaog

yliaog commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

thanks for the PR

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 28, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tamird, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 28, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit c01426a into kubernetes-client:master Jul 28, 2026
10 checks passed
@tamird
tamird deleted the prototype/modern-asyncio-generator branch July 28, 2026 22:06
@tamird

tamird commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog thanks for merging! Just a reminder to merge kubernetes-client/gen#306 so everything is consistent!

@yliaog

yliaog commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Sure, approved kubernetes-client/gen#306

1c5984c can be reverted then, could you revert it?

@tamird

tamird commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog Done. #2656 reverts 1c5984c and restores the synchronous V1Status signatures and documentation. The merged asynchronous client and its broader deletion handling are unchanged.

[tamirdex]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants