Skip to content

Commit

Permalink
ansible: Handle GroupDiscoveryFailedError in proxy.go (operator-frame…
Browse files Browse the repository at this point in the history
…work#5596)

Similar to the fix in helm (helm/helm#6361), this
fix allows GroupDiscoveryFailedError to not error out the process of
managing apiserver resource types.

Fixes operator-framework#5596

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
  • Loading branch information
gabe-l-hart committed Dec 15, 2022
1 parent cbeec47 commit 170c063
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/ansible/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,18 @@ func (a *apiResources) resetResources() error {
defer a.mu.Unlock()

_, apisResourceList, err := a.discoveryClient.ServerGroupsAndResources()
// Issue #5596
// The ServerGroupsAndResources call can return both a valid list of api
// resources AND an error for one or more resources that fail to correctly
// look up against the API server. This fix mirrors the similar fix in helm:
// https://github.com/helm/helm/issues/6361
if err != nil {
return err
if discovery.IsGroupDiscoveryFailedError(err) {
log.Info("WARNING: The Kubernetes server has an orphaned API service. Server reports: %s", err)
log.Info("WARNING: To fix this, kubectl delete apiservice <service-name>")
} else {
return err
}
}

a.gvkToAPIResource = map[string]metav1.APIResource{}
Expand Down

0 comments on commit 170c063

Please sign in to comment.