Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 7979903

Browse files
committed
exec enable cmd ignore ignore some apiservices error
1 parent 7653009 commit 7979903

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pkg/kubefedctl/enable/util.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package enable
1919
import (
2020
"fmt"
2121
"io"
22+
apierrors "k8s.io/apimachinery/pkg/util/errors"
23+
"k8s.io/klog"
2224
"os"
2325
"strings"
2426

@@ -89,9 +91,10 @@ func CrdForAPIResource(apiResource metav1.APIResource, validation *apiextv1.Cust
8991
}
9092

9193
func LookupAPIResource(config *rest.Config, key, targetVersion string) (*metav1.APIResource, error) {
94+
errs := []error{}
9295
resourceLists, err := GetServerPreferredResources(config)
9396
if err != nil {
94-
return nil, err
97+
errs = append(errs, err)
9598
}
9699

97100
var targetResource *metav1.APIResource
@@ -124,15 +127,19 @@ func LookupAPIResource(config *rest.Config, key, targetVersion string) (*metav1.
124127
}
125128
}
126129
}
130+
127131
if len(matchedResources) > 1 {
128-
return nil, errors.Errorf("Multiple resources are matched by %q: %s. A group-qualified plural name must be provided.", key, strings.Join(matchedResources, ", "))
132+
errs = append(errs, errors.Errorf("Multiple resources are matched by %q: %s. A group-qualified plural name must be provided.", key, strings.Join(matchedResources, ", ")))
133+
return nil, apierrors.NewAggregate(errs)
129134
}
130135

131136
if targetResource != nil {
137+
klog.Warningf("Api resource found with err %v, error ignored.", apierrors.NewAggregate(errs))
132138
return targetResource, nil
133139
}
134140

135-
return nil, errors.Errorf("Unable to find api resource named %q.", key)
141+
errs = append(errs, errors.Errorf("Unable to find api resource named %q.", key))
142+
return nil, apierrors.NewAggregate(errs)
136143
}
137144

138145
func NameMatchesResource(name string, apiResource metav1.APIResource, group string) bool {
@@ -161,7 +168,7 @@ func GetServerPreferredResources(config *rest.Config) ([]*metav1.APIResourceList
161168

162169
resourceLists, err := client.ServerPreferredResources()
163170
if err != nil {
164-
return nil, errors.Wrap(err, "Error listing api resources")
171+
return resourceLists, errors.Wrap(err, "Error listing api resources")
165172
}
166173
return resourceLists, nil
167174
}

0 commit comments

Comments
 (0)