From 0a1dfa366e70f59947ed4dc9ab626c37deb9e01d Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Thu, 21 Aug 2014 13:35:50 -0700 Subject: [PATCH] Make integration test pass. --- cmd/integration/integration.go | 8 +++++++- pkg/registry/etcd/etcd.go | 1 - pkg/registry/pod/storage.go | 11 ++++++++--- pkg/tools/etcd_tools.go | 1 + plugin/pkg/scheduler/factory/factory.go | 12 +++++++++++- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index b7bfc03a5b..9227a9dd75 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -38,6 +38,9 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/master" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait" + "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler" + "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/factory" + "github.com/coreos/go-etcd/etcd" "github.com/golang/glog" ) @@ -64,7 +67,7 @@ func (fakePodInfoGetter) GetPodInfo(host, podID string) (api.PodInfo, error) { Port: 10251, } default: - glog.Fatalf("Can't get info for: %v, %v", host, podID) + glog.Fatalf("Can't get info for: '%v', '%v'", host, podID) } return c.GetPodInfo("localhost", podID) } @@ -106,6 +109,9 @@ func startComponents(manifestURL string) (apiServerURL string) { storage, codec := m.API_v1beta1() handler.delegate = apiserver.Handle(storage, codec, "/api/v1beta1") + // Scheduler + scheduler.New((&factory.ConfigFactory{cl}).Create()).Run() + controllerManager := controller.NewReplicationManager(cl) // Prove that controllerManager's watch works by making it not sync until after this diff --git a/pkg/registry/etcd/etcd.go b/pkg/registry/etcd/etcd.go index 477c850b20..9747457e96 100644 --- a/pkg/registry/etcd/etcd.go +++ b/pkg/registry/etcd/etcd.go @@ -135,7 +135,6 @@ func (r *Registry) setPodHostTo(podID, oldMachine, machine string) (finalPod *ap } // assignPod assigns the given pod to the given machine. -// TODO: hook this up via apiserver, not by calling it from CreatePod(). func (r *Registry) assignPod(podID string, machine string) error { finalPod, err := r.setPodHostTo(podID, "", machine) if err != nil { diff --git a/pkg/registry/pod/storage.go b/pkg/registry/pod/storage.go index 47ac6fd036..0433599d1d 100644 --- a/pkg/registry/pod/storage.go +++ b/pkg/registry/pod/storage.go @@ -133,10 +133,11 @@ func (rs *RegistryStorage) Watch(label, field labels.Selector, resourceVersion u pod := e.Object.(*api.Pod) fields := labels.Set{ "ID": pod.ID, - "DesiredState.Status": string(pod.CurrentState.Status), - "DesiredState.Host": pod.CurrentState.Host, + "DesiredState.Status": string(pod.DesiredState.Status), + "DesiredState.Host": pod.DesiredState.Host, } - return e, label.Matches(labels.Set(pod.Labels)) && field.Matches(fields) + passesFilter := label.Matches(labels.Set(pod.Labels)) && field.Matches(fields) + return e, passesFilter }), nil } @@ -158,6 +159,10 @@ func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { } func (rs *RegistryStorage) fillPodInfo(pod *api.Pod) { + pod.CurrentState.Host = pod.DesiredState.Host + if pod.CurrentState.Host == "" { + return + } // Get cached info for the list currently. // TODO: Optionally use fresh info if rs.podCache != nil { diff --git a/pkg/tools/etcd_tools.go b/pkg/tools/etcd_tools.go index 358d69ebef..f44f4de1f5 100644 --- a/pkg/tools/etcd_tools.go +++ b/pkg/tools/etcd_tools.go @@ -477,6 +477,7 @@ func (w *etcdWatcher) sendResult(res *etcd.Response) { var action watch.EventType var data []byte var index uint64 + glog.Infof("watching: got %v", res.Action) switch res.Action { case "create": if res.Node == nil { diff --git a/plugin/pkg/scheduler/factory/factory.go b/plugin/pkg/scheduler/factory/factory.go index d140b1904f..24bc0db2b2 100644 --- a/plugin/pkg/scheduler/factory/factory.go +++ b/plugin/pkg/scheduler/factory/factory.go @@ -69,7 +69,14 @@ func (factory *ConfigFactory) Create() *scheduler.Config { Algorithm: algo, Binder: &binder{factory.Client}, NextPod: func() *api.Pod { - return podQueue.Pop().(*api.Pod) + pod := podQueue.Pop().(*api.Pod) + // TODO: Remove or reduce verbosity by sep 6th, 2014. Leave until then to + // make it easy to find scheduling problems. + glog.Infof("About to try and schedule pod %v\n"+ + "\tknown minions: %v\n"+ + "\tknown scheduled pods: %v\n", + pod.ID, minionCache.Contains(), podCache.Contains()) + return pod }, Error: factory.makeDefaultErrorFunc(podQueue), } @@ -193,5 +200,8 @@ type binder struct { // Bind just does a POST binding RPC. func (b *binder) Bind(binding *api.Binding) error { + // TODO: Remove or reduce verbosity by sep 6th, 2014. Leave until then to + // make it easy to find scheduling problems. + glog.Infof("Attempting to bind %v to %v", binding.PodID, binding.Host) return b.Post().Path("bindings").Body(binding).Do().Error() }