diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 8e4908b7e83..dcd3610157b 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -73,7 +73,7 @@ func (fakeKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.Pod Client: http.DefaultClient, Port: 10250, } - case "machine": + case "127.0.0.1": c = &client.HTTPKubeletClient{ Client: http.DefaultClient, Port: 10251, @@ -81,7 +81,18 @@ func (fakeKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.Pod default: glog.Fatalf("Can't get info for: '%v', '%v - %v'", host, podNamespace, podID) } - return c.GetPodStatus("localhost", podNamespace, podID) + r, err := c.GetPodStatus("localhost", podNamespace, podID) + if err != nil { + return r, err + } + r.Status.PodIP = "1.2.3.4" + m := make(api.PodInfo) + for k, v := range r.Status.Info { + v.PodIP = "1.2.3.4" + m[k] = v + } + r.Status.Info = m + return r, nil } func (fakeKubeletClient) HealthCheck(host string) (probe.Status, error) { @@ -104,7 +115,7 @@ 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"} + machineList := []string{"localhost", "127.0.0.1"} handler := delegateHandler{} apiServer := httptest.NewServer(&handler) @@ -163,6 +174,7 @@ func startComponents(manifestURL string) (apiServerURL string) { ReadWritePort: portNumber, ReadOnlyPort: portNumber, PublicAddress: net.ParseIP(host), + CacheTimeout: 2 * time.Second, }) handler.delegate = m.Handler @@ -185,7 +197,7 @@ func startComponents(manifestURL string) (apiServerURL string) { nodeResources := &api.NodeResources{} nodeController := nodeControllerPkg.NewNodeController(nil, "", machineList, nodeResources, cl, fakeKubeletClient{}) - nodeController.Run(10*time.Second, 10) + nodeController.Run(5*time.Second, 10) // Kubelet (localhost) testRootDir := makeTempDirOrDie("kubelet_integ_1.") diff --git a/pkg/master/master.go b/pkg/master/master.go index 872c29ac45c..62b67830b57 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -100,6 +100,10 @@ type Config struct { // If nil, the first result from net.InterfaceAddrs will be used. PublicAddress net.IP + + // Control the interval that pod, node IP, and node heath status caches + // expire. + CacheTimeout time.Duration } // Master contains state for a Kubernetes cluster master/api server. @@ -117,6 +121,7 @@ type Master struct { storage map[string]apiserver.RESTStorage client *client.Client portalNet *net.IPNet + cacheTimeout time.Duration mux apiserver.Mux muxHelper *apiserver.MuxHelper @@ -179,6 +184,9 @@ func setDefaults(c *Config) { if c.ReadOnlyPort == 0 { c.ReadOnlyPort = 7080 } + if c.CacheTimeout == 0 { + c.CacheTimeout = 5 * time.Second + } if c.ReadWritePort == 0 { c.ReadWritePort = 443 } @@ -283,7 +291,9 @@ func New(c *Config) *Master { authorizer: c.Authorizer, admissionControl: c.AdmissionControl, v1beta3: c.EnableV1Beta3, - nodeIPCache: NewIPCache(c.Cloud, util.RealClock{}, 30*time.Second), + nodeIPCache: NewIPCache(c.Cloud, util.RealClock{}, c.CacheTimeout), + + cacheTimeout: c.CacheTimeout, masterCount: c.MasterCount, publicIP: c.PublicAddress, @@ -365,7 +375,7 @@ func (m *Master) init(c *Config) { RESTStorageToNodes(nodeRESTStorage).Nodes(), m.podRegistry, ) - go util.Forever(func() { podCache.UpdateAllContainers() }, time.Second*5) + go util.Forever(func() { podCache.UpdateAllContainers() }, m.cacheTimeout) go util.Forever(func() { podCache.GarbageCollectPodStatus() }, time.Minute*30) // TODO: Factor out the core API registration