Add client side event rate limiting

Kubernetes-commit: b62fa1d72855ef1eb02ec2c908b16b7477feb3b1
This commit is contained in:
Derek Carr
2017-06-15 15:58:06 -04:00
committed by Kubernetes Publisher
parent a18b27ec1f
commit 170149c11b
4 changed files with 131 additions and 15 deletions

View File

@@ -412,7 +412,8 @@ func TestWriteEventError(t *testing.T) {
},
}
eventCorrelator := NewEventCorrelator(clock.RealClock{})
clock := clock.IntervalClock{Time: time.Now(), Duration: time.Second}
eventCorrelator := NewEventCorrelator(&clock)
randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
for caseName, ent := range table {
@@ -435,7 +436,8 @@ func TestWriteEventError(t *testing.T) {
}
func TestUpdateExpiredEvent(t *testing.T) {
eventCorrelator := NewEventCorrelator(clock.RealClock{})
clock := clock.IntervalClock{Time: time.Now(), Duration: time.Second}
eventCorrelator := NewEventCorrelator(&clock)
randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
var createdEvent *v1.Event
@@ -497,14 +499,15 @@ func TestLotsOfEvents(t *testing.T) {
loggerCalled <- struct{}{}
})
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "eventTest"})
ref := &v1.ObjectReference{
Kind: "Pod",
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "version",
}
for i := 0; i < maxQueuedEvents; i++ {
// we want a unique object to stop spam filtering
ref := &v1.ObjectReference{
Kind: "Pod",
Name: fmt.Sprintf("foo-%v", i),
Namespace: "baz",
UID: "bar",
APIVersion: "version",
}
// we need to vary the reason to prevent aggregation
go recorder.Eventf(ref, v1.EventTypeNormal, "Reason-"+string(i), strconv.Itoa(i))
}