mirror of https://github.com/k3s-io/k3s
Merge pull request #55162 from deads2k/cli-06-tolerate-error
Automatic merge from submit-queue. 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>. tolerate discovery errors in the restmapper Found this while investigating a related problem. The restmapper can use the information it has found. It doesn't have to discard all of it.pull/6/head
commit
f4d470c75c
|
@ -79,22 +79,24 @@ func (e shortcutExpander) RESTMappings(gk schema.GroupKind, versions ...string)
|
|||
func (e shortcutExpander) getShortcutMappings() ([]kubectl.ResourceShortcuts, error) {
|
||||
res := []kubectl.ResourceShortcuts{}
|
||||
// get server resources
|
||||
// This can return an error *and* the results it was able to find. We don't need to fail on the error.
|
||||
apiResList, err := e.discoveryClient.ServerResources()
|
||||
if err == nil {
|
||||
for _, apiResources := range apiResList {
|
||||
for _, apiRes := range apiResources.APIResources {
|
||||
for _, shortName := range apiRes.ShortNames {
|
||||
gv, err := schema.ParseGroupVersion(apiResources.GroupVersion)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("Unable to parse groupversion = %s due to = %s", apiResources.GroupVersion, err.Error())
|
||||
continue
|
||||
}
|
||||
rs := kubectl.ResourceShortcuts{
|
||||
ShortForm: schema.GroupResource{Group: gv.Group, Resource: shortName},
|
||||
LongForm: schema.GroupResource{Group: gv.Group, Resource: apiRes.Name},
|
||||
}
|
||||
res = append(res, rs)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("Error loading discovery information: %v", err)
|
||||
}
|
||||
for _, apiResources := range apiResList {
|
||||
for _, apiRes := range apiResources.APIResources {
|
||||
for _, shortName := range apiRes.ShortNames {
|
||||
gv, err := schema.ParseGroupVersion(apiResources.GroupVersion)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("Unable to parse groupversion = %s due to = %s", apiResources.GroupVersion, err.Error())
|
||||
continue
|
||||
}
|
||||
rs := kubectl.ResourceShortcuts{
|
||||
ShortForm: schema.GroupResource{Group: gv.Group, Resource: shortName},
|
||||
LongForm: schema.GroupResource{Group: gv.Group, Resource: apiRes.Name},
|
||||
}
|
||||
res = append(res, rs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue