Reconcile cloud endpoint rules in the agent
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.