-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when patching using patch_namespaced_custom_object() #1216
Comments
/assign |
cc @yliaog |
In the following CRD spec, the kind: is 'Test' with uppercase 'T', could you trying switching it to lowercase, and see if you still see the same errors? ==================== |
Hi @yliaog , I have followed your advice and tried with a lowercase 'test' in in 'kind' but it is failing with the same issue. |
I think only merge patch is supported by the library [0]. [0] https://github.com/kubernetes-client/python/blob/b5603d8ee2/kubernetes/client/api/custom_objects_api.py#L2408 |
Thanks @doude, I can see from the gen PR that "application/json-patch+json" was added but I can't see that a relevant change was made in this repository (mainly select_header_content_type() being able to add the new Content-Type header to the request. Closing this as it is not an error, it is just unsupported. |
If someone needs a solution, you could make this monkey patch of Kubernetes client. class ApiClientForJsonPatch(client.ApiClient):
def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, async_req=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None):
header_params['Content-Type'] = self.select_header_content_type(['application/json-patch+json'])
return super().call_api(resource_path, method, path_params, query_params, header_params, body,
post_params, files, response_type, auth_settings, async_req, _return_http_data_only,
collection_formats, _preload_content, _request_timeout) Then use |
In case anyone else is still running into this... I just dealt with this same problem. As a workaround, I had to call:
before This, along with passing the This was with kubernetes==24.2.0 |
What happened (please include outputs or screenshots):
Hi, I am unable to patch a custom resource using patch_namespaced_custom_object(). I receive the error:
What you expected to happen:
For the patch to be applied successfully.
How to reproduce it (as minimally and precisely as possible):
Create a basic CRD:
Create a resource to test against:
Run the following Python to try and change
exampleField
:Anything else we need to know?:
The JSON patch works fine if applied using kubectl:
Environment:
kubectl version
):python --version
): Python 3.8.2pip list | grep kubernetes
): kubernetes 11.0.0The text was updated successfully, but these errors were encountered: