Skip to content

fix: Make IPAM default route idempotent on ADD retries - #270

Merged
privateip merged 1 commit into
mainfrom
fix/idempotent-ipam-default-route
Jul 31, 2026
Merged

fix: Make IPAM default route idempotent on ADD retries#270
privateip merged 1 commit into
mainfrom
fix/idempotent-ipam-default-route

Conversation

@privateip

@privateip privateip commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

galactic-cni's IPAM step adds a default route toward the attachment's gateway on every CNI ADD. If a caller retries ADD against the same netns without an intervening DEL — which happens in practice when an earlier ADD attempt is aborted before its own rollback runs — the route already exists and ADD fails with configure IPAM: add default route via <gateway>: file exists, leaving the pod stuck in ContainerCreating on every subsequent retry.

The IPAM route/address install now checks existing kernel state first: if the address or default route already match what's being installed, the call is a no-op success. If a default route exists via a different gateway, that's a real misconfiguration and now fails loudly instead of being silently papered over or overwritten.

Also hardened the DEL path: the error from delegating DEL to the host-device plugin (the mechanism that actually flushes the route/address, by moving the guest interface back out of the netns) was previously discarded entirely. It's now logged, so a failed cleanup — the underlying cause of the stale route in the first place — is visible instead of invisible.

A CNI ADD retried against a netns that a previous, non-DEL'd ADD had
already configured failed with "add default route ... file exists"
instead of succeeding, leaving pods stuck in ContainerCreating.

addAddrAndDefaultRoute now checks existing kernel state before adding:
identical state is a no-op, while a default route via a different
gateway is a loud conflict error instead of being silently overwritten
or masked. DEL's host-device delegation error (the mechanism that
flushes the route/address by moving the interface out of the netns) is
now logged instead of silently discarded, so a failed cleanup is
diagnosable.
@privateip
privateip requested a review from a team as a code owner July 31, 2026 02:55

@drewr drewr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's try it

@privateip
privateip merged commit a9b0ade into main Jul 31, 2026
9 checks passed
@privateip
privateip deleted the fix/idempotent-ipam-default-route branch July 31, 2026 03:21
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.

2 participants