k3s/pkg/client
Kubernetes Submit Queue 7d14b568c3 Merge pull request #36001 from smarterclayton/change_double_decode
Automatic merge from submit-queue

Avoid double decoding all client responses

Fixes #35982 

The linked issue uncovered that we were always double decoding the response in restclient for get, list, update, create, and patch.  That's fairly expensive, most especially for list.  This PR refines the behavior of the rest client to avoid double decoding, and does so while minimizing the changes to rest client consumers.

restclient must be able to deal with multiple types of servers. Alter the behavior of restclient.Result#Raw() to not process the body on error, but instead to return the generic error (which still matches the error checking cases in api/error like IsBadRequest). If the caller uses
.Error(), .Into(), or .Get(), try decoding the body as a Status.

For older servers, continue to default apiVersion "v1" when calling restclient.Result#Error(). This was only for 1.1 servers and the extensions group, which we have since fixed.

This removes a double decode of very large objects (like LIST) - we were trying to DecodeInto status, but that ends up decoding the entire result and then throwing it away.  This makes the decode behavior specific to the type of action the user wants.

```release-note
The error handling behavior of `pkg/client/restclient.Result` has changed.  Calls to `Result.Raw()` will no longer parse the body, although they will still return errors that react to `pkg/api/errors.Is*()` as in previous releases.  Callers of `Get()` and `Into()` will continue to receive errors that are parsed from the body if the kind and apiVersion of the body match the `Status` object.

This more closely aligns rest client as a generic RESTful client, while preserving the special Kube API extended error handling for the `Get` and `Into` methods (which most Kube clients use).
```
2016-11-02 11:36:41 -07:00
..
cache move watch.ListWatchUntil to its own package to avoid future import cycle 2016-10-30 13:14:20 -07:00
chaosclient autogenerated 2016-10-21 17:32:32 -07:00
clientset_generated remove release_1_4 2016-10-31 15:05:26 -07:00
leaderelection autogenerated 2016-10-21 17:32:32 -07:00
listers autogenerated 2016-11-01 15:13:27 -07:00
metrics autogenerated 2016-10-21 17:32:32 -07:00
record autogenerated 2016-10-21 17:32:32 -07:00
restclient Avoid double decoding all client responses 2016-11-01 22:55:51 -04:00
retry autogenerated 2016-10-21 17:32:32 -07:00
testdata
testing autogenerated 2016-10-21 17:32:32 -07:00
transport autogenerated 2016-10-21 17:32:32 -07:00
typed move client/unversioned/fake to client/restclient/fake 2016-10-29 14:22:02 -07:00
unversioned Merge pull request #34489 from caesarxuchao/time-copy.sh 2016-10-29 16:24:07 -07:00
OWNERS Move blunderbuss assignees into tree 2016-03-02 20:46:32 -05:00