Skip to content

Add etcd-backed service registry - #20

Merged
bpalermo merged 2 commits into
mainfrom
feat/etcd-registry
Mar 7, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/etcd-registry

Conversation

@bpalermo

@bpalermo bpalermo commented Mar 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement etcd backend for the Registry interface, storing service endpoints in a hierarchical key structure (/aether/services/<service>/protocols/<protocol>/endpoints/<ip>) with protobuf serialization
  • Add --registry-backend and --etcd-endpoints agent flags to select between DynamoDB and etcd at runtime
  • Include integration tests using testcontainers-go with a real etcd container

Files changed

File Description
registry/internal/etcd/etcd.go Core etcd registry implementation
registry/internal/etcd/etcd_test.go Integration tests with testcontainers
registry/etcd.go Factory function and EtcdConfig type alias
agent/pkg/cmd/root.go Registry backend selection in setupRegistry()
agent/pkg/cmd/config.go New config fields for backend selection
constants/registry.go DefaultEtcdKeyPrefix constant
MODULE.bazel, go.mod, go.sum etcd client + testcontainers dependencies

Test plan

  • All existing tests pass (bazel test //...)
  • etcd integration tests pass with testcontainers (bazel test //registry/internal/etcd:etcd_test)
  • Manual: run agent with --registry-backend etcd --etcd-endpoints localhost:2379

🤖 Generated with Claude Code

bpalermo and others added 2 commits March 7, 2026 14:09
Implement an etcd backend for the Registry interface as an alternative
to DynamoDB. Endpoints are stored in a hierarchical key structure
using protobuf serialization. The agent now supports --registry-backend
and --etcd-endpoints flags to select the backend at runtime.

Includes integration tests using testcontainers-go with a real etcd
instance.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Testcontainers-based tests need more time than the default "small"
size allows in Bazel.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@bpalermo
bpalermo merged commit 6f9e7ff into main Mar 7, 2026
1 check passed
@bpalermo
bpalermo deleted the feat/etcd-registry branch March 7, 2026 17:32
bpalermo added a commit that referenced this pull request Sep 13, 2026
…oval (#767) (#769)

* chore(deps): add a repeatable Go dependency audit (#767)

`go mod tidy` is structurally unusable in this repository: the generated
proto packages `aethermesh.dev/api/aether/*/v1` exist only as Bazel
outputs, so the Go tool fails with "no matching versions for query
latest" on every import of them, and `go mod tidy -e` strips modules that
only generated code or a BUILD file needs (which then breaks the
`gazelle_override`s and `bazel mod tidy`).

So drive the audit from the module graph and the Bazel graph instead:

* stale go.sum modules = go.sum modules outside `go list -m all` (fatal);
* direct requires with no Go import, no `@repo//` reference in any
  BUILD/.bzl file and no `tool` directive (fatal);
* direct requires with no Go import that ARE Bazel-referenced and are not
  annotated `// bazel-only:` (warning) — the fix for a version pin is to
  reclassify it as indirect, never to delete it.

`go list -m all` runs as a subprocess of `bazel run`, so `--repo_env` does
not reach it; the script exports GOPROXY itself.

Wired as `make deps-audit` and as a `deps-audit` job in ci.yaml (in the
`ci` fan-in's needs). Deliberately cheap: `go list -m all` plus greps, no
bazel build.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* chore(deps): prune 27 stale modules from go.sum (#767)

Every one of these modules is outside the module build list
(`go list -m all`), i.e. nothing in go.mod can resolve to them any more —
residue left by the DynamoDB removal (#764) and by earlier bumps that
`bazel mod tidy` does not prune and `go mod tidy` cannot be run to prune:
the whole aws-sdk-go-v2 tree, smithy-go, protoc-gen-dynamo,
protoc-gen-star, jennifer, the dynamodb/localstack testcontainers
modules, otelzap and kr/pty.

-243 lines (1,458 -> 1,215), 277 -> 250 modules.

Verified that nothing removed was needed: `go mod download` over all 318
modules of the build list succeeds and adds no line back, `bazel build
//... //test/e2e:e2e_test` is green (gazelle's go_deps verifies every
module it fetches against go.sum), `bazel test //...` is 98/98, and
`bazel mod tidy` is a no-op.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* chore(deps): drop the unused embedded-etcd modules (#767)

`go.etcd.io/etcd/server/v3` and `go.etcd.io/raft/v3` came in with the
original etcd backend (#20) for an embedded etcd server that was never
used: neither is imported by any .go file and neither is reachable from
`deps(//... + //test/e2e:e2e_test + //website:all)`. The registry backend
and the testcontainers etcd module use only `client/v3` + `api/v3`, which
stay.

`go get <mod>@none` is NOT usable here: `@none` downgrades every module
that requires the removed one, and k8s.io/[email protected]
requires etcd/server/v3 — it took controller-runtime 0.25.0 -> 0.9.7,
e2e-framework 0.7.0 -> 0.0.5 and apiextensions-apiserver -> 0.22.0-alpha.3
with it. `go mod edit -droprequire` removes the requirement without
touching anyone's selected version, which is what is wanted.

Also dropped the 22 indirect requires that existed only to satisfy those
two (bbolt, etcd/pkg/v3, cmux, probing, grpc-websocket-proxy,
golang-jwt/v5, groupcache, btree, go-humanize, gogo/protobuf, clockwork,
afero, go-strcase, vtprotobuf, morikuni/aec, pkg/errors, google/cel-go,
go-cmp, easyjson, intern, go-grpc-middleware v1 and its prometheus
provider) — each verified absent from the Bazel build graph first — and
the two now-dangling `go_deps.gazelle_override` blocks plus the
`io_etcd_go_etcd_server_v3` `use_repo` entry, without which the go_deps
extension fails with "Some gazelle_overrides did not target a Go module
with a matching path".

go.mod 207 -> 183 requires (75 -> 74 direct, 132 -> 109 indirect); the
module build list 318 -> 295; go.sum 1,215 -> 1,189 lines after re-running
the stale-module prune (18 more modules fell out of the graph).
etcd/server/v3 itself stays in the build list at v3.7.0 as a transitive
requirement of apiextensions-apiserver — it is simply no longer ours, and
gazelle no longer generates a repository for it.

Verified: `bazel build //... //test/e2e:e2e_test`, `bazel test //...`
98/98 (incl. //registry/internal/etcd:etcd_test and //website:site_test),
`bazel run //:gazelle` no churn, `bazel mod tidy` idempotent, and
`go mod download` over all 295 modules adds nothing back.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* chore(deps): reclassify pinned-but-unimported requires as indirect (#767)

21 direct requires have no Go import anywhere in the repo, no BUILD/.bzl
reference and no `tool` directive. They exist to force a CVE-clean
version through MVS, so the rule is reclassify, never drop: the pin (and
therefore the selected version) survives, only the directness changes.

Moved to the indirect block: golang.org/x/crypto, golang.org/x/time,
github.com/go-jose/go-jose/v4, github.com/go-openapi/swag and its 11
sub-modules, github.com/moby/spdystream, github.com/mxk/go-flowrate,
github.com/vladimirvivien/gexe, github.com/zeebo/errs,
github.com/blang/semver/v4 and k8s.io/component-base. Diffing the
module/version pairs before and after (including after `bazel mod tidy`)
shows the only change is the `// indirect` markers — not one version
moved.

Annotated, and kept direct:
* buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go —
  `// bazel-only:`, it is only ever named by the `gazelle:resolve`
  directive in //BUILD.bazel;
* github.com/uudashr/gocognit — `// bazel-only:`, the lint aspect's
  binary (//bazel/lint/linters.bzl); it is also a `tool` directive.
The other two "Bazel-only" tools in #767, protoc-gen-doc and protokit,
turn out to be genuine Go imports — //bazel/protodoc/main.go wraps them —
so they are marked `// build tooling:` instead of `// bazel-only:`, which
would have been untrue.

`bazel mod tidy` then dropped the 21 corresponding `use_repo` entries:
75 -> 53. go.mod is 183 requires, 53 direct / 130 indirect.

scripts/go-deps-audit.sh is now clean (exit 0) on the whole tree.
Verified: `bazel build //... //test/e2e:e2e_test`, `bazel test //...`
98/98, `bazel run //:gazelle` no churn, `bazel mod tidy` idempotent,
`make format-check`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* chore(deps): bump github.com/moby/go-archive to v0.3.3 (#767)

Closes the one open Go Dependabot alert: GHSA-hfg8-hc9c-6c3h, high,
`< 0.3.0`, reached indirectly through testcontainers-go. testcontainers-go
v0.44.0 is the newest release and still pins go-archive v0.2.0, so there
is no upstream bump to ride — the floor has to be raised here.

* github.com/moby/go-archive v0.2.0 -> v0.3.3 (>= the 0.3.0 fix)
* github.com/moby/sys/user v0.4.0 -> v0.4.1 (pulled by the above)

`go get` marks what it fetches as a direct require; nothing imports
go-archive, so it is put back in the indirect block — it is a pure MVS
floor, the same shape as the other CVE pins, and leaving it direct would
(rightly) fail scripts/go-deps-audit.sh.

Verified: `bazel build //... //test/e2e:e2e_test`, `bazel test //...`
98/98 with //registry/internal/etcd:etcd_test and
//registrar/internal/replicator:replicator_test actually re-executed (the
testcontainers path changed), `bazel run //:gazelle` no churn, `bazel mod
tidy` idempotent, `scripts/go-deps-audit.sh` exit 0.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs: write down why `go mod tidy` is forbidden here (#767)

A "Go dependency hygiene" subsection in the developer runbook: what
`make deps-audit` reports and why it exists, why `go mod tidy` (and
especially `go mod tidy -e`) cannot be trusted in this module, the
reclassify-don't-drop rule for CVE version pins, why `go get` needs its
`// indirect` marker put back by hand, why removals use `go mod edit
-droprequire` rather than `go get <mod>@none`, and what a `// bazel-only:`
annotation means.

AGENTS.md and CLAUDE.md pointed at `make tidy` as the way to "update
go.mod dependencies", which it is not — it syncs MODULE.bazel's use_repo.
Both now say what it does, mention `make deps-audit`, and state the
`go mod tidy` prohibition where an agent will actually read it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant