Skip to content

Clean up a moved instance's advertisement the standard CNI way - #1386

Draft
scotwells wants to merge 7 commits into
mainfrom
fix/attachment-status-node-flip
Draft

scotwells wants to merge 7 commits into
mainfrom
fix/attachment-status-node-flip

Conversation

@scotwells

@scotwells scotwells commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Scot Schuchert-Wells · project thread

Fixes #1385. Related: datum-cloud/enhancements#921, datum-cloud/compute#630.

Problem

A recreated instance keeps its attachment identity. When it moves node, the old node's advertisement stayed until that node's GC collected it, because CNI DEL never deleted advertisements. Meanwhile the cloud controller wrote each advertisement's node into the attachment status in turn, so the status flipped between nodes several times a second, every node router added and removed the instance's routes on each flip, and its DNS lookups were denied for minutes.

Change

  • CNI DEL follows standard CNI cleanup. galactic-bgp removes its container's entries from this node's advertisement and deletes the advertisement once no container it records is still alive. A replacement on the same node whose ADD ran first keeps it. Writes carry the resourceVersion, so a concurrent ADD is never overwritten.
  • CNI ADD deletes leftovers as a fallback. It deletes the attachment's advertisements on other nodes, best effort, for a predecessor whose DEL never ran.
  • The old node's tap still gets cleaned up. galactic-cni's stale tap reclaim now also removes a detached tap (no VMM holds it, seen on two passes) whose attachment is advertised only on another node, even though its VPCAttachment still exists. Before, it needed no VPCAttachment at all.
  • Docs updated for DEL, ADD and the tap reclaim.

Testing

  • New unit tests cover: DEL deletes the last container's advertisement, DEL keeps a replacement's advertisement and prefixes, DEL with nothing to release, ADD deleting only other nodes' advertisements for the same attachment, and tap reclaim for a moved attachment while keeping one that is still advertised on this node.
  • The cnibgp, gc and installer suites were run in a Linux container. The only failures were tests that need VRF support, which that kernel lacks, and they fail the same way on main.

A recreated instance keeps its attachment identity, so after it moves node
both nodes hold an advertisement for it until the old node's teardown
withdraws its own. Each advertisement's reconcile wrote its own node into
the attachment status, and every status write re-enqueued both, so the node
flipped several times a second and every node router added and removed the
attachment's routes on each flip.

CNI ADD now stamps the advertisement with when it last published it, and
the controller only projects status from the advertisement published most
recently, falling back to creation time for older advertisements.

Fixes #1385
@scotwells scotwells self-assigned this Nov 12, 2026
Review fixes: when the newest advertisement is withdrawn while an older one
remains, project from the survivor right away instead of leaving the
attachment on a node with no advertisement. A stamped advertisement beats
an unstamped one, so nodes not yet on the stamping CNI never win on their
first creation time. Check currency only once an attachment is found.
…g by time

Replaces the last-ADD timestamp ordering. A CNI ADD now marks every other
node's advertisement for its attachment replaced by this node, and clears the
mark on its own. The cloud controller never projects status from a replaced
advertisement, and hands the attachment to the current one when a replaced
advertisement wrote last or the current one is withdrawn.

The old advertisement is marked rather than deleted: CNI DEL leaves it to the
old node's GC, which reclaims the old host link through it.
@scotwells scotwells changed the title Keep a moved instance's attachment status on its newest advertisement Keep a moved instance's attachment status on its new node Nov 12, 2026
Review fixes: a mark naming a node with no advertisement for the attachment
any more no longer holds the old advertisement back, so a rolled-back or late
ADD cannot leave the attachment without status. A failed mark logs instead of
failing the ADD. The replaced advertisement's handover no longer needs its
router, and withdrawal only re-projects when the attachment was on the
withdrawn node. Documents the mark.
Review fix: letting a mark lapse once the replacing advertisement was gone
reported delivery on the node the instance left, possibly a dead one, after
the instance stopped. Marks now stay until their advertisement is collected,
and a failed ADD that deletes its freshly created advertisement removes the
marks it wrote, where they still name its node.
Replaces the replaced-by mark. CNI DEL now releases what its ADD published:
it removes its container's entries from this node's BGPAdvertisement and
deletes the advertisement once no container it records is alive, so a
replacement whose ADD ran first keeps it. As a fallback for a predecessor
whose DEL never ran, CNI ADD deletes the attachment's advertisements on other
nodes, and galactic-cni's stale tap reclaim now removes a detached tap whose
attachment is advertised only on another node, so the old node's tap does
not outlive the deleted advertisement.
@scotwells scotwells changed the title Keep a moved instance's attachment status on its new node Clean up a moved instance's advertisement the standard CNI way Nov 12, 2026
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.

Attachment status flips between nodes after an instance moves, dropping its routes

1 participant