Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events should be non-blocking. #15954

Merged
merged 1 commit into from
Oct 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/client/record/event.go
Expand Up @@ -261,7 +261,10 @@ func (recorder *recorderImpl) generateEvent(object runtime.Object, timestamp unv
event := recorder.makeEvent(ref, reason, message)
event.Source = recorder.source

recorder.Action(watch.Added, event)
go func() {
// NOTE: events should be a non-blocking operation
recorder.Action(watch.Added, event)
}()
}

func (recorder *recorderImpl) Event(object runtime.Object, reason, message string) {
Expand Down
10 changes: 6 additions & 4 deletions pkg/client/record/event_test.go
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"runtime"
"strconv"
"strings"
"testing"
Expand All @@ -28,7 +29,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/runtime"
k8sruntime "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/strategicpatch"
)
Expand Down Expand Up @@ -127,7 +128,7 @@ func TestEventf(t *testing.T) {
t.Fatal(err)
}
table := []struct {
obj runtime.Object
obj k8sruntime.Object
reason string
messageFmt string
elements []interface{}
Expand Down Expand Up @@ -471,6 +472,7 @@ func TestWriteEventError(t *testing.T) {
for caseName := range table {
clock.Step(1 * time.Second)
recorder.Event(ref, "Reason", caseName)
runtime.Gosched()
}
recorder.Event(ref, "Reason", "finished")
<-done
Expand Down Expand Up @@ -548,7 +550,7 @@ func TestEventfNoNamespace(t *testing.T) {
t.Fatal(err)
}
table := []struct {
obj runtime.Object
obj k8sruntime.Object
reason string
messageFmt string
elements []interface{}
Expand Down Expand Up @@ -654,7 +656,7 @@ func TestMultiSinkCache(t *testing.T) {
t.Fatal(err)
}
table := []struct {
obj runtime.Object
obj k8sruntime.Object
reason string
messageFmt string
elements []interface{}
Expand Down