AlinsRan opened a new pull request, #2817:
URL: https://github.com/apache/apisix-ingress-controller/pull/2817

   ### Type of change:
   
   - [x] Bugfix
   
   ### What this PR does / why we need it:
   
   Fixes #2734
   
   After a control-plane failover (kube-apiserver transiently unreachable at 
controller startup), the controller logged `Index with name 
field:serviceRefs/secretRefs/ingressClassParametersRef does not exist` forever 
and every reconcile failed until manual restart — and even restart didn't help 
if the API was still unstable at boot.
   
   Root cause: `HasAPIResource` created a discovery client and, on **any** 
error, returned `false` — indistinguishable from "CRD genuinely absent". 
Field-index registration is gated on `HasAPIResource` and runs once at startup 
with no retry, so a transient discovery failure permanently skipped the 
indexes; informers later reconnected and reconcile ran, but every 
field-selector `List` then failed forever.
   
   Fix: classify the discovery error. A definitive answer (GroupVersion 
`NotFound`, or discovery `Forbidden`) returns immediately; a transient 
transport/availability error (connection refused, timeout, 5xx, throttling) is 
retried with exponential backoff (1s→30s cap) until a definitive result. A 
reachable API server always yields a definitive result, so the loop only waits 
while the API server is actually unreachable.
   
   Why not register the indexes unconditionally: controller-runtime's 
`IndexField` eagerly resolves the GVK through the RESTMapper, which errors for 
a genuinely-absent CRD — so unconditional registration would break setup for 
optional CRDs that aren't installed.
   
   ### Discussion point
   
   On a *persistently* unreachable API server, `HasAPIResource` now blocks 
setup (before `mgr.Start`) until the API is reachable, rather than proceeding 
into a permanently-broken state. This is intentional (the controller can't 
function without the API server), but there is no overall deadline — a hard 
bound via context could be added if preferred, at the cost of threading a 
context through the ~20 call sites. Feedback welcome.
   
   ### Pre-submission checklist:
   
   - [x] Did you explain what problem does this PR solve?
   - [x] Have you added corresponding test cases? (transient-then-success 
regression + error classification)
   - [ ] Have you modified the corresponding document? (n/a)
   - [x] Is this PR backward compatible?


-- 
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]

Reply via email to