Commit 44a3cd12 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #40930 from deads2k/kubectl-01-negotiation

Automatic merge from submit-queue (batch tested with PRs 40930, 40951) update negotiation to reflect current kubectl state Very few things actually require negotiation, but the client-cache attempts it all the time. If you've explicitly requested one, you still fail. If you haven't requested one and the server doesn't have one, you still get the client behavior. After this, if you haven't requested one and the client and server don't have one, you simply get an empty you can interpret how you choose. @lavalamp without this, you're unable to use `kubectl` against arbitrary servers.
parents 095f4ef6 2b5b04d0
...@@ -104,8 +104,8 @@ func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion ...@@ -104,8 +104,8 @@ func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion
return &clientRegisteredGVs[0], nil return &clientRegisteredGVs[0], nil
} }
return nil, fmt.Errorf("failed to negotiate an api version; server supports: %v, client supports: %v", // fall back to an empty GroupVersion. Most client commands no longer respect a GroupVersion anyway
serverVersions, clientVersions) return &schema.GroupVersion{}, nil
} }
// GroupVersionResources converts APIResourceLists to the GroupVersionResources. // GroupVersionResources converts APIResourceLists to the GroupVersionResources.
......
...@@ -118,9 +118,9 @@ func TestNegotiateVersion(t *testing.T) { ...@@ -118,9 +118,9 @@ func TestNegotiateVersion(t *testing.T) {
statusCode: http.StatusNotFound, statusCode: http.StatusNotFound,
}, },
{ {
name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, no fallback GroupVersion", name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, fallback to empty GroupVersion",
expectErr: func(err error) bool { return strings.Contains(err.Error(), "failed to negotiate an api version;") }, expectedVersion: &schema.GroupVersion{},
statusCode: http.StatusForbidden, statusCode: http.StatusForbidden,
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment