Unverified Commit 7ba97b92 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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 ```
parents 1ef0153e e203c4e4
...@@ -144,7 +144,10 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V ...@@ -144,7 +144,10 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V
func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) { func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
apiGroups, err := cl.ServerGroups() apiGroups, err := cl.ServerGroups()
if err != nil { 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 var result []*APIGroupResources
for _, group := range apiGroups.Groups { for _, group := range apiGroups.Groups {
...@@ -157,7 +160,9 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) { ...@@ -157,7 +160,9 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
if err != nil { if err != nil {
// continue as best we can // continue as best we can
// TODO track the errors and update callers to handle partial errors. // 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 groupResources.VersionedResources[version.Version] = resources.APIResources
} }
......
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