nic-6443 commented on code in PR #2817:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2817#discussion_r3656003303
##########
pkg/utils/k8s.go:
##########
@@ -52,29 +121,124 @@ func HasAPIResourceWithLogger(mgr ctrl.Manager, obj
client.Object, logger logr.L
"groupVersion", groupVersion,
)
- // Create discovery client
- discoveryClient, err :=
discovery.NewDiscoveryClientForConfig(mgr.GetConfig())
- if err != nil {
- logger.Info("failed to create discovery client", "error", err)
- return false
- }
-
// Query server resources for the specific group/version
- apiResources, err :=
discoveryClient.ServerResourcesForGroupVersion(groupVersion)
- if err != nil {
+ var apiResources *metav1.APIResourceList
+ err := retryUntilDefinitive(backoff, logger, func() error {
+ var err error
+ apiResources, err =
discoveryClient.ServerResourcesForGroupVersion(groupVersion)
+ return err
+ })
+ switch {
+ case err == nil:
+ case apierrors.IsNotFound(err):
logger.Info("group/version not available in cluster", "error",
err)
- return false
+ return false, nil
+ case apierrors.IsForbidden(err):
Review Comment:
[P1] Forbidden discovery cannot be treated as “resource not installed”. This
result is decided once for the lifetime of the manager, so an RBAC or discovery
misconfiguration starts a ready controller with the corresponding controllers
and indexes permanently omitted, recreating the half-disabled startup mode this
PR is meant to prevent. Return the Forbidden error and fail startup; only a
real NotFound is evidence that the API is absent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]