Skip to content

fix(agent): a CNI ADD whose snapshot is installed succeeds although an open watch was not answered from it (#1620) - #1631

Merged
bpalermo merged 1 commit into
mainfrom
fix/1620-cni-watch-not-answered
Oct 10, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/1620-cni-watch-not-answered

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Closes #1620

What was wrong

Since #1625 a snapshot build that could not hand a response to an open watch within its bound returns cache.ErrWatchNotAnswered, wrapped by every mutator. The snapshot is installed and is the one every later request is answered from. agent/internal/cni/server still treated that error as a build that failed: a CNI ADD was answered Internal, and the runtime tore down and retried a sandbox whose listeners were published.

What is true now

Every caller of the snapshot cache in the CNI server passes the mutator's error through one helper (snapshotInstalled, snapshotwatch.go). For errors.Is(err, cache.ErrWatchNotAnswered) it logs a WARN, counts, and returns nil. Every other error is returned unchanged.

Caller Before, on the sentinel Now
CNI ADD (AddPod) codes.Internal, sandbox retried RESULT_SUCCESS; the best-effort ACK wait still runs
CNI DEL (removePodListeners) RPC succeeded (best-effort), ERROR failed to remove listener RPC succeeds, WARN instead of the untrue ERROR
ghost sweep (pruneOnePod) ERROR failed to drop listener for pruned pod WARN instead of the untrue ERROR
surge takeover (ReconcileStorage) step logged as takeover step failed step succeeds

Any other error keeps what it had: the ADD is codes.Internal with failed to add listener: …, the DEL and the sweep log their ERROR, the takeover step returns the joined error.

What an operator sees

  • Log, WARN, one per change: pod's snapshot change is installed, but an open watch was not answered from it; not a failure, a later snapshot build sends the proxy the change, with pod, namespace, caller and error. The build's own WARN (snapshot installed, but an open watch was not answered from it, with snapshot_version) precedes it.
  • Metric: aether.agent.cni.snapshot_watch_unanswered{aether.snapshot.caller} (Prometheus aether_agent_cni_snapshot_watch_unanswered_total{aether_snapshot_caller}), caller one of cni_add, cni_del, takeover, ghost_sweep, each exported at zero. It is not expected to move (agent: one unread xDS watch can stall every snapshot build on the node #1619). Documented in docs/runbook.md beside the build's line.

How it is tested

The server now holds the cache behind a three-method interface (podSnapshots), so a test can return the sentinel without waiting out the cache's 5 s bound, which this package cannot shorten. NewCNIServer still takes *cache.SnapshotCache.

snapshotwatch_test.go, per caller, the sentinel and another error:

  • seen red against the unchanged behaviour (the helper returning its error as it is): the ADD returned Internal, the DEL and the sweep logged ERROR and counted nothing, the takeover returned the error;
  • mutation: a helper that forgives every error fails the four "snapshot not built" cases.

Run locally: //agent/internal/cni/server:server_test (also under --config=race), //test/harnesscontract:checks, //agent/internal/cmd/..., the lint build over //... with fail_on_violation, make format-check.

No chart change. The external-harness contract is unchanged (a new metric, in no closed set).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…n open watch was not answered from it (#1620)

Since #1625 a snapshot build that could not hand a response to an open watch
within its bound returns cache.ErrWatchNotAnswered: the snapshot is installed
and served. The CNI server still read it as a failed build.

Every caller of the snapshot cache in agent/internal/cni/server now passes the
mutator's error through one helper. For the sentinel it logs a WARN, adds one
to aether.agent.cni.snapshot_watch_unanswered{aether.snapshot.caller} and
returns nil; every other error is returned unchanged.

- CNI ADD: answered with success instead of Internal, so the runtime no
  longer tears down and retries a sandbox whose listeners are published.
- CNI DEL and the ghost sweep: already best-effort; they no longer log that
  the listener was not removed when it was.
- surge takeover: the step is no longer logged as failed for listeners that
  are installed.

The server holds the cache behind a three-method interface so a test can
return the sentinel without waiting out the cache's 5 s bound.

Closes #1620

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit fe95b64 into main Oct 10, 2026
30 checks passed
@bpalermo
bpalermo deleted the fix/1620-cni-watch-not-answered branch October 10, 2026 09:13
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.

agent: callers are told a snapshot build failed when the snapshot was installed and is being served

1 participant