-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
sample-apiserver returns 200 with error marshalling protobuf response #50342
Comments
/sig api-machinery |
I expect that's a shortcoming of the example server, not the aggregator itself |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
Hello, I'd like to take a look into this as my first contribution. |
/assign @tristanburgess |
@cheftako: GitHub didn't allow me to assign the following users: tristanburgess. Note that only kubernetes members and repo collaborators can be assigned. 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. |
Looking into this so far, I'm able to reproduce the issue, and also that using
There are potentially two separate considerations out of this as far as I can tell (in addition to the original issue):
In terms of the actual status code we want to return, would
|
Pertaining to 2), JSON serialization appears to be baked in to the API as the default, so there really isn't a similar |
For 1), .proto definitions definitely weren't created for the extension API resource types. I generated them and confirmed that API response was successful after that. I'll file a separate ticket/PR for the addition to the sample APIs after this issue is fixed.
|
I had a starting implementation that successfully returned a 406 on protobuf marshalling definition not implemented ( There's an order of operations issue which is preventing http status code from being handled properly with both serialization encode success and serialization encode failure between apiserver and apimachinery.
In The problem in The specific case of encode failing can be resolved by calling The catch is, this change would now cause successful encode to return the wrong status code, because our The solution here is likely to move header modifications closer to Two questions I'm currently weighing are:
|
…andling_refinement_for_serialization_encode Automatic merge from submit-queue (batch tested with PRs 67041, 66948). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. 50342: Establish '406 Not Acceptable' response for protobuf serializa… …tion 'errNotMarshalable' - Added metav1.Status() that enforces '406 Not Acceptable' response if protobuf serialization is not fully supported for the API resource type. - JSON and YAML serialization are supposed to be more completely baked in, so serialization involving those, and general errors with seralizing protobuf, will return '500 Internal Server Error'. - If serialization failure occurs and original HTTP status code is error, use the original status code, else use the serialization failure status code. - Write encoded API responses to intermediate buffer - Use apimachinery/runtime::Encode() instead of apimachinery/runtime/protocol::Encode() in apiserver/endpoints/handlers/responsewriters/writers::SerializeObject() - This allows for intended encoder error handling to fully work, facilitated by apiserver/endpoints/handlers/responsewriters/status::ErrorToAPIResponse() before officially writing to the http.ResponseWriter - The specific part that wasn't working by ErrorToAPIResponse() was the HTTP status code set. A direct call to http.ResponseWriter::WriteHeader(statusCode) was made in SerializeObject() with the original response status code, before performing the encode. Once this method is called, it can not again update the status code at a later time, with say, an erro status code due to encode failure. - Updated relevant apiserver unit test to reflect the new behavior (TestWriteJSONDecodeError()) - Add build deps from make update for protobuf serializer **What this PR does / why we need it**: This PR fixes a bug that was blocking extensible error handling in the case that serializing response data fails, and implements a '406 Not Acceptable' status code response if protobuf marshal definitions are not implemented for an API resource type. See commit message for further details. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes kubernetes#50342 **Special notes for your reviewer**: **Release note**: ```release-note Fixed a bug that was blocking extensible error handling when serializing API responses error out. Previously, serialization failures always resulted in the status code of the original response being returned. Now, the following behavior occurs: - If the serialization type is application/vnd.kubernetes.protobuf, and protobuf marshaling is not implemented for the requested API resource type, a '406 Not Acceptable is returned'. - If the serialization type is 'application/json': - If serialization fails, and the original status code was an failure (e.g. 4xx or 5xx), the original status code will be returned. - If serialization fails, and the original status code was not a failure (e.g. 2xx), the status code of the serialization failure will be returned. By default, this is '500 Internal Server Error', because JSON serialization is our default, and not supposed to be implemented on a type-by-type basis. ```
/kind bug
What happened:
Sent a request for an aggregated resource (sample-api wardle/flunders). Response was a 200 status code and an error message saying the response could not be given.
What you expected to happen:
We should have an error status code.
How to reproduce it (as minimally and precisely as possible):
< HTTP/1.1 200 OK
< Content-Length: 173
< Content-Type: application/vnd.kubernetes.protobuf
< Date: Tue, 08 Aug 2017 22:57:37 GMT
<
k8s
�v1��Status���
�
��Failure�~object *v1alpha1.FlunderList does not implement the protobuf marshalling interface and cannot be encoded to a protobuf message"0���"
Anything else we need to know?:
Environment:
kubectl version
): 1.8uname -a
): 3.16.0-4-amd64The text was updated successfully, but these errors were encountered: