Make each new instance of kubelet generate a new event channel (instead of reusing existing).

This commit is contained in:
saadali
2015-03-16 21:03:07 -07:00
parent 10b4fe6f30
commit e0f71cb21f
13 changed files with 172 additions and 151 deletions

View File

@@ -26,6 +26,7 @@ import (
"os"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports"
@@ -77,8 +78,6 @@ func (s *SchedulerServer) Run(_ []string) error {
glog.Fatalf("Invalid API configuration: %v", err)
}
record.StartRecording(kubeClient.Events(""))
go func() {
if s.EnableProfiling {
mux := http.NewServeMux()
@@ -95,6 +94,10 @@ func (s *SchedulerServer) Run(_ []string) error {
glog.Fatalf("Failed to create scheduler configuration: %v", err)
}
eventBroadcaster := record.NewBroadcaster()
config.Recorder = eventBroadcaster.NewRecorder(api.EventSource{Component: "scheduler"})
eventBroadcaster.StartRecordingToSink(kubeClient.Events(""))
sched := scheduler.New(config)
sched.Run()

View File

@@ -26,7 +26,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
algorithm "github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@@ -194,8 +193,7 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys util.StringSe
glog.V(2).Infof("About to try and schedule pod %v", pod.Name)
return pod
},
Error: f.makeDefaultErrorFunc(&podBackoff, f.PodQueue),
Recorder: record.FromSource(api.EventSource{Component: "scheduler"}),
Error: f.makeDefaultErrorFunc(&podBackoff, f.PodQueue),
}, nil
}

View File

@@ -56,7 +56,8 @@ func (es mockScheduler) Schedule(pod api.Pod, ml scheduler.MinionLister) (string
}
func TestScheduler(t *testing.T) {
defer record.StartLogging(t.Logf).Stop()
eventBroadcaster := record.NewBroadcaster()
defer eventBroadcaster.StartLogging(t.Logf).Stop()
errS := errors.New("scheduler")
errB := errors.New("binder")
@@ -119,11 +120,11 @@ func TestScheduler(t *testing.T) {
NextPod: func() *api.Pod {
return item.sendPod
},
Recorder: record.FromSource(api.EventSource{Component: "scheduler"}),
Recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "scheduler"}),
}
s := New(c)
called := make(chan struct{})
events := record.GetEvents(func(e *api.Event) {
events := eventBroadcaster.StartEventWatcher(func(e *api.Event) {
if e, a := item.eventReason, e.Reason; e != a {
t.Errorf("%v: expected %v, got %v", i, e, a)
}