DELETE watch events missing revision number from etcd ModRevision
Problem
DELETE watch events from etcd currently have rev: 0 in controller Events because we don't capture the ModRevision field for delete events.
In pkg/entity/store.go around line 469-493, DELETE events don't set read = true, so the code that sets entity.SetRevision(event.Kv.ModRevision) is skipped. However, etcd DOES provide event.Kv.ModRevision even for delete events - it's the revision at which the delete occurred.
Impact
- Controllers receiving DELETE events see
Rev: 0instead of the actual etcd revision - This violates the etcd semantic that all watch events have revisions
- Can cause issues with revision tracking and event ordering
Root Cause
case event.Type == clientv3.EventTypeDelete:
eventType = EntityOpDelete
// read = false by default
// ...
if read { // This is false for DELETE
// Sets entity.SetRevision(event.Kv.ModRevision)
// Never reached for DELETE events
}
Fix
For DELETE events, we should still capture event.Kv.ModRevision and include it in the EntityOp, even though there's no entity body.
Discovery Context
Found while investigating CI test failure in PR #396. The test showed a rev: 0 event being processed as a delete, which led to discovering this pre-existing bug.