Include entity data in delete watch events#600
Conversation
📝 WalkthroughWalkthroughAdds revision-aware reads and preserves pre-deletion state for watches. MockStore gains a No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Comment |
d082e23 to
99ab0a6
Compare
When a watched entity is deleted, watchers now receive the full entity data from before deletion instead of just the operation type. This eliminates the need for watchers to cache entities on their side. - WatchEntity: uses WithPrevKV() to unmarshal the previous entity value - WatchIndex: fetches the entity via GetEntity (still exists since index entries are deleted first), falling back to GetEntityAtRevision - Adds GetEntityAtRevision to Store interface for revision-based reads
99ab0a6 to
bbca3c1
Compare
Update GenericController.Delete to receive the decoded entity from delete watch events, completing the plumbing started in PR #600 which made entity data available in delete events but stopped short of threading it through the controller interface. This allows the sandbox controller to clean up iptables DNAT rules even when the entity has already been deleted from the store, since the entity data arrives directly from the watch event rather than requiring a store lookup.
Summary
WatchEntityuses etcd'sWithPrevKV()to get the previous entity value directly from the watch event — no extra round-tripWatchIndexfetches the entity viaGetEntity(entity still exists since index entries are deleted first), with a fallback to the newGetEntityAtRevisionmethod for robustnessGetEntityAtRevisionto theStoreinterface for revision-based reads from etcdTest plan
TestWatchEntity_DeleteIncludesEntityagainst real etcdTestEntityServer_WatchEntity_DeleteIncludesEntityagainst mockTestEntityServer_WatchIndex_DeleteIncludesEntityagainst mockTestEntityServer_WatchEntity_DeleteIncludesEntity_Etcdagainst real etcdTestEntityServer_WatchIndex_DeleteIncludesEntity_Etcdagainst real etcdpkg/entitytest suite (229 tests passing)servers/entityservertest suite (23 tests passing)