Skip to content

Commit

Permalink
Improve IsResAvailableInGroupVersion to handle non running api serv…
Browse files Browse the repository at this point in the history
…ers (#1460)

* Don't fail `ServerPreferredResources` in case of serer unable

* Add review comment
  • Loading branch information
viveksinghggits committed Jun 7, 2022
1 parent c5acaac commit 5de51df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/kube/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ func IsOSRouteGroupAvailable(ctx context.Context, cli discovery.DiscoveryInterfa

// IsResAvailableInGroupVersion takes a resource and checks if that exists in the passed group and version
func IsResAvailableInGroupVersion(ctx context.Context, cli discovery.DiscoveryInterface, groupName, version, resource string) (bool, error) {
// This call is going to fail with error type `*discovery.ErrGroupDiscoveryFailed` if there are
// some api-resources that are served by aggregated API server and the aggregated API server is not ready.
// So if this utility is being called for those api-resources, `false` would be returned
resList, err := cli.ServerPreferredResources()
if err != nil {
return false, err
if _, ok := err.(*discovery.ErrGroupDiscoveryFailed); !ok {
return false, err
}
}

gv := fmt.Sprintf(groupVersionFormat, groupName, version)
Expand Down

0 comments on commit 5de51df

Please sign in to comment.