Skip to content

Return typed models from Python DELETE methods - #2763

Open
tamird wants to merge 1 commit into
kubernetes-client:masterfrom
tamird:python-typed-delete-results
Open

tamird wants to merge 1 commit into
kubernetes-client:masterfrom
tamird:python-typed-delete-results

Conversation

@tamird

@tamird tamird commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug
/kind api-change

What this PR does / why we need it:

Deleting a ConfigMap can return either the ConfigMap or a Kubernetes Status. Today both come back as dictionaries. Deleting a Pod has a different failure: a successful Status response can raise a validation error because the client tries to read it as a Pod.

Regenerate the synchronous and asyncio clients so individual built-in DELETEs return the model the server actually sent. For example, delete_namespaced_config_map() returns V1ConfigMap | V1Status:

result = api.delete_namespaced_config_map(name, namespace)
if isinstance(result, client.V1Status):
    print(result.message)
else:
    print(result.metadata.name)

For _with_http_info, the model is the first item in the synchronous client’s (data, status, headers) tuple and the .data field of the asyncio response. Collection deletes and generic custom-object methods keep their existing behavior.

Which issue(s) this PR fixes:

Fixes #2752

Special notes for your reviewer:

Depends on kubernetes-client/gen#313, where the generator change lives. The OpenAPI v3 migration plan preserves the return types shown here.

Does this PR introduce a user-facing change?

action required: Individual built-in DELETE methods now return the deleted resource model or V1Status. If you read these responses as dictionaries, switch to model attributes and use isinstance(result, V1Status) to distinguish a Status from the resource. For _with_http_info methods, read the model from the first tuple item in the synchronous client or from response.data in the asyncio client.

Prepared with Codex assistance.

Deleting a ConfigMap returned a dictionary, while deleting a Pod
rejected a successful Status response as an invalid Pod [1].

Regenerate the synchronous and asyncio clients to return the deleted
resource or V1Status according to the response's apiVersion and kind.
Reject a response that identifies neither model. Callers that consumed
dictionaries must now read model attributes, for example result.status
in place of result.get("status").

[1]: kubernetes-client#2752
@kubernetes-prow kubernetes-prow Bot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. kind/bug Categorizes issue or PR as related to a bug. labels Oct 28, 2026
@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 assign roycaihw for approval. 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 added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Oct 28, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog October 28, 2026 21:04
@kubernetes-prow kubernetes-prow Bot added 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 Oct 28, 2026
@tamird

tamird commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog, #2664 told 37.x callers to use dictionary access. Would you be comfortable switching these methods to return models in the next major release?

@tomplus, does returning a V1ConfigMap or V1Status directly from await api.delete_namespaced_config_map(...) work for asyncio callers?

— with Codex assistance

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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. 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.

Resolve inconsistent typing in 37.0.0 delete operations

1 participant