Repository navigation
feat(BA-8643): add compare_and_replace_prefixes to AbstractKVStore - #15988
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks done
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused addition preserves existing replacement logic, follows conditional-write patterns, and has no identified blocking defects.
No open issues 🎉
What changed in this PR
Adds guarded subtree replacement to the shared AsyncEtcd client, enabling conditional configuration updates for the AppProxy Traefik ingress work.
Changes:
- Adds
compare_and_replace_prefixes, which commits replacements only when every guard matches, withNonechecking key absence. - Shares replacement-operation construction with
atomic_replace_prefixes. - Adds tests for matching, changed, and absent guards, plus a feature changelog entry.
| File | Description |
|---|---|
tests/unit/common/test_etcd.py |
Tests successful replacement and preservation when a guard fails. |
src/ai/backend/common/etcd.py |
Adds guarded transactions and extracts the shared replacement helper. |
changes/15988.feature.md |
Documents the new guarded replacement method. |
Review effort: Balanced
jopemachine
marked this pull request as draft
October 22, 2026 05:40
AgentEtcdClientView forwards it with the agent's scope prefixes, as it does the other conditional writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jopemachine
marked this pull request as ready for review
October 22, 2026 06:12
HyeockJinKim
approved these changes
Oct 22, 2026
HyeockJinKim
left a comment
Collaborator
There was a problem hiding this comment.
It seems like there are a few more etcd calls than usual, but let's put this task aside for now and address it in a follow-up issue.
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.
Part of the AppProxy worker Ingress work (epic BA-8433). Independent of the coordinator stack; #15893 (
TraefikWorkerClient) builds on it and carries these commits until this merges. Replaces #15916, whose branch was recreated.Resolves #15914 (BA-8643)
Summary
AbstractKVStore.compare_and_replace_prefixes(replacements, *, guards)replaces the subtrees asatomic_replace_prefixesdoes, only when every guard key holds its given value at commit (None: the key is absent).Truewhen the replacement landed andFalsewhen a guard failed, leaving the subtrees as they were.AsyncEtcdruns it through_request(..., conditional=True)like the existing conditional writes.AgentEtcdClientViewforwards it with the agent's scope prefixes, as it doescompare_and_putandcompare_and_delete.atomic_replace_prefixesand the new method share_replacement_ops, which builds the deletes of stale keys and the puts of new ones.Test plan
pants check/pants testontests/unit/common/test_etcd.pyandtests/unit/agent/test_etcd.pytests/unit/common/test_etcd.py— the subtree is replaced while the guard holds, left alone when the guard moved, and aNoneguard holds for an absent keytests/unit/agent/test_etcd.py— throughAgentEtcdClientView, the guard and the subtree resolve in the same agent scope: replaced while the guard holds, left alone when it moved🤖 Generated with Claude Code