m/p/event/etcd: handle spurious watch updates
With the recent etcd updates, we started seeing some failures in tests
for the etcd-backed Event Value library.
This seems to be due to etcd now sometimes returning 'spurious' watch
updates, in which a keyvalue is returned twice, with two separate
revision numbers, even though the underlying value has not been
updated.
We elect to deduplicate these within the event value library itself, if
only to make it less work for downstream users to do the same. This is
done be keeping a cross-watcher.Get map of key->values, and filtering
out updates which effectively do not update the data underneath.
We had one test relying on 1:1 correspondance between etcd puts and
Event Value backlogged Gets. However, the rest of our codebase does not
make this assumption, and it seems fair that this assumption doesn't
make sense alongside the intended use of the Event Value system in which
we deliberately and arbitrarily drop intermediate updates within a
single Get call.
Change-Id: I731a15b2d15ab6807bb95cb6c777c176dde22f0b
Reviewed-on: https://review.monogon.dev/c/monogon/+/654
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/pkg/event/etcd/etcd_test.go b/metropolis/pkg/event/etcd/etcd_test.go
index faa9629..d91a6b9 100644
--- a/metropolis/pkg/event/etcd/etcd_test.go
+++ b/metropolis/pkg/event/etcd/etcd_test.go
@@ -654,17 +654,16 @@
wantError("foo")
wantValue("18", 18)
wantError("10")
- wantError("10")
wantValue("27", 27)
wantValue("36", 36)
for i, want := range wantList {
q := <-queue
if want == nil && q.err == nil {
- t.Errorf("Case %d: wanted error, got no error and value %d", i, q.val)
+ t.Fatalf("Case %d: wanted error, got no error and value %d", i, q.val)
}
if want != nil && (*want) != q.val {
- t.Errorf("Case %d: wanted value %d, got error %v and value %d", i, *want, q.err, q.val)
+ t.Fatalf("Case %d: wanted value %d, got error %v and value %d", i, *want, q.err, q.val)
}
}
}