Skip to content

feat(registrar): etcd watch — sync at watch speed, not the 5s poll - #174

Merged
bpalermo merged 1 commit into
mainfrom
feat/etcd-watch-sync
Jun 13, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/etcd-watch-sync

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

The etcd backend implements registry.ChangeNotifier via clientv3.Watch; the registrar Syncer reacts to Changes() (200ms debounce) on top of the periodic poll (kept as backstop). Closes the cross-replica last-old-exit skew on etcd (~6s → sub-second) and makes cross-cluster convergence watch-speed when registrars share an external etcd. DynamoDB unchanged (poll-only). Agents still go through the registrar — never etcd directly (apiserver-style watch cache; see the registrar-etcd analysis).

Tests: etcd Changes() fires on register/unregister (real etcd container); Syncer change-driven sync beats the poll interval.

🤖 Generated with Claude Code

The etcd backend now implements registry.ChangeNotifier via clientv3.Watch
over the key prefix: any write (from this replica, the peer replica, or any
cluster sharing the etcd) signals consumers in ~ms. The registrar Syncer
reacts to Changes() (debounced 200ms to coalesce roll bursts) in addition to
the periodic poll, which stays as the backstop for events missed during a
watch re-establish (compaction, leader change). Backends without
notifications (DynamoDB) are unchanged (poll-only).

