patch_namespaced_deployment gets 500 as response when using json-patch
See original GitHub issueWhen using a RFC6902 formatted json-patch you get a 500 response. The hack for the issue #93 introduced this bug. Are there any plans to get rid of the hack?
To repoduce the problem the following can be done:
create the deployment with kubectl
kubectl run nginx --image=nginx:1.11.12
try to patch it
from kubernetes import client, config
config.load_kube_config()
client.configuration.debug = True
v1 = client.ExtensionsV1beta1Api()
patch = [{"op": "replace", "value": "nginx:1.11.13", "path": "/spec/template/spec/containers/0/image"}]
v1.patch_namespaced_deployment(name='nginx', namespace='default', body=patch)
log output
DEBUG Starting new HTTPS connection (1): xxx
send: b'PATCH /apis/extensions/v1beta1/namespaces/default/deployments/nginx HTTP/1.1\r\nHost: xxx\r\nAccept-Encoding: identity\r\nContent-Length: 95\r\nAccept: application/json\r\nContent-Type: application/strategic-merge-patch+json\r\nUser-Agent: Swagger-Codegen/1.0.0-alpha/python\r\nauthorization: Bearer xxx\r\n\r\n'
send: b'[{"op": "replace", "value": "nginx:1.11.13", "path": "/spec/template/spec/containers/0/image"}]'
reply: 'HTTP/1.1 500 Internal Server Error\r\n'
DEBUG https://xxx:443 "PATCH /apis/extensions/v1beta1/namespaces/default/deployments/nginx HTTP/1.1" 500 114
header: Content-Type header: Date header: Content-Length Traceback (most recent call last):
File "api_test.py", line 25, in <module>
main()
File "api_test.py", line 21, in main
print(v1.patch_namespaced_deployment(name='nginx', namespace='default', body=patch_test))
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/extensions_v1beta1_api.py", line 5400, in patch_namespaced_deployment
(data) = self.patch_namespaced_deployment_with_http_info(name, namespace, body, **kwargs)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/extensions_v1beta1_api.py", line 5496, in patch_namespaced_deployment_with_http_info
collection_formats=collection_formats)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 329, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 153, in __call_api
_request_timeout=_request_timeout)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 399, in request
body=body)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/rest.py", line 295, in PATCH
body=body)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/rest.py", line 231, in request
raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Fri, 21 Apr 2017 12:05:35 GMT', 'Content-Length': '114'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Invalid JSON document","code":500}
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
ExtensionsV1beta1Api.patchNamespacedDeployment throws ...
patchNamespacedDeployment throws 500 Internal server error ... type as application/json-patch+json (in postman rest client) , getting ...
Read more >500 Internal Server Error on PATCH request - Squidex Support
Hi Sebastian, thank you for the quick reply. Could you please confirm which encoding format is expected from Squidex? Would it be possible...
Read more >Error while applying JSON Patch to Kubernetes Custom ...
foo to exist and to be of type string . The request above is declined by the Kubernetes API server with the following...
Read more >JsonPatch in ASP.NET Core web API - Microsoft Learn
To add support for JSON Patch using Newtonsoft.Json , while leaving the other ... With this option, you can get error messages in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mbohlool I made a plan b to scale deployment, which as below:
body['spec']['replicas'] = desired_replicas
.replace_namespaced_deployment(name, namespace, body)
.@mbohlool : ack, i’ll try to find a way to multiple ways to specify the patch request body https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#patch-operations