Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Patch subresources via separate API endpoints #54

Merged
merged 2 commits into from
Mar 29, 2020

Conversation

nolar
Copy link

@nolar nolar commented Mar 19, 2020

Kubernetes resources are now advised to have status & replica as sub-resources — especially since Kubernetes 1.16.

This requires separate PATCH requests to separate endpoints, instead of passing the status as part of the main payload of the PATCH request on the resource's body — it is just ignored there (i.e. not applied to the resource).

With this PR, a kwarg named subresource= is added to the object's .patch() method. The default is to use the resource' main body, unless explicitly said to patch the sub-resource.

A better way would be to internally analyse the CRD's declaration, and whether some subresources are declared separately or not, and to modify the patching method to send separate API requests if the relevant sub-fields are present in the patch's body. Thos way is much more complex, and potentially implies unexpected heuristic in the API client.

The explicit way seems more straightforward — leaving the decision on what and how to patch to the developers, who also declare their CRDs with/without sub-resources.


For reference, the Kubernetes client implements this as separate patching methods: v1api. patch_namespaced_pod_status() instead of v1api. patch_namespaced_pod() (link)

@hjacobs hjacobs merged commit ac24ce3 into hjacobs:master Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants