fix: remove redundant route.Hosts to prevent false diffs in ADC sync#2743
Conversation
The translator was setting hosts on both Route and Service for ApisixRoute resources. Since APISIX routes inherit hosts from their parent service, the route-level hosts is redundant. For backends that don't support route-level hosts, this causes a false diff every sync cycle: the local state has route.hosts but the remote state never does, triggering unnecessary PUT requests and audit log bloat. Remove route.Hosts assignment; service.Hosts remains as the canonical location for host matching.
There was a problem hiding this comment.
Pull request overview
Removes redundant hosts assignment at the route level for ApisixRoute translation to avoid persistent false diffs during ADC sync (especially for backends that don’t support route-level hosts).
Changes:
- Stop setting
route.Hostsfromrule.Match.HostsinbuildRoute(), relying onservice.Hostsas the canonical host matcher. - Add unit tests to verify
route.Hostsis unset andservice.Hostsremains correctly set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/adc/translator/apisixroute.go |
Removes redundant route.Hosts assignment so host matching is represented only at the service level. |
internal/adc/translator/apisixroute_test.go |
Adds tests asserting route.Hosts is not populated and service.Hosts is populated from rule.Match.Hosts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
CI Status: lint ✅, unit tests ✅, misspell ✅, CRD docs ✅, license check ✅ The e2e test failures are a pre-existing infrastructure issue — the ADC dev Docker image ( |
The ghcr.io/api7/adc:dev Docker image now bundles main.cjs instead of main.js at the container root. Update all workflow files that extract the ADC binary via docker cp.
|
Pushed CI fix: updated |
|
CI Status update: All APISIX E2E Tests ✅ (7/7 jobs passed), all conformance tests ✅, lint ✅, unit tests ✅, CodeQL ✅, license ✅. The only failure is |
In APISIX standalone mode, config application via /apisix/admin/configs is async (returns 202). Two tests asserted HTTP status immediately after config push without retry, causing intermittent 404s: - Basic test: direct assertion on /headers after route update - WebSocket test: direct dial+sleep assertion after route creation Replace direct assertions with Eventually retry (20s timeout, 1s interval) to match the pattern used elsewhere in the test suite.
|
Pushed e2e test fix: replaced 2 direct HTTP assertions with Root cause: In APISIX standalone mode, config application via Fix: Use The previous Benchmark test failure (APISIX 500 on ListServices) was an infrastructure issue — APISIX standalone failed to initialize. This should resolve on re-run. |
Problem
The translator sets
hostson both Route and Service for ApisixRoute resources. Since APISIX routes inherit hosts from their parent service, the route-level hosts is redundant.For backends that don't support route-level hosts, this causes a false diff every sync cycle: the local state has
route.hostsbut the remote state never does, triggering unnecessary PUT requests and audit log bloat.Root Cause
In
buildRoute()(internal/adc/translator/apisixroute.go),route.Hostswas set torule.Match.Hosts. However,buildService()already setsservice.Hoststo the same value. Since routes inherit hosts from their parent service, the route-level hosts is redundant and can cause false diffs during config sync.Fix
Remove
route.Hosts = rule.Match.HostsfrombuildRoute().service.Hostsremains as the canonical location for host matching.CI Fix
Also fixes ADC binary extraction in CI workflows: the
ghcr.io/api7/adc:devDocker image now bundlesmain.cjsinstead ofmain.jsat the container root. Updatedapisix-e2e-test.ymlandbenchmark-test.yml.Testing
Added unit tests:
TestBuildRoute_HostsNotSet: verifies route.Hosts is not set after buildRouteTestBuildService_HostsSet: verifies service.Hosts is correctly set