ThirdPartyResources / API: Failure on POST with YAML #37455
Description
Is this a BUG REPORT or FEATURE REQUEST?: Bug Report.
Kubernetes version (use kubectl version
):
Client Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.5", GitCommit:"5a0a696437ad35c133c0c8493f7e9d22b0f9b81b", GitTreeState:"clean", BuildDate:"2016-10-29T01:38:40Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.5+coreos.0", GitCommit:"f70c2e5b2944cb5d622621a706bdec3d8a5a9c5e", GitTreeState:"clean", BuildDate:"2016-10-31T19:16:47Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
What happened:
Occurs only with third-party resources:
$ curl --silent -H "Content-Type: application/yaml" -XPOST -d"$(cat manifest.yaml)" "http://127.0.0.1:8080/apis/<third_party_domain>/v1/namespaces/<namespace>/<third_party_resource_type>"
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the object provided is unrecognized (must be of type ThirdPartyResourceData): invalid character 'a' looking for beginning of value (61706956657273696f6e3a20746563746f6e69632d76657273696f6e2e74 ...)",
"reason": "BadRequest",
"code": 400
}
The 'a' being the first letter of the manifest (stands for apiVersion
). Changing it modifies the returned error.
However, it works just fine after conversion from YAML to JSON of the object:
$ curl --silent -H "Content-Type: application/json" -XPOST -d"$(cat manifest.json)" "http://127.0.0.1:8080/apis/<third_party_domain>/v1/namespaces/<namespace>/<third_party_resource_type>"
Of course, when passing an invalid format, the API Server answers that both JSON and YAML are supported:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the body of the request was in an unknown format - accepted media types include: application/json, application/yaml",
"reason": "UnsupportedMediaType",
"code": 415
}
It also works wonderfully using kubectl create -f manifest.yaml
because the YAML manifest is converted client-side to JSON before calling out to the API server.
What you expected to happen:
The adequate serializer should have been selected and should have converted the object server-side, as specified by the Content-Type
header.