Skip to content

fix(registry): namespace-qualify the kubernetes backend's service keys (020) - #427

Merged
bpalermo merged 1 commit into
mainfrom
fix/k8s-backend-namespace-qualified-keys
Jun 28, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/k8s-backend-namespace-qualified-keys

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

The kubernetes registry backend keyed endpoints by the BARE ServiceAccount name, unlike the CNI/etcd/ddb paths which use <ns>/<sa> (020). Because serviceref.ParseKey rejects bare keys, the mesh-Service generator skipped every SA-backed service, and same-named SAs collided across namespaces (echo-v1 in the two conformance namespaces) → merged endpoint set → oscillation → agent xDS churn (the suspected MeshFrontend root + the residual 3-fail flap).

Namespace-qualifies both ListAllEndpoints/ListEndpoints to match the rest. Production uses dynamodb/etcd (correct already), so low-risk there; this is the conformance backend. New TestListAllEndpoints_SameSANamespaceIsolation proves the cross-namespace isolation; existing cases updated to <ns>/<sa>. The soft mesh-http job will confirm the conformance score impact post-merge. 🤖 Generated with Claude Code

…s (020)

The kubernetes registry backend keyed endpoints by the BARE pod ServiceAccount
name, while the CNI registration path (registry/cni.go) and the etcd/ddb backends
all key by the namespace-qualified "<ns>/<sa>" (proposal 020 Part 1). Two
consequences with the kubernetes backend:

- serviceref.ParseKey REJECTS bare keys (no "/"), so the mesh-Service VIP generator
  skipped EVERY SA-backed service ("malformed non-namespaced key") — no SA-backed
  mesh Services, so that traffic fell to the redirect-all passthrough / kube-proxy.
- same-named ServiceAccounts in different namespaces (e.g. echo-v1 in two
  conformance namespaces) collided into ONE bare "echo-v1" entry whose merged
  endpoint set then oscillated and churned the agent's xDS snapshot.

Key by serviceref.New(pod.Namespace, pod.Spec.ServiceAccountName).Key() in both
ListAllEndpoints and ListEndpoints, matching the rest. Production uses dynamodb/etcd
(already correct), so this is low-risk there; it is the conformance backend
(registryBackend: kubernetes) and the suspected MESH-HTTP MeshFrontend root.

Tests: existing cases updated to "<ns>/<sa>"; new TestListAllEndpoints_SameSA
NamespaceIsolation proves two namespaces no longer collide. Conformance impact (the
mesh-http job is soft) to be confirmed by the post-merge run.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
@bpalermo
bpalermo merged commit a937024 into main Jun 28, 2026
13 checks passed
@bpalermo
bpalermo deleted the fix/k8s-backend-namespace-qualified-keys branch June 28, 2026 23:34
bpalermo added a commit that referenced this pull request Jun 28, 2026
…ckends (#428)

Follow-up to #427 (the kubernetes backend had silently bypassed serviceref). Adds a
shared registrytest.RequireNamespaceQualifiedKeys the key-DERIVING backends run on
their ListAllEndpoints output, asserting (1) every key is a serviceref-parseable
"<ns>/<sa>" and (2) no endpoint's namespace disagrees with its key's namespace
(the cross-namespace collision). Wired into the kubernetes backend test.

The keying format is centralized in common/serviceref and the write path qualifies
once in registry/cni.go; storage backends (etcd/dynamodb) are key-agnostic
passthroughs of the caller's key, so the contract targets the backends that DERIVE
keys (kubernetes today) — the place divergence can recur.


Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S

Co-authored-by: Claude Opus 4.8 <[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