This closes the cross-replica last-old-exit skew on the etcd backend: the
lagging replica learns a write at watch speed instead of waiting out its 5s
sync cycle, so the ~6s tail-of-roll window collapses to sub-second. It also
makes cross-cluster convergence (registrars sharing an external etcd)
watch-speed, per the registrar-etcd analysis. Native CDC at the registrar
tier — agents still go through the registrar (apiserver-style watch cache),
never etcd directly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo merged commit a51a21b into main Jun 13, 2026
9 checks passed
@bpalermo
bpalermo deleted the feat/etcd-watch-sync branch June 13, 2026 17:42
bpalermo added a commit that referenced this pull request Sep 12, 2026
The dynamodb backend only ever implemented the base registry.Registry
interface. Everything the registrar gained since June is etcd-only:
watch-driven sync (ChangeNotifier, #174), the cross-cluster config plane
(ConfigExporter/ConfigImporter, proposal 026), ServiceExporter, and the
multi-region mirror (proposal 006). On DynamoDB the registrar fell back to
the 5 s poll and config propagation did not work at all. The 2026-06-13
directive already ruled out global tables for multi-region, talos-main has
been on etcd since rev 47, and the chart default is the zero-infra
kubernetes backend. Supported backends are now kubernetes and etcd — the
same shape as the Cloud Map removal (#150).

Backend + Go code
- Delete registry/internal/ddb/ (dynamodb.go, dynamodb_test.go, BUILD.bazel).
- registry/backend/backend.go: drop the dynamodb case and the AWS config
  loading; error text is now "supported: kubernetes, etcd". ctx is unused by
  the two remaining constructors, so the parameter is kept but blanked.
- registrar/internal/cmd: flag help + comments -> "kubernetes or etcd";
  config_test's round-trip case switches to etcd.
- common/constants: remove DefaultDynamoDBServiceTableName. registry.go held
  only the package doc afterwards, so it is renamed to doc.go.
- Comment-only rewording: registry/registry.go, registry/registrytest,
  registry/registrarclient, registrar/internal/server/{server,sync}.go,
  agent/internal/cmd/root.go.

Codegen
- api/aether/registry/v1/service.proto: drop the proto/dynamo/v1 import and
  the (dynamo.v1.msg).key option. Edition stays 2023 (gRPC still caps there;
  never lower an edition).
- api/aether/registry/v1/BUILD.bazel: drop the protoc-gen-dynamo proto dep
  and //bazel/go:go_dynamo from compilers.
- Delete bazel/go:go_dynamo, the two root gazelle:resolve directives for
  proto/dynamo/v1, the go_dynamo entry in gazelle:go_proto_compilers, and the
  .pb.dynamo.go exclusion in bazel/lint/gocognit.bzl.
- The api/aether/{agent,config}/v1 BUILD comments explaining why those
  packages avoid go_dynamo are moot; the per-package
  gazelle:go_proto_compilers directives they carried are now the root default,
  so both go with them.

Dependencies
- Removed direct: aws-sdk-go-v2, /config, /credentials,
  /feature/dynamodb/attributevalue, /service/dynamodb, pquerna/protoc-gen-dynamo,
  testcontainers-go/modules/dynamodb.
- Removed indirect: aws-sdk-go-v2/{feature/ec2/imds, internal/configsources,
  internal/endpoints/v2, internal/ini, internal/v4a,
  service/dynamodbstreams, service/internal/accept-encoding,
  service/internal/endpoint-discovery, service/internal/presigned-url,
  service/signin, service/sso, service/ssooidc, service/sts}, aws/smithy-go,
  dave/jennifer, lyft/protoc-gen-star/v2 — and with it the pquerna
  protoc-gen-star fork replace directive.
- klauspost/compress is KEPT (moby/go-archive needs it) but demoted to
  indirect. The Masterminds/sprig chain (semver, sprig, aokoli/goutils,
  huandu/xstrings, imdario/mergo) is KEPT: pseudomuto/protoc-gen-doc, the
  website API-doc generator, needs it.
- bazel mod tidy dropped 8 use_repo(go_deps, ...) entries: the five AWS
  repos, com_github_klauspost_compress, com_github_pquerna_protoc_gen_dynamo,
  com_github_testcontainers_testcontainers_go_modules_dynamodb.
- go.mod 251 -> 209 lines. go.sum is unchanged: pruning it needs `go mod tidy`,
  which is forbidden here and would additionally strip the repo's Bazel-only
  direct requires (protoc-gen-doc, protokit). The stale entries are inert.
- The cel.dev/expr gazelle_override is unrelated (cel-go#1184) and stays.

Chart (0.92.14 -> 0.92.16)
- values.yaml: backend enum comment -> "kubernetes, etcd"; delete the
  registrar.aws block; reword the agent's AWS-credentials note.
- registrar-serviceaccount.yaml: drop the IRSA eks.amazonaws.com/role-arn
  annotation block.
- registrar-deployment.yaml: drop the AWS_REGION env block.

Docs
- docs/registry-backend-evolution.md: status line now lists kubernetes + etcd,
  section 3 is marked dropped, and a new dated section 5 records the removal
  and its rationale in the style of the Cloud Map entry.
- docs/{runbook,getting-started,configuration}.md, README.md, AGENTS.md,
  CLAUDE.md: backend lists, AWS values, and protoc-gen-dynamo mentions.
- docs/proposals/* left untouched (historical).

Verification
- bazel build //... green; bazel test //... 98/98 pass, including the etcd
  testcontainers integration test and the chart lint/template tests.
- make format-check clean; bazel build --config=lint //... clean.
- make gazelle idempotent (diff hash identical across two runs);
  bazel mod tidy idempotent.
- scripts/check-chart-version-bump.sh origin/upgrade/go-1.27: 0.92.15 ->
  0.92.16 OK.
- The issue's grep gate returns only explainable hits: "writeRawState" and
  "withdraws" (substring false positives) and the edge Gateway TLS
  SECRET_PROVIDER_AWS_SECRETS_MANAGER enum, a reserved, not-implemented
  provider unrelated to the registry backend.

Out of scope per the issue: the registrar's write-behind pending-shield and
the out-of-repo AetherService table / IAM role cleanup.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo added a commit that referenced this pull request Sep 12, 2026
The dynamodb backend only ever implemented the base registry.Registry
interface. Everything the registrar gained since June is etcd-only:
watch-driven sync (ChangeNotifier, #174), the cross-cluster config plane
(ConfigExporter/ConfigImporter, proposal 026), ServiceExporter, and the
multi-region mirror (proposal 006). On DynamoDB the registrar fell back to
the 5 s poll and config propagation did not work at all. The 2026-06-13
directive already ruled out global tables for multi-region, talos-main has
been on etcd since rev 47, and the chart default is the zero-infra
kubernetes backend. Supported backends are now kubernetes and etcd — the
same shape as the Cloud Map removal (#150).

Backend + Go code
- Delete registry/internal/ddb/ (dynamodb.go, dynamodb_test.go, BUILD.bazel).
- registry/backend/backend.go: drop the dynamodb case and the AWS config
  loading; error text is now "supported: kubernetes, etcd". ctx is unused by
  the two remaining constructors, so the parameter is kept but blanked.
- registrar/internal/cmd: flag help + comments -> "kubernetes or etcd";
  config_test's round-trip case switches to etcd.
- common/constants: remove DefaultDynamoDBServiceTableName. registry.go held
  only the package doc afterwards, so it is renamed to doc.go.
- Comment-only rewording: registry/registry.go, registry/registrytest,
  registry/registrarclient, registrar/internal/server/{server,sync}.go,
  agent/internal/cmd/root.go.

Codegen
- api/aether/registry/v1/service.proto: drop the proto/dynamo/v1 import and
  the (dynamo.v1.msg).key option. Edition stays 2023 (gRPC still caps there;
  never lower an edition).
- api/aether/registry/v1/BUILD.bazel: drop the protoc-gen-dynamo proto dep
  and //bazel/go:go_dynamo from compilers.
- Delete bazel/go:go_dynamo, the two root gazelle:resolve directives for
  proto/dynamo/v1, the go_dynamo entry in gazelle:go_proto_compilers, and the
  .pb.dynamo.go exclusion in bazel/lint/gocognit.bzl.
- The api/aether/{agent,config}/v1 BUILD comments explaining why those
  packages avoid go_dynamo are moot; the per-package
  gazelle:go_proto_compilers directives they carried are now the root default,
  so both go with them.

Dependencies
- Removed direct: aws-sdk-go-v2, /config, /credentials,
  /feature/dynamodb/attributevalue, /service/dynamodb, pquerna/protoc-gen-dynamo,
  testcontainers-go/modules/dynamodb.
- Removed indirect: aws-sdk-go-v2/{feature/ec2/imds, internal/configsources,
  internal/endpoints/v2, internal/ini, internal/v4a,
  service/dynamodbstreams, service/internal/accept-encoding,
  service/internal/endpoint-discovery, service/internal/presigned-url,
  service/signin, service/sso, service/ssooidc, service/sts}, aws/smithy-go,
  dave/jennifer, lyft/protoc-gen-star/v2 — and with it the pquerna
  protoc-gen-star fork replace directive.
- klauspost/compress is KEPT (moby/go-archive needs it) but demoted to
  indirect. The Masterminds/sprig chain (semver, sprig, aokoli/goutils,
  huandu/xstrings, imdario/mergo) is KEPT: pseudomuto/protoc-gen-doc, the
  website API-doc generator, needs it.
- bazel mod tidy dropped 8 use_repo(go_deps, ...) entries: the five AWS
  repos, com_github_klauspost_compress, com_github_pquerna_protoc_gen_dynamo,
  com_github_testcontainers_testcontainers_go_modules_dynamodb.
- go.mod 251 -> 209 lines. go.sum is unchanged: pruning it needs `go mod tidy`,
  which is forbidden here and would additionally strip the repo's Bazel-only
  direct requires (protoc-gen-doc, protokit). The stale entries are inert.
- The cel.dev/expr gazelle_override is unrelated (cel-go#1184) and stays.

Chart (0.92.14 -> 0.92.16)
- values.yaml: backend enum comment -> "kubernetes, etcd"; delete the
  registrar.aws block; reword the agent's AWS-credentials note.
- registrar-serviceaccount.yaml: drop the IRSA eks.amazonaws.com/role-arn
  annotation block.
- registrar-deployment.yaml: drop the AWS_REGION env block.

Docs
- docs/registry-backend-evolution.md: status line now lists kubernetes + etcd,
  section 3 is marked dropped, and a new dated section 5 records the removal
  and its rationale in the style of the Cloud Map entry.
- docs/{runbook,getting-started,configuration}.md, README.md, AGENTS.md,
  CLAUDE.md: backend lists, AWS values, and protoc-gen-dynamo mentions.
- docs/proposals/* left untouched (historical).

Verification
- bazel build //... green; bazel test //... 98/98 pass, including the etcd
  testcontainers integration test and the chart lint/template tests.
- make format-check clean; bazel build --config=lint //... clean.
- make gazelle idempotent (diff hash identical across two runs);
  bazel mod tidy idempotent.
- scripts/check-chart-version-bump.sh origin/upgrade/go-1.27: 0.92.15 ->
  0.92.16 OK.
- The issue's grep gate returns only explainable hits: "writeRawState" and
  "withdraws" (substring false positives) and the edge Gateway TLS
  SECRET_PROVIDER_AWS_SECRETS_MANAGER enum, a reserved, not-implemented
  provider unrelated to the registry backend.

Out of scope per the issue: the registrar's write-behind pending-shield and
the out-of-repo AetherService table / IAM role cleanup.

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