Skip to content

Regenerate Python clients with shared legacy model helpers - #2762

Open
Abhinav0905 wants to merge 1 commit into
kubernetes-client:masterfrom
Abhinav0905:agent/share-legacy-model-helpers
Open

Abhinav0905 wants to merge 1 commit into
kubernetes-client:masterfrom
Abhinav0905:agent/share-legacy-model-helpers

Conversation

@Abhinav0905

@Abhinav0905 Abhinav0905 commented Oct 27, 2026 •

Copy link
Copy Markdown

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Regenerates the synchronous and asyncio Python clients with the OpenAPI Generator v7.27.0 release. It contains the shared legacy model helpers from OpenAPITools/openapi-generator#24730.

  • The generator pin is in kubernetes-client/gen#315. No pin changes remain in this repo's scripts/constants.py, scripts/update-client.sh or scripts/update-client-asyncio.sh.
  • Both clients use the checked-in scripts/swagger.json and the existing package version. The regenerated code replaces 1,690 helper copies with two private modules. An AST comparison found no other changes in the 845 model classes per client.
  • The base includes rest: send Content-Type application/json for JSON bodies #2783. Its JSON Content-Type patch, the sync retry patch and keepalive patch apply unchanged. The async retry patch only needs extra context for the CIMultiDict import. Two REST test assertions now check the outgoing header and caller input rather than the identity of the header dict. rest: send Content-Type application/json for JSON bodies #2783's wire-level tests are unchanged.

Which issue(s) this PR is related to:

Related to #2677. This removes duplicate conversion helpers, not the separate sync and async clients. The upstream-first approach was agreed in #2677.

Special notes for your reviewer:

The v7.27.0 generator adds case-insensitive header handling and query serialization changes. Those changes are separate from model helper extraction and explain the generated API and transport diff. Generation used the published Maven plugin and python.xml / python-aio.xml from gen, then ran postprocess_python.py and reapplied the Kubernetes patches. The schema was not fetched or changed.

Measured against 2ea2c0a4fcf8206d71bd46b21806a32fb769e15a with CPython 3.12.14, setuptools 84.2.1 and wheel 0.48.0:

Measurement Before (bytes) After (bytes)
Compressed release wheel 7,529,782 6,692,336
Packaged Python source 73,698,736 70,227,635
Installed files plus bytecode 116,766,335 110,485,809

The compressed wheel is 11.12% smaller. To repeat, run python devel/measure-package-size.py /path/to/checkout against clean checkouts with the same Python and build tools.

Validation:

  • python -m pytest -q kubernetes/utils/rest_test.py kubernetes/test/test_legacy_model_helpers.py: 24 passed, including the JSON Content-Type wire tests.
  • Broader local run: 543 passed, 1 skipped, 270 subtests passed. The two end-to-end directories and 27 cluster-dependent dynamic-client cases were excluded. Live-cluster behavior was not tested.
  • git diff --check passed.

Does this PR introduce a user-facing change?

Reduce duplicated legacy model conversion helpers in the synchronous and asyncio Python clients, reducing package source, wheel and bytecode sizes.

AI usage disclosure:

AI assisted with regeneration setup, test changes, local verification and the PR description. The checked-in clients were produced by the tagged OpenAPI Generator release.

@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Oct 27, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Abhinav0905 / name: Kumar Abhinav (58b1868)

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @Abhinav0905!

It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 27, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog October 27, 2026 20:06
@kubernetes-prow kubernetes-prow Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 27, 2026
@yliaog

yliaog commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

/assign

@Abhinav0905

Copy link
Copy Markdown
Author

I audited the regeneration against base 774884d, with particular attention to the generator-version changes outside the shared-helper extraction.

  • All 1,690 generated model files differ only by replacing the duplicated helper bodies with imports from the two shared modules.
  • The 132 generated API files differ only in case-insensitive header merge/default handling. Sync uses HTTPHeaderDict and asyncio uses CIMultiDict; the existing later-source precedence is retained, while differently cased duplicates now collapse correctly.
  • The generic query serializer now quotes runtime keys and applies collection formats only to list/tuple values. No generated Kubernetes endpoint calls the new object-explode helper, and the existing fixed query names are unchanged.

So normal model and request serialization remain compatible. The behavior change is limited to correcting duplicate differently cased headers and malformed/internal query-helper inputs.

kolli-karthik-accenture pushed a commit to kolli-karthik-accenture/bounded that referenced this pull request Nov 22, 2026
kubernetes-client/python#2786 - fix(stream): handle tuple _request_timeout
  - 3 files, score: 77/100, 2 critical issues

kubernetes-client/python#2762 - Regenerate Python clients with shared legacy
  - 30 files, score: 77/100, 13 critical issues

kubernetes-client/python#2698 - Support _request_timeout in dynamic client
  - 2 files, score: 66/100, clean code

BaaRai/ARTEX#494 - fix(server): do not return database errors
  - 2 files, score: 68/100, 1 security issue

torvalds/GuitarPedal#60 - WebMIDI: keep queued BLE writes
  - 2 files, score: 77/100, clean code
@Abhinav0905

Copy link
Copy Markdown
Author

Hi @yliaog, could you take a look at the client regeneration when you have a chance? All eight build checks passed. I'd especially appreciate a second look at the header and query-serialization changes called out in the compatibility audit. Thanks!

@yliaog

yliaog commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

thanks for the PR

Please bump OPENAPI_GENERATOR_COMMIT in kubernetes-client/gen (openapi/python.sh and openapi/python-aio.sh) to a tagged release (v7.27.0 or v7.28.0).

Drop the OPENAPI_GENERATOR_COMMIT changes from scripts/constants.py, scripts/update-client.sh, and scripts/update-client-asyncio.sh, rebase onto current master (so recent rest.py / patch updates like #2783 stay intact), and regenerate from the tagged release.

@Abhinav0905
Abhinav0905 force-pushed the agent/share-legacy-model-helpers branch from 58b1868 to c7d77fb Compare November 30, 2026 01:56
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Abhinav0905
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

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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