Skip to content

feat(agent): Cilium-style startup taint to gate pods on CNI readiness - #263

Merged
bpalermo merged 2 commits into
mainfrom
feat/agent-startup-taint
Jun 22, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/agent-startup-taint

Conversation

@bpalermo

@bpalermo bpalermo commented Jun 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

The aether CNI plugin fails-closed: until the node agent's gRPC CNI server is serving, a pod's CNI ADD errors and the kubelet retries. On a cold node — or an agent roll onto a fresh node — that leaves pods churning in ContainerCreating. This adds a Cilium-style startup taint (aether.io/agent-not-ready) so workload pods don't get scheduled onto a node until aether's CNI is actually functional.

This is the cold-start prevention layer of #261. The data-plane guaranteed-delete reorder (#262) and the storage↔pods reconcile (#264) are separate, already-merged changes.

What's here

  • common/constants — TaintAgentNotReady = aether.io/agent-not-ready.
  • agent/internal/node — TaintRemover, a manager Runnable that removes the taint from the agent's own node (cfg.NodeName) once the CNI server is serving (signalled by its Unix socket existing). Best-effort with retry; never fails agent startup. The filtering logic is a pure, unit-tested removeTaint(node, key) (changed bool). Gated by --remove-startup-taint (default true).
  • chart:
    • Tolerate the taint on every aether component — the agent + proxy DaemonSets and the controller, registrar, and edge Deployments. Only actual mesh-managed user workloads do not tolerate it (see below).
    • Agent ClusterRole: add nodes patch (it already had get/list/watch) so it can remove the taint.
    • values.yaml: document that the operator must register nodes with the taint (kubelet --register-with-taints=aether.io/agent-not-ready=true:NoSchedule; Talos machine.nodeTaints / kubelet extraArgs). The chart ships removal + tolerations + RBAC; it cannot taint nodes itself.
    • Chart bumped 0.18.0 → 0.19.0.

Toleration decision

The taint gates mesh-managed user workloads, which aether's own control plane is not — so every aether component tolerates it; only real workloads wait for a node to become ready.

The control-plane Deployments (controller/registrar/edge) tolerate for two reasons:

  1. They don't depend on the agent. They run in aether-system, and the CNI plugin skips ignored namespaces before ever calling the agent (cni/internal/plugin/plugin.go: "skipping CNI add for system pod"). They never touch the aether CNI, so they have no node-readiness dependency. The edge is an ingress gateway that dials pods directly and never uses the node proxy.
  2. The controller MUST tolerate, or a fresh cluster deadlocks. It projects the <release>-mesh-config ConfigMap that the agent mounts and blocks on at startup (non-optional volume — "stays in ContainerCreating until it exists"), and the agent only removes the taint once its CNI is serving. So if the controller waited for a ready node, it could never schedule to create that ConfigMap → the agent stays blocked → the taint is never removed → nothing bootstraps.

On a fresh cluster: nodes register tainted → agent + proxy + control plane all tolerate and schedule → controller creates the MeshConfig ConfigMap → agent unblocks, serves CNI, and removes the taint → user workloads schedule.

Validation

  • bazel build //agent/... //common/constants/... green; //agent/internal/node:node_test and //agent/internal/cmd:cmd_test pass.
  • helm template renders: agent RBAC nodes verbs include patch; all five aether components (agent, proxy, controller, registrar, edge) carry the toleration; controller RBAC unchanged (stays read-only).
  • talos e2e pending (needs a node registered with the taint to exercise the cold-start → untaint flow).

Refs #261

🤖 Generated with Claude Code

The CNI plugin fails-closed: until the node agent's gRPC CNI server is
serving, a pod's CNI ADD errors and kubelet retries. On a cold node (or an
agent roll on a fresh node) that leaves pods churning ContainerCreating.

Add a node startup taint, mirroring Cilium's agent-not-ready gate:

- common/constants: TaintAgentNotReady = aether.io/agent-not-ready.
- agent/internal/node: TaintRemover manager Runnable removes the taint from
  the agent's OWN node once the CNI server is serving (its UDS exists),
  best-effort with retry — never fails agent startup. removeTaint is a pure,
  unit-tested helper. Gated by --remove-startup-taint (default true).
- chart: tolerate the taint on the agent + proxy DaemonSets ONLY (workload
  pods, registrar, controller, edge do NOT — they wait for a ready node);
  add nodes/patch RBAC for the agent; document that the operator must register
  nodes with the taint (kubelet --register-with-taints); bump chart to 0.19.0.

