Skip to content

Regenerate the synchronous client with the modern Python generator#2631

Open
tamird wants to merge 1 commit into
kubernetes-client:masterfrom
tamird:prototype/modern-openapi-generator
Open

Regenerate the synchronous client with the modern Python generator#2631
tamird wants to merge 1 commit into
kubernetes-client:masterfrom
tamird:prototype/modern-openapi-generator

Conversation

@tamird

@tamird tamird commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

The synchronous client is still generated with OpenAPI Generator 6.6's
python-legacy backend. OpenAPI Generator removed that backend in v7,
so the current generation path cannot move to a supported generator or
inherit the modern Python generator's native type information.

This PR moves the synchronous client to the modern python backend:

  • regenerate the client and Sphinx API index with Pydantic models and
    modern generated type information;
  • declare the generated runtime requirements and package py.typed;
  • adapt dynamic, stream, watch, OIDC, YAML, and example helpers to the
    modern generated API; and
  • remove obsolete post-generation hotfixes while retaining the small
    body-aware PATCH media-type correction.

Which issue(s) this PR fixes:

No single tracked issue. The regeneration fixes existing urllib
compatibility, typing, and bytes-handling gaps in the synchronous
client.

Special notes for your reviewer:

The paired generator migration is
kubernetes-client/gen#305. It selects the
released OpenAPI Generator v7.24.0, which contains the required legacy
compatibility and API-key-prefix fixes. The generated provenance records
the release tag and resolved commit 203d4867.

This changes synchronous generation only. The async client remains on
its existing generator path and should be regenerated separately; until
then, six remains an async requirement.

Legacy async_req=True still returns an ApplyResult consumed with
.get(), and _preload_content=False returns the raw response.
Ordinary return annotations intentionally describe the default call:
Watch reflects them to select event models. The generator rationale is
OpenAPITools/openapi-generator#24300.

The initial release render was produced by the normal
scripts/update-client.sh Docker path in
https://github.com/tamird/kubernetes-python/actions/runs/29785873376.
Until the paired generator PR merges, reproduce it with that generator
branch checked out locally:

GEN_ROOT=/path/to/kubernetes-client-gen scripts/update-client.sh

The previously published generated head passes the fork's Python
3.10-3.14 lint and test matrix:
https://github.com/tamird/kubernetes-python/actions/runs/29790431747.

Does this PR introduce a user-facing change?

The synchronous Python client is regenerated with the modern OpenAPI
Generator Python backend.

Additional documentation:


@kubernetes-prow kubernetes-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 14, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from fabianvf and roycaihw July 14, 2026 00:51
@kubernetes-prow kubernetes-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 14, 2026
@penguinolog

penguinolog commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

technically ton of (urllib compatibility, typing, several broken places with bytes processing)

Comment thread requirements.txt Outdated
@@ -1,10 +1,12 @@
certifi>=14.05.14 # MPL
six>=1.9.0 # MIT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

six is needed only for async after merge. Regenerate too as next PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. This draft intentionally migrates only synchronous generation; async should be regenerated separately. setup.py reads requirements.txt, while the release package adds requirements-asyncio.txt, so I removed six from the synchronous requirements and left its async declaration in place.

@tamird

tamird commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Right; this is not tied to one tracked issue. I updated that section to name the urllib compatibility, typing, and bytes-handling gaps instead of saying None.

Comment thread kubernetes/.openapi-generator/VERSION Outdated
@@ -1 +1 @@
6.6.0 No newline at end of file
7.24.0-SNAPSHOT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's not released, IMHO released version should be used instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's why this is a draft. It requires some changed that are not yet released.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The three prerequisite generator fixes have merged, but they are not released yet. I updated the draft description to make that boundary explicit: this stays inspection-only until client-gen can pin the first released version containing them and regenerate canonically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. OpenAPI Generator v7.24.0 is released and contains the required compatibility fixes. I regenerated this branch from the release via kubernetes-client/gen#305; the checked-in VERSION is now 7.24.0 and the resolved generator commit is 203d4867. The canonical Docker render is https://github.com/tamird/kubernetes-python/actions/runs/29785873376.

@tamird
tamird force-pushed the prototype/modern-openapi-generator branch from 77e286b to 6bc343e Compare July 15, 2026 23:26
@roycaihw

Copy link
Copy Markdown
Member

/assign @yliaog

@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 16, 2026
@tamird
tamird force-pushed the prototype/modern-openapi-generator branch from 6bc343e to c248094 Compare July 16, 2026 23:48
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tamird
Once this PR has been reviewed and has the lgtm label, please ask for approval from yliaog. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 17, 2026
@tamird
tamird marked this pull request as ready for review July 21, 2026 00:14
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 21, 2026
@tamird
tamird force-pushed the prototype/modern-openapi-generator branch from 2edde6c to af93dd7 Compare July 21, 2026 00:29
OpenAPI Generator v7 removed python-legacy, preventing the synchronous
Kubernetes client from moving beyond v6.6.0 and inheriting the modern
Python generator's native type information.

Regenerate with the released v7.24.0 Python generator, declare its
runtime requirements, package py.typed, and refresh the Sphinx API
index. Adapt dynamic, stream, watch, OIDC, YAML, leader-election, and
example callers to the modern transport and legacy-compatible response
behavior.

Remove obsolete post-generation hotfixes while retaining the small REST
correction that selects strategic merge for built-in object patches and
JSON Patch for operation lists. Cover those media types and asynchronous
YAML creation with request-level compatibility tests.
@tamird
tamird force-pushed the prototype/modern-openapi-generator branch from af93dd7 to 325ae7c Compare July 21, 2026 16:57
@yliaog

yliaog commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@tamird thanks for the PR, do you know whether the import latency issue reported in tomplus/kubernetes_asyncio#293 is resolved with the new openapi generator?

@yliaog

yliaog commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

could you also please take a look at the failure tests? https://github.com/kubernetes-client/python/actions/runs/29850863235/job/88758260386?pr=2631

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

Labels

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

4 participants