-
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
Unsupported Media Type (HTTP 415) when patching custom resources #866
Comments
Found the root cause: With 9.0.0, the type was The return content_types[0] The CustomObjectsApi feeds it with these 2 content-types: header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json-patch+json', 'application/merge-patch+json']) Previously (in 9.0.0), it was one: header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/merge-patch+json']) This happened because of 9c8bd4a. And so, the default content type has suddenly changed since 9.0 to 10.0.0. The Kubernetes API doesn't like it, because [
{ "op": "add", "path": "/myPath", "value": ["myValue"] }
] However, the content data sent by the users all over the world was not changed, and most likely remains a dict as per PS: With |
/assign |
Thanks for the detailed bug report. I see the kube-apiserver supports both JSON patch and JSON merge patch as content types for patching custom resources. The problem is I think we should do two things:
|
…N merge patch is used by default
…N merge patch is used by default
fixed in 10.0.1 /close |
@roycaihw: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
which version is this fix in? I still get the same problem when patching profiles. Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.3" Any idea why I'm still seeing it? |
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [kubernetes-client#866](kubernetes-client#866) - [kubernetes-client#959](kubernetes-client#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
This would be great! Until this is implemented and for everybody coming here in search for a way to apply a JSON patch to a custom resource with |
Reading this issue, I still don't understand what needs done to actually use this ;) I'm calling the following code with version 19.15.0 of the python bindings.
However, I receive the following error:
|
For future readers, the body is a JSON patch which is described here. In particular, it took me a while to figure out how to add an annotation with a body = [
{
"op": "add",
# '~1' is an escaped '/'
# See https://jsonpatch.com/#json-pointer for escaping rules
"path": "/metadata/annotations/myproject.io~1archive-name",
"value": archive.metadata.name,
}
] |
Reference: - [#866](kubernetes-client/python#866) - [#959](kubernetes-client/python#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Reference: - [#866](kubernetes-client/python#866) - [#959](kubernetes-client/python#959) Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
Actual behaviour
v10.0.0 was released this night. Since then, custom resource patching is broken:
HTTP 415 "Unsupported Media Type" when patching the custom resources.
When tracing step by step, the actual Content-Type used is
application/json-patch+json
, which should match the supported types from the error message.There is no way to control Content-Type from the user side, i.e. when calling the patch-method.
Expected behaviour
Patching works smoothly.
It all works fine if installed as
pip install 'kubernetes<10.0.0'
Steps to reproduce:
Any other CRD should show the same behaviour (probably); this one is just for a quick example.
Then a Python script:
Any
body
content cause the same error, event the empty body — so, I guess, it is not about the patch-content itself.Versions
Kubernetes: 1.15.0
kubernetes==10.0.0
Python 3.7
Notes
Might be related:
merge-patch+json
patch type #862The text was updated successfully, but these errors were encountered: