• Kubernetes Submit Queue's avatar
    Merge pull request #36001 from smarterclayton/change_double_decode · 7d14b568
    Kubernetes Submit Queue authored
    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).
    ```
    7d14b568
Name
Last commit
Last update
..
apis Loading commit data...
client Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
deploy Loading commit data...
develop Loading commit data...
docs/api-reference Loading commit data...
manifests Loading commit data...
pkg Loading commit data...
registry/cluster Loading commit data...
Makefile Loading commit data...
OWNERS Loading commit data...
README.md Loading commit data...