k3s/pkg/api
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
..
annotations autogenerated 2016-10-21 17:32:32 -07:00
endpoints autogenerated 2016-10-21 17:32:32 -07:00
errors autogenerated 2016-10-21 17:32:32 -07:00
events autogenerated 2016-10-21 17:32:32 -07:00
install autogenerated 2016-10-21 17:32:32 -07:00
meta autogenerated 2016-10-21 17:32:32 -07:00
pod autogenerated 2016-10-21 17:32:32 -07:00
resource autogenerated 2016-10-21 17:32:32 -07:00
rest autogenerated 2016-10-21 17:32:32 -07:00
service autogenerated 2016-10-21 17:32:32 -07:00
testapi Authorization should be registered in testapi 2016-11-01 22:55:58 -04:00
testing kubeadm: fix central api tests 2016-11-01 16:48:45 -07:00
unversioned Rename PetSet API to StatefulSet 2016-10-27 17:25:10 -07:00
util autogenerated 2016-10-21 17:32:32 -07:00
v1 generated: alternative unsafe conversions 2016-10-31 11:00:29 -04:00
validation Support opaque integer resource accounting. 2016-10-28 10:15:13 -07:00
BUILD autogenerated 2016-10-21 17:32:32 -07:00
OWNERS
context.go print instruction in case of failed kubectl 1.3 rolling-update against 1.4 cluster 2016-09-15 17:20:39 -07:00
context_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
conversion.go Add conversion instructions 2016-10-25 19:28:40 -04:00
conversion_test.go remove testapi.Default.GroupVersion 2016-10-07 10:10:54 -04:00
copy_test.go remove testapi.Default.GroupVersion 2016-10-07 10:10:54 -04:00
deep_copy_test.go Update etcd default ports for v3, and validate tests 2016-08-17 07:49:19 -05:00
defaulting_test.go kubeadm: fix central api tests 2016-11-01 16:48:45 -07:00
defaults.go fix register.go files up + add test import 2016-08-11 17:06:54 -07:00
doc.go Use Go canonical import paths 2016-07-16 13:48:21 -04:00
field_constants.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
generate.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
generate_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
helpers.go Support opaque integer resource accounting. 2016-10-28 10:15:13 -07:00
helpers_test.go Return error for empty sysctl names 2016-09-30 17:56:37 +02:00
mapper.go remove dead mapper 2016-09-19 09:57:19 -04:00
meta.go add ClusterName field to ObjectMeta 2016-08-22 21:09:57 -07:00
meta_test.go remove testapi.Default.GroupVersion 2016-10-07 10:10:54 -04:00
node_example.json Change minion to node 2016-09-28 10:53:30 -07:00
ref.go move api.OjbectReference.ObjectKind() to ref.go 2016-07-14 23:02:05 -07:00
ref_test.go Use make as the main build tool 2016-07-12 21:52:00 -07:00
register.go Fix various typos in pkg/api 2016-08-29 11:31:16 +02:00
replication_controller_example.json Initial Quobyte support 2016-08-18 17:13:50 +02:00
requestcontext.go Cleanup handler chain 2016-09-23 12:03:58 +02:00
resource_helpers.go extensions: add minReadySeconds/availableReplicas to replica sets 2016-09-28 11:06:40 +02:00
resource_helpers_test.go extensions: add minReadySeconds/availableReplicas to replica sets 2016-09-28 11:06:40 +02:00
serialization_proto_test.go Replace negotiation with a new method that can extract info 2016-10-28 11:30:11 -04:00
serialization_test.go Improve the common kinds API test to catch more errors 2016-11-01 22:55:58 -04:00
types.generated.go generated: Unsafe conversions 2016-10-25 19:30:34 -04:00
types.go Support opaque integer resource accounting. 2016-10-28 10:15:13 -07:00
zz_generated.deepcopy.go Generated changes for lastProbeTime removal 2016-10-20 15:16:46 +02:00