From bc399996ff5e3011d9f8bd0dcac858c4b875233f Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 6 Apr 2018 22:42:34 -0400 Subject: [PATCH] Handle partial group and resource responses consistently Kubernetes-commit: e203c4e42b9037a6800dbc0dc433c63fc8cf7516 --- discovery/restmapper.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/discovery/restmapper.go b/discovery/restmapper.go index df5ab035..f90e1bb0 100644 --- a/discovery/restmapper.go +++ b/discovery/restmapper.go @@ -144,7 +144,10 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) { apiGroups, err := cl.ServerGroups() if err != nil { - return nil, err + if apiGroups == nil || len(apiGroups.Groups) == 0 { + return nil, err + } + // TODO track the errors and update callers to handle partial errors. } var result []*APIGroupResources for _, group := range apiGroups.Groups { @@ -157,7 +160,9 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) { if err != nil { // continue as best we can // TODO track the errors and update callers to handle partial errors. - continue + if resources == nil || len(resources.APIResources) == 0 { + continue + } } groupResources.VersionedResources[version.Version] = resources.APIResources }