Make the service reconciller use the API, not a PodRegistry

This commit is contained in:
Brendan Burns
2014-07-18 13:22:26 -07:00
parent fda69bcca2
commit c6255afe37
5 changed files with 105 additions and 48 deletions

View File

@@ -76,11 +76,13 @@ func main() {
Port: *minionPort,
}
client := client.New("http://localhost:8080", nil)
var m *master.Master
if len(etcdServerList) > 0 {
m = master.New(etcdServerList, machineList, podInfoGetter, cloud, *minionRegexp)
m = master.New(etcdServerList, machineList, podInfoGetter, cloud, *minionRegexp, client)
} else {
m = master.NewMemoryServer(machineList, podInfoGetter, cloud)
m = master.NewMemoryServer(machineList, podInfoGetter, cloud, client)
}
glog.Fatal(m.Run(net.JoinHostPort(*address, strconv.Itoa(int(*port))), *apiPrefix))

View File

@@ -66,19 +66,33 @@ func (fakePodInfoGetter) GetPodInfo(host, podID string) (api.PodInfo, error) {
return c.GetPodInfo("localhost", podID)
}
type delegateHandler struct {
delegate http.Handler
}
func (h *delegateHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if h.delegate != nil {
h.delegate.ServeHTTP(w, req)
}
w.WriteHeader(http.StatusNotFound)
}
func startComponents(manifestURL string) (apiServerURL string) {
// Setup
servers := []string{"http://localhost:4001"}
glog.Infof("Creating etcd client pointing to %v", servers)
machineList := []string{"localhost", "machine"}
// Master
m := master.New(servers, machineList, fakePodInfoGetter{}, nil, "")
apiserver := httptest.NewServer(m.ConstructHandler("/api/v1beta1"))
handler := delegateHandler{}
apiserver := httptest.NewServer(&handler)
cl := client.New(apiserver.URL, nil)
cl.PollPeriod = time.Second * 1
cl.Sync = true
// Master
m := master.New(servers, machineList, fakePodInfoGetter{}, nil, "", cl)
handler.delegate = m.ConstructHandler("/api/v1beta1")
controllerManager := controller.MakeReplicationManager(etcd.NewClient(servers), cl)
controllerManager.Run(1 * time.Second)