feat(admin): deprecate the Admin API write path in favor of declarative configuration#776
Conversation
…ve configuration Every mutating /admin/v1/* response now carries the RFC 9745 Deprecation header (@1783929480, the file-based resource source's release timestamp) and a rel="deprecation" Link to the declarative- configuration docs, stamped by one router-level layer that shares its write predicate with the file-managed guard so new write routes can't omit the signal and the file-mode 409 carries it too. Write operations in the generated Admin OpenAPI are marked deprecated: true via one programmatic pass, with descriptions pointing at resources_file / direct etcd writes; reads are untouched. The e2e smoke now boots from a declarative resources.yaml (file mode) instead of admin-write -> proxy-read, and the openai-sdk-compat deprecation-window case pins the header contract on a live admin write.
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Admin API write endpoints (POST/PUT/DELETE across every resource collection,
rotateincluded, on both the canonicalapi_keysand the formerapikeysspelling) now signal in-band that they are deprecated in favor of the declarative configuration paths — aresources_filesource (resources.yaml) or direct etcd writes. The endpoints remain fully functional: no request/response body, status code, or behavior changes — only the two response headers and the OpenAPI marking below.Three surfaces:
/admin/v1/*response carries, per RFC 9745:Deprecation: @1783929480Link: <https://docs.api7.ai/ai-gateway/getting-started/self-hosted-quickstart>; rel="deprecation"deprecated: truewith a description line pointing at the declarative paths;info.descriptionexplains the write-path deprecation once. Read operations are untouched.Header form: why
Deprecation: @1783929480and nottrueRFC 9745 (the published IETF standard for this header) requires the value to be an RFC 9651 structured-field Date —
@<unix-timestamp>. The bare booleantruefrom earlier drafts is not valid in the final RFC. We deliberately promise no removal timeline, and the RFC supports exactly that: a past date means "the resource in context was deprecated at that date" and implies nothing about removal (that would be sunset signaling, a separate mechanism this PR intentionally does not emit).1783929480is the merge timestamp of9b8b407, the change that shipped the file-based resource source — the factual point at which declarative configuration became the recommended standalone path.The
Linkheader uses thedeprecationrelation type registered by RFC 9745 §3, pointing at the published quickstart that documents the declarative configuration flow (the same docs URL family the README already references).Chokepoint design
One router-level layer,
deprecated_write_headersincrates/aisix-admin/src/lib.rs, stamps both headers. It shares a singleis_admin_resource_writepredicate with the existing file-managed write guard, so the two views of "a write" cannot drift. Properties:/admin/v1/*route — a newly added write route cannot ship without the signal./admin/v1/models/status,/admin/v1/health,/admin/openapi.json) and non-resource endpoints (/playground/*,/livez,/readyz) are untouched.Linkis appended, never inserted, so a handler-provided link relation can't be clobbered.The OpenAPI marking mirrors the same idea: one programmatic pass (
mark_admin_write_operations_deprecated) over the merged document instead of 29 hand-edited operations, running after the former-apikeysalias mirroring so those operations are covered too.Smoke conversion
tests/e2e/src/cases/smoke.test.tsnow boots from a declarativeresources.yaml(the harness's file mode) and asserts the same observable contract as before: the file-defined model is visible on/v1/models, and a chat completion round-trips to the mock upstream exactly once at/v1/chat/completions. File mode is synchronous at boot, so the etcd-propagation polling scaffolding is gone, and the smoke no longer requires etcd at all.Deliberate Admin-API-write coverage remains where it is marked: the seed-vs-admin characterization case and the two cases commented "Deliberately seeds via the Admin API" (
openai-sdk-compat,datadog-exporter).openai-sdk-compatadditionally pins the deprecation signal itself now: an admin write must answer with an RFC-9745-shapedDeprecationvalue (@<unix>) and arel="deprecation"link, and an admin read must answer with neither.Tests
aisix-admin): a representative create, a rotate, a former-spelling delete, and the file-managed 409 all carry both headers with the exact pinned values; GET reads,/admin/openapi.json, and the playground POST carry none; every OpenAPI write operation isdeprecated: truewith the declarative-paths description, and no read/non-resource operation is marked.cargo run -p aisix-admin --bin dump-openapiverified idempotent (two consecutive runs byte-identical); no checked-in artifacts change (resource schemas are untouched).cargo fmt/cargo clippy --workspace --all-targets -- -D warnings/cargo test --workspaceclean.