Skip to content

fix(cni): Keep traffic policy classifying when the shard watch is down - #1100

Merged
privateip merged 2 commits into
mainfrom
fix/issue-1084
Oct 25, 2026
Merged

privateip merged 2 commits into
mainfrom
fix/issue-1084

Conversation

@privateip

@privateip privateip commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In hashed egress mode, the CNI agent that starts without a working shard watch drops every packet arriving for the node's tenant workloads.

Traffic policy can't tell a NAT shard's traffic from private traffic until it knows the shard addresses, and it only learned them from the watch. Replies to tenant egress and private traffic from other sites failed classification and were dropped.

Traffic policy now learns the configured shards and the shards the node already routes to on every sweep, so it classifies from the first sweep and the watch adds the rest, while a node that knows no shard keeps failing closed.

Test plan

  • Unit tests: a sweep with the watch not started, unsynced or failing still hands traffic policy every shard the node can egress through
  • Unit tests: a node with no known shard keeps traffic policy unsynced until the watch syncs
  • Lab: tenant traffic is delivered with the shard watch denied

Related to #1084

🤖 Generated with Claude Code

In hashed egress mode, galactic-cni gave traffic policy its NAT shard locators only after the EgressShard watch had listed the cluster. Every restart resets the datapath's "locators synced" flag, so a node whose watch could not start classified every encapsulated path as unknown, and any rule naming a path dropped the packet with reason classification_error. Tenant egress still left through the shards, but the replies and all private traffic from other nodes were dropped at the workload.

Each sweep now hands traffic policy every shard SID the node can egress through: the configured shards, every member of a published shard group, and the watch's shards once it has synced. usid_egress sends only to configured shards or published group members, so that set covers every path the node can take before the watch syncs. A sweep that cannot read a group skips the update rather than mark an incomplete set complete. A datapath without the shard group map hands over the configured shards, the only ones it can route to.

Fixes #1084

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@privateip privateip self-assigned this Oct 25, 2026
Before the EgressShard watch has synced, the sweep handed traffic policy the seeded shard SIDs even when the seed was empty. An empty set marked the NAT locators complete, so a reply from an unknown shard was classified as private instead of being dropped. The sweep now calls the locator hook before the watch syncs only when the seed holds at least one SID. A node with no configured shard and no published group keeps traffic policy unsynced until the watch lists the shards. Once the watch has synced, the behavior is unchanged.

Also reword the knownShardSIDs doc comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@privateip
privateip marked this pull request as ready for review October 25, 2026 17:07
@privateip
privateip requested a review from a team as a code owner October 25, 2026 17:07
@privateip
privateip enabled auto-merge October 25, 2026 17:08
@privateip
privateip merged commit 271a223 into main Oct 25, 2026
22 of 23 checks passed
@privateip

Copy link
Copy Markdown
Contributor Author

Review record for head a997ac9.

First pass: pr-adversary returned merge with one warning (an empty locator set was marked complete before the shard watch synced) and one decision (the lab check of the active/active egress verify step is unrun). pr-conventions-reviewer returned merge with nits.

Second pass on a997ac9: pr-rereviewer confirmed all three applied findings fixed (the empty-seed guard with a test that fails when the guard is reverted, the doc comment on the known shard SIDs, and the PR body wording and issue link) and returned merge. Its one remaining nit, about the commit trailer, is not applied. pr-conventions-reviewer returned VERDICT merge; its nit to fold the fix commit into the first is not applied, because the branch is not force-pushed.

What ran. pr-rereviewer: git diff b09db74...a997ac9, git log --show-signature, gh pr view, go test ./internal/installer/ (pass), a tamper test reverting the guard (failed as intended), gofmt -l. pr-conventions-reviewer: gh pr view, git diff and git log, gh pr list for collisions (none; #598 touches different installer files), and the repository conventions document.

Applied findings: the empty-seed guard and its test, the doc comment, and the PR body rewrite, all in the fix commit a997ac9.

Deferred by decision: the lab check of the active/active egress verify step has not been run. The decision was to proceed without it, and the PR links the issue with "Related to" so the issue stays open until the lab run passes.

CI: every check on a997ac9 passed. The E2E job was cancelled once while installing build dependencies (a runner timeout, unrelated to the change) and passed on rerun.

Auto-merge is enabled with the merge method, the only one the ruleset on main allows. The ruleset requires one approving review and a code owner review, and dismisses approvals on push, so the PR waits for a human approval. No human reviewer is configured beyond the code owners.

@privateip
privateip deleted the fix/issue-1084 branch October 25, 2026 17:14

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

Watch-down start now classifies from configured shards plus published group members, and the empty-seed case still fails closed. Locators are add-only keyed on the top 64 bits, so a stale or removed shard cannot misclassify anything unless its /64 collides with a router locator, which the existing design treats as disjoint.

  • egressgroup.go (sweepHashed): the group members are read before applyClasses runs, so on the sweep where the watch syncs with a changed shard set the locators come from the old group contents plus the new watch list. The next sweep catches up; harmless because locators are add-only.
  • A group read error skips the update and leaves the previous locators and synced flag as they were. A node that has never synced stays unsynced and fails closed, which is correct.
  • Tests cover not-started, unsynced, failing and synced watches, the empty seed, and the no-group-map path. Each case asserts the exact SID set.

Follow-ups:

  • No test for the watch returning with a different shard set. Add-only behavior is documented in setNATLocators but not pinned by a test here.
  • Removed shards' locators stay until the agent restarts. Fine while shard locators are disjoint from router locators; worth an assertion or startup check if that ever stops being guaranteed.

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.

Hashed egress drops all tenant ingress when the EgressShard watch cannot start

3 participants