The data-plane delete guarantee + storage/pod reconcile are separate changes.

Refs #261
bpalermo added a commit that referenced this pull request Jun 22, 2026
…sue #261) (#264)

The ghost sweep reconciled the registry against local storage but never
reconciled local storage against the node's real pods, so two desync classes
went uncured (talos worker-01, 2026-06-22):

  - Orphan ghost: a missed CNI DEL that left the netns bind-mount pin behind.
    netnsExists() stats the lingering pin and reports present, so the existing
    stale-prune never removed it; the agent kept emitting a listener bound to a
    dead netns (prober-vhbp8) — a connection sink and a latent #245 segfault.
  - Missing pod: a live, mesh-managed pod with no storage entry (a lost CNI ADD)
    that therefore had no listener and 100% connection_error (prober-k7vsm), and
    never self-healed.

The agent's manager cache is already scoped to spec.nodeName=<this node>, so
listing the node's pods is local and cheap (no new RBAC — it already has
pods get/list/watch). The sweep now:

  - Prunes a stored pod when EITHER its netns is gone (existing) OR its
    Kubernetes pod no longer exists — by pod identity, regardless of a lingering
    pin. The pruned pod's registry endpoint then falls through to ghost
    deregistration as before. If the pod list fails we skip prune-by-absence
    (an empty list would nuke every entry) but still run the netns prune.
  - Surfaces live, Running, mesh-managed pods that storage has no entry for: the
    agent can't synthesize the CNI data to self-heal, so it emits a metric +
    warning (the pod must be rolled) instead of silently serving no listener.

New metrics: ghost_sweep.orphans_pruned, ghost_sweep.missing_storage. Tests:
TestSweepPrunesOrphanedPods (lingering-pin orphan pruned + ghost-deregistered,
live pod kept) and TestIsMeshManagedK8sPod; existing sweep tests keep a nil
k8sClient and skip the pod reconcile via a defensive guard.

This is the cure layer; the guaranteed-delete reorder (#262) is the prevention
and the startup taint (#263) closes the cold-start window.


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

Co-authored-by: Claude Opus 4.8 <[email protected]>
The first cut tolerated the taint only on the agent + proxy DaemonSets and made
the control-plane Deployments wait for a ready node. That deadlocks a fresh
cluster: the controller projects the MeshConfig ConfigMap the agent mounts and
blocks on at startup (non-optional volume, "ContainerCreating until it exists"),
and the agent only removes the taint once its CNI is serving. So a non-tolerating
controller can never schedule to create that ConfigMap -> the agent stays blocked
-> the taint is never removed -> nothing bootstraps.

They also don't need to wait at all: controller/registrar/edge run in
aether-system, and the CNI plugin skips ignored namespaces before ever calling
the agent (plugin.go: "skipping CNI add for system pod"), so they never touch the
aether CNI and have no node-readiness dependency. The edge is an ingress gateway
that dials pods directly and never uses the node proxy.

The taint exists to gate mesh-managed user workloads, which aether's own control
plane is not — so every aether component tolerates it; only real workloads wait.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
@bpalermo

Copy link
Copy Markdown
Owner Author

Updated: tolerate the taint on controller/registrar/edge (fixes a bootstrap deadlock)

The original "only agent + proxy tolerate" decision deadlocks a fresh cluster:

  1. Agent + proxy tolerate → scheduled, but the agent sits in ContainerCreating waiting for the <release>-mesh-config ConfigMap (non-optional mount, "stays in ContainerCreating until it exists").
  2. The controller projects that ConfigMap — but it didn't tolerate the taint, so it couldn't schedule until a node was ready.
  3. A node only becomes ready once the agent serves CNI and removes the taint — which it can't, blocked on the controller's ConfigMap. Deadlock.

And they don't need to wait anyway: controller/registrar/edge are in aether-system, which the CNI plugin skips before ever calling the agent (plugin.go: "skipping CNI add for system pod") — they never touch the aether CNI, so they have zero node-readiness dependency. The edge dials pods directly and never uses the node proxy.

Principle: the taint gates mesh-managed user workloads, which aether's own control plane is not. So every aether component (agent, proxy, controller, registrar, edge) tolerates it; only real workloads wait. helm template confirms all 5 carry the toleration; controller RBAC stays read-only.

Thanks @bpalermo for catching this.

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