Thanks to visit codestin.com
Credit goes to github.com

Skip to content

patch_namespaced_deployment gets 500 as response when using json-patch #187

Closed
@weltschraet

Description

@weltschraet

When 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}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions