api: add Config Entries and Discovery Chain endpoints#121
Merged
mbrulatout merged 3 commits intoJul 3, 2026
Conversation
added 3 commits
July 2, 2026 13:01
Adds consul.config for the generic Kind/Name-based config entry endpoint (PUT/GET/GET-list/DELETE /v1/config), covering all config entry kinds (service-defaults, service-router, proxy-defaults, mesh, ingress-gateway, etc.) through one implementation rather than modeling each kind's schema individually. cas (check-and-set) support included on both set() and delete(). Note: DELETE /v1/config/:kind/:name returns an empty object when no cas is given, but a real JSON boolean when cas is passed -- callback choice (CB.boolean vs CB.json) branches on that.
Adds consul.discovery_chain.get(), covering both the plain GET (no overrides) and the POST variant Consul requires when passing OverrideConnectTimeout/OverrideProtocol/OverrideMeshGateway.
master doesn't have this fix yet (PR criteo#120 is still pending review), so any branch cut from master right now hits the same sqlite3.OperationalError: database is locked INTERNAL ERROR in CI. Carrying the fix here too so this PR's CI is green independently. Trivial to reconcile on rebase once criteo#120 merges.
mougams
approved these changes
Jul 3, 2026
This was referenced Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the ongoing API-parity work (follow-up to #120). Adds two more endpoint groups:
consul/api/config.py) — generic CRUD for/v1/config, covering all config entry kinds (service-defaults, service-router, service-splitter, service-resolver, proxy-defaults, mesh, ingress-gateway, terminating-gateway, exported-services, api-gateway, etc.) through one Kind/Name-based implementation rather than modeling every kind's schema individually. Includescas(check-and-set) support on bothset()anddelete().consul/api/discovery_chain.py) —consul.discovery_chain.get(), covering both the plain GET and the POST variant Consul requires when passing override parameters (connect timeout, protocol, mesh gateway mode).Not included, on purpose:
consul/std.py,consul/aio.py) unconditionally decode every response body as UTF-8 text. Implementing Snapshot correctly needs a small transport-layer change (an opt-in raw/binary response mode) that's a distinct, separate piece of work deserving its own isolated review rather than being bundled into an "add a CRUD module" PR. Will follow up separately.A bug this surfaced
While testing
Config.set()/delete()withcas, I found thatPUT /v1/configalways returns a literal JSON boolean (true/false) reflecting whether the CAS check passed — butDELETE /v1/config/:kind/:namereturns an empty object ({}) when nocasis given, and only returns a real boolean whencasis passed. UsingCB.boolean()(which only checks the HTTP status code, not body content) would have silently reported CAS failures as successes. Fixed by usingCB.json()forset(), and branching betweenCB.boolean()/CB.json()indelete()based on whethercaswas supplied. Verified against a live Consul instance before writing the test assertions.Base branch note
This branches off
master, not off #120 — the two PRs touch disjoint files except for.pre-commit-config.yaml's mypy fix, which is carried over here too (see last commit) since master doesn't have it yet.ENDPOINT_STATUS.mdisn't touched in this PR since it doesn't exist onmasteryet (it's new in #120); I'll add Config Entries/Discovery Chain rows to it once this rebases past #120's merge.Test plan
mypy consul/ --no-sqlite-cache— cleanruff check ./ruff format --diff .— cleantests/api/test_config.pyandtests/api/test_discovery_chain.py, run against real dockerized Consul (1.20.6/1.21.5/1.22.0) — all passing, including both CAS-success and CAS-failure paths onset()anddelete()