NOSSLETTER.techLIVE
back to archive

Reconcile cloud endpoint rules in the agent

Language: Go+1087 -24feature
concepts demonstrated
State management with persistent databasesReconciliation loops for system state consistencyContext-aware error handling with cancellation and timeoutsIntegration with cloud provider IP address management (IPAM)
The Issue & Context

Before this PR, the Cilium agent lacked a durable record of expected routing rules per endpoint, causing stale or orphaned cloud routing rules after endpoint restoration or missed cleanup.

Root Cause Analysis

The agent relied solely on transient CNI ADD/DEL events without persistent state, so it couldn't detect or fix routing rules left behind by restored endpoints or incomplete deletions, leading to inconsistent routing state.

Solution Strategy & Architectural Pattern

Introduced a StateDB table to store desired endpoint routing rules, with lifecycle events updating this table. A reconciler uses this state to install missing rules, replace legacy rules, remove rules after endpoint deletion, and garbage-collect orphaned rules. Startup waits for endpoint restoration before pruning state, and endpoint creation blocks until routing state is confirmed, ensuring consistency.

Key Takeaway for Contributors

Maintaining a durable, authoritative state representation in the agent enables reliable reconciliation and cleanup of external system state, preventing drift that transient event-driven updates alone cannot handle.