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

   <!-- Please answer these questions before submitting a pull request -->
   
   ### Type of change:
   
   <!-- Please delete options that are not relevant. -->
   
   <!-- Select all the options from below that matches the type your PR best -->
   
   - [ ] Bugfix
   - [ ] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   - [ ] Documentation
   - [x] Refactor
   - [ ] Chore
   - [ ] CI/CD or Tests
   
   ### What this PR does / why we need it:
   
   Follows up #2865 by finishing the responsibility split between the 
`internal/adc/client` package and `apisixProvider`. After #2865 the client 
still fanned a sync out over `Config.ServerAddrs`, decided on its own whether 
to retry a stale-`conf_version` rejection, and kept per-leadership-term 
bookkeeping of which data-plane diff baselines it had rebuilt. None of that is 
wire-protocol work; it is policy about how to react to a data plane, and only 
apisix-standalone needs it at all.
   
   `internal/adc/client.Client` is now strictly "translate one request, send it 
once, parse the reply into a typed error":
   
   - `Client.Sync` takes a single `SyncInput` and returns one `error` (a parsed 
`types.ADCExecutionServerAddrError`, or nil) instead of taking a slice and 
returning a map. It never retries and keeps no state across calls.
   - The `Client` struct loses `rebuiltBaselines`/`rebuiltMu`, the 
`InvalidateADCCache` / `baselineIsCurrent` / `markBaselineCurrent` methods, and 
the internal `push` / `syncOne` layers.
   - `isConfVersionRejection` is exported as `IsConfVersionRejection` so a 
caller can recognize the one rejection it can answer; the `conf_version` 
field-name match stays in this package because it is an ADC admin-API fact.
   - `runHTTPSync` no longer loops over `Config.ServerAddrs`. A new 
`syncTargetAddr` resolves the list into the one address a request targets: 
`apisix-standalone` joins every entry with commas (ADC treats that as one 
logical destination), every other backend type uses the first entry. Whoever 
built `Config.ServerAddrs` owns the address count; a GatewayProxy is expected 
to resolve to a single address for non-standalone backends. The validate path 
is unchanged.
   - `backendAPISIXStandalone` is exported as `BackendAPISIXStandalone`.
   
   apisix-standalone's baseline recovery moves into a dedicated 
`client.StandaloneSyncer`, composed on top of the one-shot `Client`:
   
   - It owns the `BypassCache` decision, the single detect-and-retry for a 
stale `conf_version` (rebuild ADC's diff baseline from the data plane, push 
once more), the `conf_version_conflict` metric, and the per-leadership-term 
record of which cacheKeys it has rebuilt. `InvalidateBaselines()` resets that 
record on leader acquisition.
   - `Sync` returns 0, 1, or 2 errors: the final failure, plus the rejection 
that triggered a rebuild which then failed for a different reason (on its own 
that failure points nowhere near its cause, e.g. an ADC server too old to know 
`bypassCache` answers with a schema error).
   - Every other backend type keeps a conf_version of nothing, so it does not 
go through the syncer at all.
   
   `apisixProvider` gains one `*client.StandaloneSyncer` field and calls it on 
leader acquisition. `pushConfig` is now a single `if backend == 
apisix-standalone` branch: standalone goes through the syncer, everything else 
is one `Client.Sync`, and both converge on the same wrap into the 
`types.ADCExecutionErrors` shape the status pipeline already consumes. 
`status.go`, the `statusesMap` structure, and `handleADCExecutionErrors` are 
untouched.
   
   The eight `TestClientSync*` cases in `executor_test.go` covered the 
retry/baseline behavior that left the package; they are replaced by equivalent 
cases in a new `sync_baseline_test.go` that drive the same scenarios through 
`pushConfig` and the real HTTP path. Every `handleHTTPResponse` / 
`buildHTTPRequest` / `distinctReasons` test is unchanged.
   
   This is backward compatible: no CRD, config, or status-condition behavior 
changes, and metrics are equivalent (`RecordSyncDuration`, 
`RecordExecutionError` including the `conf_version_conflict` counter).
   
   ### Pre-submission checklist:
   
   <!--
   Please follow the requirements:
   1. Use Draft if the PR is not ready to be reviewed
   2. Test is required for the feat/fix PR, unless you have a good reason
   3. Doc is required for the feat PR
   4. Use a new commit to resolve review instead of `push -f`
   5. Use "request review" to notify the reviewer once you have resolved the 
review
   -->
   
   - [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   - [x] Have you added corresponding test cases?
   - [ ] Have you modified the corresponding document?
   - [x] Is this PR backward compatible? **If it is not backward compatible, 
please discuss on the [mailing 
list](https://github.com/apache/apisix-ingress-controller#community) first**
   


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