-
Notifications
You must be signed in to change notification settings - Fork 38.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 "$type does not implement the protobuf marshalling interface and cannot be encoded to a protobuf message" error instead of falling back to second Accept type #86253
Comments
In TestWatchNonDefaultContentType, there is test for falling back to JSON serialization:
|
That's testing client-side fallback. This bug is about a server serving a type which cannot be serialized using protobuf. |
I set up a simple addition to the sample-apiserver integration test to exercise this: flunder := `{"apiVersion":"wardle.k8s.io/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"abc","namespace":"default"}}`
result := wardleClient.Discovery().RESTClient().Post().
AbsPath("/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders").
Body([]byte(flunder)).
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/vnd.kubernetes.protobuf,application/json").
Do()
if err := result.Error(); err != nil {
t.Fatal(err)
} Tested this across all releases since the working 1.10 API server:
|
digging further, 1.10 and 1.11 did not actually succeed, but returned 200 responses containing status errors (issue reported in #50342, fixed in #67041 to correctly report the error attempting to encode to protobuf) we should still improve the server to fall back to other supported Accept types when the type being encoded did not support the first requested Accept encoding, but this is not a new issue |
The likely approach here is to filter the encoders the server supports to the ones the type for a particular endpoint supports when deciding what types a particular resource supports. |
What happened:
Creating an example object against the sample-apiserver returns the following error with a default client:
What you expected to happen:
The sample-apiserver would fall back to encoding the object in json
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Seen in a PR attempting to update the sample-apiserver used in e2e to 1.17.0 levels (#84735, https://prow.k8s.io/view/gcs/kubernetes-jenkins/pr-logs/pull/84735/pull-kubernetes-e2e-kind/1205296180716638211)
/sig api-machinery
/assign @smarterclayton
The text was updated successfully, but these errors were encountered: