Prevent caching empty discovery docs

pull/6/head
Jordan Liggitt 2017-02-28 13:15:25 -05:00
parent 81d01a84e0
commit 091aac7e1e
No known key found for this signature in database
GPG Key ID: 24E7ADF9A3B42012
2 changed files with 11 additions and 1 deletions

View File

@ -75,6 +75,11 @@ func (d *CachedDiscoveryClient) ServerResourcesForGroupVersion(groupVersion stri
liveResources, err := d.delegate.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
glog.V(3).Infof("skipped caching discovery info due to %v", err)
return liveResources, err
}
if liveResources == nil || len(liveResources.APIResources) == 0 {
glog.V(3).Infof("skipped caching discovery info, no resources found")
return liveResources, err
}
@ -117,6 +122,11 @@ func (d *CachedDiscoveryClient) ServerGroups() (*metav1.APIGroupList, error) {
liveGroups, err := d.delegate.ServerGroups()
if err != nil {
glog.V(3).Infof("skipped caching discovery info due to %v", err)
return liveGroups, err
}
if liveGroups == nil || len(liveGroups.Groups) == 0 {
glog.V(3).Infof("skipped caching discovery info, no groups found")
return liveGroups, err
}

View File

@ -135,7 +135,7 @@ func (c *fakeDiscoveryClient) ServerGroups() (*metav1.APIGroupList, error) {
func (c *fakeDiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
c.resourceCalls = c.resourceCalls + 1
if groupVersion == "a/v1" {
return &metav1.APIResourceList{}, nil
return &metav1.APIResourceList{APIResources: []metav1.APIResource{{Name: "widgets", Kind: "Widget"}}}, nil
}
return nil, errors.NewNotFound(schema.GroupResource{}, "")