From 2b5b04d074ba57b36ab3c1fc9b2d82d5ec50ff4c Mon Sep 17 00:00:00 2001 From: deads2k Date: Fri, 3 Feb 2017 12:12:45 -0500 Subject: [PATCH] update negotiation to reflect current kubectl state --- staging/src/k8s.io/client-go/discovery/helper.go | 4 ++-- .../src/k8s.io/client-go/discovery/helper_blackbox_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/client-go/discovery/helper.go b/staging/src/k8s.io/client-go/discovery/helper.go index 41a580807e5..0222e188bb6 100644 --- a/staging/src/k8s.io/client-go/discovery/helper.go +++ b/staging/src/k8s.io/client-go/discovery/helper.go @@ -104,8 +104,8 @@ func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion return &clientRegisteredGVs[0], nil } - return nil, fmt.Errorf("failed to negotiate an api version; server supports: %v, client supports: %v", - serverVersions, clientVersions) + // fall back to an empty GroupVersion. Most client commands no longer respect a GroupVersion anyway + return &schema.GroupVersion{}, nil } // GroupVersionResources converts APIResourceLists to the GroupVersionResources. diff --git a/staging/src/k8s.io/client-go/discovery/helper_blackbox_test.go b/staging/src/k8s.io/client-go/discovery/helper_blackbox_test.go index 3232bffb73a..9093316e876 100644 --- a/staging/src/k8s.io/client-go/discovery/helper_blackbox_test.go +++ b/staging/src/k8s.io/client-go/discovery/helper_blackbox_test.go @@ -118,9 +118,9 @@ func TestNegotiateVersion(t *testing.T) { statusCode: http.StatusNotFound, }, { - name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, no fallback GroupVersion", - expectErr: func(err error) bool { return strings.Contains(err.Error(), "failed to negotiate an api version;") }, - statusCode: http.StatusForbidden, + name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, fallback to empty GroupVersion", + expectedVersion: &schema.GroupVersion{}, + statusCode: http.StatusForbidden, }, }