Merge pull request #62234 from liggitt/apigroup-partial-discovery

Automatic merge from submit-queue (batch tested with PRs 61306, 60270, 62496, 62181, 62234). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Handle partial group and resource responses consistently

GetAPIGroupResources tolerates partial discovery responses to provide as much information to the caller as possible.

Before skipping a particular error response, check whether the response was accompanied by partial group or resource data.

There's an existing TODO to propagate partial errors that I plan to address in a follow-up, but that had more ripples and I wanted to correct this first.

```release-note
NONE
```

Kubernetes-commit: 7ba97b9200a9cab45f59a81ab8b44fca8ee863eb
This commit is contained in:
Kubernetes Publisher 2018-04-13 15:03:16 -07:00
commit dd40bd1fb2
2 changed files with 36 additions and 31 deletions

58
Godeps/Godeps.json generated
View File

@ -244,119 +244,119 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "847e24b2c0e587a6a097d187ebd72e1ca24de001"
"Rev": "b2cf9c5556ca5601d7b4e9ecc67b704426bf96c6"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",

View File

@ -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
}