Skip to content

fix: stabilize InferencePool parent status reconciliation#2333

Open
Aias00 wants to merge 5 commits into
envoyproxy:mainfrom
Aias00:fix/inferencepool-status-flake
Open

fix: stabilize InferencePool parent status reconciliation#2333
Aias00 wants to merge 5 commits into
envoyproxy:mainfrom
Aias00:fix/inferencepool-status-flake

Conversation

@Aias00

@Aias00 Aias00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

This stabilizes InferencePool parent status reconciliation for the Gateway API Inference Extension conformance case where multiple HTTPRoutes reference the same InferencePool through different Gateway parents. When status changes, the controller now schedules one short follow-up reconcile so cache-backed route and gateway lists can converge. The follow-up reconcile stops once the desired parent status is already present.

This also adds a regression test for two HTTPRoutes pointing at two Gateway parents for one InferencePool.

Related Issues/PRs (if applicable)

Fixes #1331.

Special notes for reviewers (if applicable)

Validated locally with go test ./internal/controller -run TestInferencePoolController, go test ./internal/controller, and make lint.

@Aias00
Aias00 requested a review from a team as a code owner July 7, 2026 08:21
Copilot AI review requested due to automatic review settings July 7, 2026 08:21
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes InferencePool status reconciliation in the controller by avoiding no-op status updates (which can trigger repeated reconciles) and by requeueing once after a real status change so cache-backed Gateway/HTTPRoute views can converge before conformance checks evaluate parent status.

Changes:

  • Requeue reconciliation once (RequeueAfter: 1s) after a successful InferencePool status update to allow informer caches to converge.
  • Skip status updates when the computed parent statuses are semantically unchanged (ignoring LastTransitionTime) to avoid endless reconcile loops.
  • Add a regression test covering the conformance scenario with multiple HTTPRoutes pointing to multiple Gateway parents for a single InferencePool.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/controller/inference_pool.go Adds status-change detection (ignoring LastTransitionTime) and a one-time requeue after status updates to stabilize parent-status reconciliation.
internal/controller/inference_pool_test.go Updates existing expectations for the new requeue behavior and adds a regression test for multiple HTTPRoute/Gateway parents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter

codecov-commenter commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.89%. Comparing base (a7aa458) to head (e0e0f0d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2333      +/-   ##
==========================================
+ Coverage   84.83%   84.89%   +0.06%     
==========================================
  Files         148      148              
  Lines       21877    21939      +62     
==========================================
+ Hits        18559    18626      +67     
+ Misses       2197     2194       -3     
+ Partials     1121     1119       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Fixes envoyproxy#1331.

Inference Extension conformance can create multiple HTTPRoutes for the same InferencePool in quick succession. A reconcile can observe only one referenced Gateway through the controller cache and write a partial Parents status, then receive no later event to recompute the complete parent set.

Return a short requeue only when the InferencePool status actually changes. Status equality ignores LastTransitionTime so the follow-up reconcile converges and stops instead of looping forever.

Constraint: controller-runtime cache-backed route and gateway lists can lag related object events.

Rejected: Increasing conformance timeouts, because stale status can persist indefinitely without another reconcile.

Confidence: high

Scope-risk: moderate; changes InferencePool reconcile scheduling after status updates.

Tested: go test ./internal/controller -run TestInferencePoolController

Tested: go test ./internal/controller

Tested: make lint
Signed-off-by: liuhy <liuhongyu@apache.org>
@Aias00
Aias00 force-pushed the fix/inferencepool-status-flake branch from 208ab0b to 1a24ec8 Compare July 7, 2026 08:53
The status-requeue fix could still miss convergence: when the first
reconcile observes zero referenced Gateways because the controller-runtime
cache-backed list lags, and the InferencePool status is already empty,
inferencePoolParentStatusesEqual(empty, empty) is true. Relying on status
mutation alone then skips the requeue, and the status can stay stale
indefinitely if no later event fires another reconcile.

Close the gap by arming a short follow-up reconcile on the first observed
sync at a generation (in addition to on every status change), and stopping
once the status is observed unchanged at that generation. The follow-up
re-reads a now-converged cache. A spec change (new generation) re-arms the
follow-up; a deleted InferencePool forgets its marker so the map stays
bounded.

Constraint: controller-runtime cache-backed route and gateway lists can lag
related object events, so an unchanged (empty) status cannot be trusted on
first observation.

Rejected: Requeueing indefinitely on every successful sync, because that
loops forever; the generation-keyed arm/consume marker converges and stops.

Tested: go test ./internal/controller -run TestInferencePoolController
Tested: go test ./internal/controller
Tested: make lint

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: liuhy <liuhongyu@apache.org>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 10, 2026
…-generation

pendingRequeues used "namespace/name@generation" as the key. When an
InferencePool advanced from generation N to N+1 before the N follow-up was
consumed, the N+1 sync added a new marker but the stale N marker lingered — it
could only be cleared by forgetInferencePoolRequeue at object deletion. A
long-lived, frequently-updated InferencePool accumulated one stale entry per
generation for the controller's lifetime.

Track the generation as the map value instead, keyed by "namespace/name". A spec
change overwrites the single per-object entry, re-arming the follow-up without
leaving stale entries behind. forgetInferencePoolRequeue simplifies to a single
delete.

Adds a regression test that advances generations while a follow-up is armed and
asserts the map holds one entry; it fails on the old implementation (3 entries).
Also covers the delete path directly.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: liuhy <liuhongyu@apache.org>
@Aias00
Aias00 force-pushed the fix/inferencepool-status-flake branch from d663dfd to 2892ac3 Compare July 12, 2026 06:17
@missBerg missBerg added the area/routing Routing, fallback, resilience, InferencePool integration label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/routing Routing, fallback, resilience, InferencePool integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

4 participants