diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 30478ed4a86..6b0f877f4e0 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -262,7 +262,7 @@ func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc { podInfo := fakeKubeletClient{} return func() (bool, error) { for i := range pods.Items { - host, id, namespace := pods.Items[i].Status.Host, pods.Items[i].Name, pods.Items[i].Namespace + host, id, namespace := pods.Items[i].Spec.Host, pods.Items[i].Name, pods.Items[i].Namespace glog.Infof("Check whether pod %s.%s exists on node %q", id, namespace, host) if len(host) == 0 { glog.Infof("Pod %s.%s is not bound to a host yet", id, namespace) diff --git a/pkg/api/types.go b/pkg/api/types.go index 9d0254e3d31..6b324973fa8 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -723,9 +723,6 @@ type PodStatus struct { // A human readable message indicating details about why the pod is in this state. Message string `json:"message,omitempty"` - // Host is the name of the node that this Pod is currently bound to, or empty if no - // assignment has been done. - Host string `json:"host,omitempty"` HostIP string `json:"hostIP,omitempty"` PodIP string `json:"podIP,omitempty"` diff --git a/pkg/api/v1beta1/conversion.go b/pkg/api/v1beta1/conversion.go index a39a854d786..3ba786ca3a3 100644 --- a/pkg/api/v1beta1/conversion.go +++ b/pkg/api/v1beta1/conversion.go @@ -192,7 +192,6 @@ func init() { return err } out.Message = in.Message - out.Host = in.Host out.HostIP = in.HostIP out.PodIP = in.PodIP return nil @@ -209,7 +208,6 @@ func init() { } out.Message = in.Message - out.Host = in.Host out.HostIP = in.HostIP out.PodIP = in.PodIP return nil @@ -368,6 +366,7 @@ func init() { return err } out.DesiredState.Host = in.Spec.Host + out.CurrentState.Host = in.Spec.Host if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil { return err } diff --git a/pkg/api/v1beta2/conversion.go b/pkg/api/v1beta2/conversion.go index e6ffbc6952e..a259b7ffa7b 100644 --- a/pkg/api/v1beta2/conversion.go +++ b/pkg/api/v1beta2/conversion.go @@ -178,6 +178,7 @@ func init() { return err } out.DesiredState.Host = in.Spec.Host + out.CurrentState.Host = in.Spec.Host if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil { return err } @@ -496,7 +497,6 @@ func init() { return err } out.Message = in.Message - out.Host = in.Host out.HostIP = in.HostIP out.PodIP = in.PodIP return nil @@ -512,7 +512,6 @@ func init() { return err } out.Message = in.Message - out.Host = in.Host out.HostIP = in.HostIP out.PodIP = in.PodIP return nil diff --git a/pkg/api/v1beta3/types.go b/pkg/api/v1beta3/types.go index 19a4bf7c943..119f212132c 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -722,9 +722,6 @@ type PodStatus struct { // A human readable message indicating details about why the pod is in this state. Message string `json:"message,omitempty" description:"human readable message indicating details about why the pod is in this condition"` - // Host is the name of the node that this Pod is currently bound to, or empty if no - // assignment has been done. - Host string `json:"host,omitempty" description:"host to which the pod is assigned; empty if not yet scheduled; cannot be updated"` HostIP string `json:"hostIP,omitempty" description:"IP address of the host to which the pod is assigned; empty if not yet scheduled"` PodIP string `json:"podIP,omitempty" description:"IP address allocated to the pod; routable at least within the cluster; empty if not yet allocated"` diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 04b15017a95..6a7dcd23825 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -769,8 +769,8 @@ func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList { allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...) // TODO: allow change when bindings are properly decoupled from pods - if newPod.Status.Host != oldPod.Status.Host { - allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Status.Host, "pod host cannot be changed directly")) + if newPod.Spec.Host != oldPod.Spec.Host { + allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Spec.Host, "pod host cannot be changed directly")) } // For status update we ignore changes to pod spec. diff --git a/pkg/cloudprovider/controller/nodecontroller.go b/pkg/cloudprovider/controller/nodecontroller.go index 0461cf042c6..b1efd723b30 100644 --- a/pkg/cloudprovider/controller/nodecontroller.go +++ b/pkg/cloudprovider/controller/nodecontroller.go @@ -636,7 +636,7 @@ func (nc *NodeController) deletePods(nodeID string) error { return err } for _, pod := range pods.Items { - if pod.Status.Host != nodeID { + if pod.Spec.Host != nodeID { continue } glog.V(2).Infof("Delete pod %v", pod.Name) diff --git a/pkg/cloudprovider/controller/nodecontroller_test.go b/pkg/cloudprovider/controller/nodecontroller_test.go index ea2a32332b5..6ff3c58dc9e 100644 --- a/pkg/cloudprovider/controller/nodecontroller_test.go +++ b/pkg/cloudprovider/controller/nodecontroller_test.go @@ -1447,7 +1447,7 @@ func newNode(name string) *api.Node { } func newPod(name, host string) *api.Pod { - return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name}, Status: api.PodStatus{Host: host}} + return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name}, Spec: api.PodSpec{Host: host}} } func sortedNodeNames(nodes []*api.Node) []string { diff --git a/pkg/kubectl/cmd/exec.go b/pkg/kubectl/cmd/exec.go index edf6ffb5874..229bb01c656 100644 --- a/pkg/kubectl/cmd/exec.go +++ b/pkg/kubectl/cmd/exec.go @@ -135,7 +135,7 @@ func RunExec(f *Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.C req := client.RESTClient.Get(). Prefix("proxy"). Resource("minions"). - Name(pod.Status.Host). + Name(pod.Spec.Host). Suffix("exec", namespace, podName, containerName) e := remotecommand.New(req, config, args, stdin, cmdOut, cmdErr, tty) diff --git a/pkg/kubectl/cmd/log.go b/pkg/kubectl/cmd/log.go index 1c97de3caba..3324784c793 100644 --- a/pkg/kubectl/cmd/log.go +++ b/pkg/kubectl/cmd/log.go @@ -116,7 +116,7 @@ func RunLog(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error readCloser, err := client.RESTClient.Get(). Prefix("proxy"). Resource("minions"). - Name(pod.Status.Host). + Name(pod.Spec.Host). Suffix("containerLogs", namespace, podID, container). Param("follow", strconv.FormatBool(follow)). Stream() diff --git a/pkg/kubectl/cmd/portforward.go b/pkg/kubectl/cmd/portforward.go index d3bcc248754..51d7cc3925c 100644 --- a/pkg/kubectl/cmd/portforward.go +++ b/pkg/kubectl/cmd/portforward.go @@ -105,7 +105,7 @@ func RunPortForward(f *Factory, cmd *cobra.Command, args []string) error { req := client.RESTClient.Get(). Prefix("proxy"). Resource("minions"). - Name(pod.Status.Host). + Name(pod.Spec.Host). Suffix("portForward", namespace, podName) pf, err := portforward.New(req, config, args, stopCh) diff --git a/pkg/kubectl/describe.go b/pkg/kubectl/describe.go index c8189642cdf..81d16d73c5a 100644 --- a/pkg/kubectl/describe.go +++ b/pkg/kubectl/describe.go @@ -238,7 +238,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even return tabbedString(func(out io.Writer) error { fmt.Fprintf(out, "Name:\t%s\n", pod.Name) fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&pod.Spec)) - fmt.Fprintf(out, "Host:\t%s\n", pod.Status.Host+"/"+pod.Status.HostIP) + fmt.Fprintf(out, "Host:\t%s\n", pod.Spec.Host+"/"+pod.Status.HostIP) fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels)) fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase)) fmt.Fprintf(out, "Replication Controllers:\t%s\n", printReplicationControllersByLabels(rcs)) @@ -369,7 +369,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) { return "", err } for _, pod := range allPods.Items { - if pod.Status.Host != name { + if pod.Spec.Host != name { continue } pods = append(pods, pod) diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index 29effe3c8a8..5ae4687057d 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -329,7 +329,7 @@ func printPod(pod *api.Pod, w io.Writer) error { pod.Status.PodIP, firstContainer.Name, firstContainer.Image, - podHostString(pod.Status.Host, pod.Status.HostIP), + podHostString(pod.Spec.Host, pod.Status.HostIP), formatLabels(pod.Labels), pod.Status.Phase, units.HumanDuration(time.Now().Sub(pod.CreationTimestamp.Time))) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 1036c7b1114..74d2fa49847 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -1960,7 +1960,6 @@ func (kl *Kubelet) generatePodStatusByPod(pod *api.Pod) (api.PodStatus, error) { } else { pendingStatus := api.PodStatus{ Phase: api.PodPending, - Host: kl.GetHostname(), Message: fmt.Sprintf("Query docker container info failed with error (%v)", err), } return pendingStatus, nil @@ -1979,7 +1978,6 @@ func (kl *Kubelet) generatePodStatusByPod(pod *api.Pod) (api.PodStatus, error) { } } podStatus.Conditions = append(podStatus.Conditions, getPodReadyCondition(spec, podStatus.ContainerStatuses)...) - podStatus.Host = kl.GetHostname() hostIP, err := kl.GetHostIP() if err != nil { glog.Errorf("Cannot get host IP: %v", err) diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 5733eae7364..de64c99cf69 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -2169,22 +2169,20 @@ func failedState(cName string) api.ContainerStatus { func TestPodPhaseWithRestartAlways(t *testing.T) { desiredState := api.PodSpec{ + Host: "machine", Containers: []api.Container{ {Name: "containerA"}, {Name: "containerB"}, }, RestartPolicy: api.RestartPolicyAlways, } - currentState := api.PodStatus{ - Host: "machine", - } tests := []struct { pod *api.Pod status api.PodPhase test string }{ - {&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"}, + {&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"}, { &api.Pod{ Spec: desiredState, @@ -2193,7 +2191,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) { runningState("containerA"), runningState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2207,7 +2204,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) { stoppedState("containerA"), stoppedState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2221,7 +2217,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) { runningState("containerA"), stoppedState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2234,7 +2229,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) { ContainerStatuses: []api.ContainerStatus{ runningState("containerA"), }, - Host: "machine", }, }, api.PodPending, @@ -2250,22 +2244,20 @@ func TestPodPhaseWithRestartAlways(t *testing.T) { func TestPodPhaseWithRestartNever(t *testing.T) { desiredState := api.PodSpec{ + Host: "machine", Containers: []api.Container{ {Name: "containerA"}, {Name: "containerB"}, }, RestartPolicy: api.RestartPolicyNever, } - currentState := api.PodStatus{ - Host: "machine", - } tests := []struct { pod *api.Pod status api.PodPhase test string }{ - {&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"}, + {&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"}, { &api.Pod{ Spec: desiredState, @@ -2274,7 +2266,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) { runningState("containerA"), runningState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2288,7 +2279,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) { succeededState("containerA"), succeededState("containerB"), }, - Host: "machine", }, }, api.PodSucceeded, @@ -2302,7 +2292,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) { failedState("containerA"), failedState("containerB"), }, - Host: "machine", }, }, api.PodFailed, @@ -2316,7 +2305,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) { runningState("containerA"), succeededState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2329,7 +2317,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) { ContainerStatuses: []api.ContainerStatus{ runningState("containerA"), }, - Host: "machine", }, }, api.PodPending, @@ -2345,22 +2332,20 @@ func TestPodPhaseWithRestartNever(t *testing.T) { func TestPodPhaseWithRestartOnFailure(t *testing.T) { desiredState := api.PodSpec{ + Host: "machine", Containers: []api.Container{ {Name: "containerA"}, {Name: "containerB"}, }, RestartPolicy: api.RestartPolicyOnFailure, } - currentState := api.PodStatus{ - Host: "machine", - } tests := []struct { pod *api.Pod status api.PodPhase test string }{ - {&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"}, + {&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"}, { &api.Pod{ Spec: desiredState, @@ -2369,7 +2354,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) { runningState("containerA"), runningState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2383,7 +2367,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) { succeededState("containerA"), succeededState("containerB"), }, - Host: "machine", }, }, api.PodSucceeded, @@ -2397,7 +2380,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) { failedState("containerA"), failedState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2411,7 +2393,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) { runningState("containerA"), succeededState("containerB"), }, - Host: "machine", }, }, api.PodRunning, @@ -2424,7 +2405,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) { ContainerStatuses: []api.ContainerStatus{ runningState("containerA"), }, - Host: "machine", }, }, api.PodPending, diff --git a/pkg/registry/generic/etcd/etcd_test.go b/pkg/registry/generic/etcd/etcd_test.go index bdb49ca0872..34a8ab5cb61 100644 --- a/pkg/registry/generic/etcd/etcd_test.go +++ b/pkg/registry/generic/etcd/etcd_test.go @@ -107,11 +107,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) { func TestEtcdList(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } podB := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "bar"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } normalListResp := &etcd.Response{ @@ -189,11 +189,11 @@ func TestEtcdList(t *testing.T) { func TestEtcdCreate(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } podB := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, - Status: api.PodStatus{Host: "machine2"}, + Spec: api.PodSpec{Host: "machine2"}, } nodeWithPodA := tools.EtcdResponseWithError{ @@ -268,11 +268,11 @@ func TestEtcdCreate(t *testing.T) { func TestEtcdCreateWithName(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } podB := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, - Status: api.PodStatus{Host: "machine2"}, + Spec: api.PodSpec{Host: "machine2"}, } nodeWithPodA := tools.EtcdResponseWithError{ @@ -344,11 +344,11 @@ func TestEtcdCreateWithName(t *testing.T) { func TestEtcdUpdate(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } podB := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault, ResourceVersion: "1"}, - Status: api.PodStatus{Host: "machine2"}, + Spec: api.PodSpec{Host: "machine2"}, } nodeWithPodA := tools.EtcdResponseWithError{ @@ -460,11 +460,11 @@ func TestEtcdUpdate(t *testing.T) { func TestEtcdUpdateWithName(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } podB := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - Status: api.PodStatus{Host: "machine2"}, + Spec: api.PodSpec{Host: "machine2"}, } nodeWithPodA := tools.EtcdResponseWithError{ @@ -535,7 +535,7 @@ func TestEtcdUpdateWithName(t *testing.T) { func TestEtcdGet(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } nodeWithPodA := tools.EtcdResponseWithError{ @@ -591,7 +591,7 @@ func TestEtcdGet(t *testing.T) { func TestEtcdDelete(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } nodeWithPodA := tools.EtcdResponseWithError{ @@ -650,7 +650,7 @@ func TestEtcdDelete(t *testing.T) { func TestEtcdWatch(t *testing.T) { podA := &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, } respWithPodA := &etcd.Response{ Node: &etcd.Node{ diff --git a/pkg/registry/pod/etcd/etcd.go b/pkg/registry/pod/etcd/etcd.go index e67761acf87..f35eaf8128e 100644 --- a/pkg/registry/pod/etcd/etcd.go +++ b/pkg/registry/pod/etcd/etcd.go @@ -122,11 +122,10 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx api.Context, podID, oldMachin if !ok { return nil, 0, fmt.Errorf("unexpected object: %#v", obj) } - if pod.Spec.Host != oldMachine || pod.Status.Host != oldMachine { - return nil, 0, fmt.Errorf("pod %v is already assigned to host %q or %q", pod.Name, pod.Spec.Host, pod.Status.Host) + if pod.Spec.Host != oldMachine { + return nil, 0, fmt.Errorf("pod %v is already assigned to host %q", pod.Name, pod.Spec.Host) } pod.Spec.Host = machine - pod.Status.Host = machine if pod.Annotations == nil { pod.Annotations = make(map[string]string) } diff --git a/pkg/registry/pod/etcd/etcd_test.go b/pkg/registry/pod/etcd/etcd_test.go index 9314a1210fd..b5cfffeabc4 100644 --- a/pkg/registry/pod/etcd/etcd_test.go +++ b/pkg/registry/pod/etcd/etcd_test.go @@ -217,13 +217,14 @@ func TestListPodList(t *testing.T) { { Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo"}, - Status: api.PodStatus{Phase: api.PodRunning, Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, + Status: api.PodStatus{Phase: api.PodRunning}, }), }, { Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "bar"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), }, }, @@ -241,10 +242,10 @@ func TestListPodList(t *testing.T) { if len(pods.Items) != 2 { t.Errorf("Unexpected pod list: %#v", pods) } - if pods.Items[0].Name != "foo" || pods.Items[0].Status.Phase != api.PodRunning || pods.Items[0].Status.Host != "machine" { + if pods.Items[0].Name != "foo" || pods.Items[0].Status.Phase != api.PodRunning || pods.Items[0].Spec.Host != "machine" { t.Errorf("Unexpected pod: %#v", pods.Items[0]) } - if pods.Items[1].Name != "bar" || pods.Items[1].Status.Host != "machine" { + if pods.Items[1].Name != "bar" || pods.Items[1].Spec.Host != "machine" { t.Errorf("Unexpected pod: %#v", pods.Items[1]) } } @@ -364,7 +365,7 @@ func TestPodDecode(t *testing.T) { func TestGet(t *testing.T) { expect := validNewPod() expect.Status.Phase = api.PodRunning - expect.Status.Host = "machine" + expect.Spec.Host = "machine" fakeEtcdClient, helper := newHelper(t) fakeEtcdClient.Data["/registry/pods/test/foo"] = tools.EtcdResponseWithError{ @@ -454,7 +455,7 @@ func TestUpdateWithConflictingNamespace(t *testing.T) { Node: &etcd.Node{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), ModifiedIndex: 1, }, @@ -608,7 +609,7 @@ func TestDeletePod(t *testing.T) { Name: "foo", Namespace: api.NamespaceDefault, }, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), ModifiedIndex: 1, CreatedIndex: 1, @@ -1058,16 +1059,13 @@ func TestEtcdUpdateScheduled(t *testing.T) { Namespace: api.NamespaceDefault, }, Spec: api.PodSpec{ - // Host: "machine", + Host: "machine", Containers: []api.Container{ { Image: "foo:v1", }, }, }, - Status: api.PodStatus{ - Host: "machine", - }, }), 1) podIn := api.Pod{ @@ -1079,6 +1077,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { }, }, Spec: api.PodSpec{ + Host: "machine", Containers: []api.Container{ { Image: "foo:v2", @@ -1089,9 +1088,6 @@ func TestEtcdUpdateScheduled(t *testing.T) { RestartPolicy: api.RestartPolicyAlways, DNSPolicy: api.DNSClusterFirst, }, - Status: api.PodStatus{ - Host: "machine", - }, } _, _, err := registry.Update(ctx, &podIn) if err != nil { @@ -1121,15 +1117,13 @@ func TestEtcdUpdateStatus(t *testing.T) { Namespace: api.NamespaceDefault, }, Spec: api.PodSpec{ + Host: "machine", Containers: []api.Container{ { Image: "foo:v1", }, }, }, - Status: api.PodStatus{ - Host: "machine", - }, } fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &podStart), 1) @@ -1141,8 +1135,8 @@ func TestEtcdUpdateStatus(t *testing.T) { "foo": "bar", }, }, - // should be ignored Spec: api.PodSpec{ + Host: "machine", Containers: []api.Container{ { Image: "foo:v2", @@ -1152,7 +1146,6 @@ func TestEtcdUpdateStatus(t *testing.T) { }, }, Status: api.PodStatus{ - Host: "machine", Phase: api.PodRunning, PodIP: "127.0.0.1", Message: "is now scheduled", @@ -1189,7 +1182,7 @@ func TestEtcdDeletePod(t *testing.T) { key, _ := registry.KeyFunc(ctx, "foo") fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), 0) _, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0)) if err != nil { @@ -1210,7 +1203,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { key, _ := registry.KeyFunc(ctx, "foo") fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), 0) _, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0)) if err != nil { @@ -1277,13 +1270,13 @@ func TestEtcdList(t *testing.T) { { Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "foo"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), }, { Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ ObjectMeta: api.ObjectMeta{Name: "bar"}, - Status: api.PodStatus{Host: "machine"}, + Spec: api.PodSpec{Host: "machine"}, }), }, }, @@ -1300,8 +1293,8 @@ func TestEtcdList(t *testing.T) { if len(pods.Items) != 2 || pods.Items[0].Name != "foo" || pods.Items[1].Name != "bar" { t.Errorf("Unexpected pod list: %#v", pods) } - if pods.Items[0].Status.Host != "machine" || - pods.Items[1].Status.Host != "machine" { + if pods.Items[0].Spec.Host != "machine" || + pods.Items[1].Spec.Host != "machine" { t.Errorf("Failed to populate host name.") } } diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index cbc1b845268..26a46354eb6 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -54,7 +54,6 @@ func (podStrategy) NamespaceScoped() bool { func (podStrategy) PrepareForCreate(obj runtime.Object) { pod := obj.(*api.Pod) pod.Status = api.PodStatus{ - Host: pod.Spec.Host, Phase: api.PodPending, } } diff --git a/pkg/scheduler/predicates.go b/pkg/scheduler/predicates.go index c43b2b27696..ce8c94cadc6 100644 --- a/pkg/scheduler/predicates.go +++ b/pkg/scheduler/predicates.go @@ -290,7 +290,7 @@ func (s *ServiceAffinity) CheckServiceAffinity(pod api.Pod, existingPods []api.P } if len(nsServicePods) > 0 { // consider any service pod and fetch the minion its hosted on - otherMinion, err := s.nodeInfo.GetNodeInfo(nsServicePods[0].Status.Host) + otherMinion, err := s.nodeInfo.GetNodeInfo(nsServicePods[0].Spec.Host) if err != nil { return false, err } @@ -359,16 +359,7 @@ func MapPodsToMachines(lister PodLister) (map[string][]api.Pod, error) { return map[string][]api.Pod{}, err } for _, scheduledPod := range pods { - // TODO: switch to Spec.Host! There was some confusion previously - // about whether components should judge a pod's location - // based on spec.Host or status.Host. It has been decided that - // spec.Host is the canonical location of the pod. Status.Host - // will either be removed, be a copy, or in theory it could be - // used as a signal that kubelet has agreed to run the pod. - // - // This could be fixed now, but just requires someone to try it - // and verify that e2e still passes. - host := scheduledPod.Status.Host + host := scheduledPod.Spec.Host machineToPods[host] = append(machineToPods[host], scheduledPod) } return machineToPods, nil diff --git a/pkg/scheduler/predicates_test.go b/pkg/scheduler/predicates_test.go index 566259bd8d8..598cc527760 100644 --- a/pkg/scheduler/predicates_test.go +++ b/pkg/scheduler/predicates_test.go @@ -517,7 +517,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine1"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine1"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, fits: true, @@ -526,7 +526,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, fits: true, @@ -535,7 +535,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, fits: false, @@ -544,7 +544,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns2"}}}, fits: true, @@ -553,7 +553,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns2"}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns2"}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}}, fits: true, @@ -562,7 +562,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}}, fits: false, @@ -571,7 +571,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, node: "machine1", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, fits: false, @@ -580,7 +580,7 @@ func TestServiceAffinity(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, - pods: []api.Pod{{Status: api.PodStatus{Host: "machine5"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, + pods: []api.Pod{{Spec: api.PodSpec{Host: "machine5"}, ObjectMeta: api.ObjectMeta{Labels: selector}}}, node: "machine4", services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, fits: true, diff --git a/pkg/scheduler/priorities_test.go b/pkg/scheduler/priorities_test.go index 9c19a7f97dd..486cb0a7a39 100644 --- a/pkg/scheduler/priorities_test.go +++ b/pkg/scheduler/priorities_test.go @@ -46,16 +46,17 @@ func TestLeastRequested(t *testing.T) { "bar": "foo", "baz": "blah", } - machine1Status := api.PodStatus{ + machine1Spec := api.PodSpec{ Host: "machine1", } - machine2Status := api.PodStatus{ + machine2Spec := api.PodSpec{ Host: "machine2", } noResources := api.PodSpec{ Containers: []api.Container{}, } cpuOnly := api.PodSpec{ + Host: "machine1", Containers: []api.Container{ { Resources: api.ResourceRequirements{ @@ -73,7 +74,10 @@ func TestLeastRequested(t *testing.T) { }, }, } + cpuOnly2 := cpuOnly + cpuOnly2.Host = "machine2" cpuAndMemory := api.PodSpec{ + Host: "machine2", Containers: []api.Container{ { Resources: api.ResourceRequirements{ @@ -151,10 +155,10 @@ func TestLeastRequested(t *testing.T) { expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, test: "no resources requested, pods scheduled", pods: []api.Pod{ - {Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: machine2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: machine2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: machine1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: machine1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: machine2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: machine2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, }, { @@ -174,10 +178,10 @@ func TestLeastRequested(t *testing.T) { expectedList: []HostPriority{{"machine1", 7}, {"machine2", 5}}, test: "no resources requested, pods scheduled with resources", pods: []api.Pod{ - {Spec: cpuOnly, Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Spec: cpuOnly, Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Spec: cpuOnly, Status: machine2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Spec: cpuAndMemory, Status: machine2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: cpuOnly2, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: cpuAndMemory, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, }, { @@ -197,8 +201,8 @@ func TestLeastRequested(t *testing.T) { expectedList: []HostPriority{{"machine1", 5}, {"machine2", 4}}, test: "resources requested, pods scheduled with resources", pods: []api.Pod{ - {Spec: cpuOnly, Status: machine1Status}, - {Spec: cpuAndMemory, Status: machine2Status}, + {Spec: cpuOnly}, + {Spec: cpuAndMemory}, }, }, { @@ -218,8 +222,8 @@ func TestLeastRequested(t *testing.T) { expectedList: []HostPriority{{"machine1", 5}, {"machine2", 6}}, test: "resources requested, pods scheduled with resources, differently sized machines", pods: []api.Pod{ - {Spec: cpuOnly, Status: machine1Status}, - {Spec: cpuAndMemory, Status: machine2Status}, + {Spec: cpuOnly}, + {Spec: cpuAndMemory}, }, }, { @@ -239,8 +243,8 @@ func TestLeastRequested(t *testing.T) { expectedList: []HostPriority{{"machine1", 5}, {"machine2", 2}}, test: "requested resources exceed minion capacity", pods: []api.Pod{ - {Spec: cpuOnly, Status: machine1Status}, - {Spec: cpuAndMemory, Status: machine2Status}, + {Spec: cpuOnly}, + {Spec: cpuAndMemory}, }, }, { diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go index e0c652a76f2..c4285664487 100644 --- a/pkg/scheduler/scheduler_test.go +++ b/pkg/scheduler/scheduler_test.go @@ -65,10 +65,8 @@ func newPod(host string, hostPorts ...int) api.Pod { networkPorts = append(networkPorts, api.ContainerPort{HostPort: port}) } return api.Pod{ - Status: api.PodStatus{ - Host: host, - }, Spec: api.PodSpec{ + Host: host, Containers: []api.Container{ { Ports: networkPorts, diff --git a/pkg/scheduler/spreading.go b/pkg/scheduler/spreading.go index 2d12c3c6e96..43322703504 100644 --- a/pkg/scheduler/spreading.go +++ b/pkg/scheduler/spreading.go @@ -63,10 +63,10 @@ func (s *ServiceSpread) CalculateSpreadPriority(pod api.Pod, podLister PodLister counts := map[string]int{} if len(nsServicePods) > 0 { for _, pod := range nsServicePods { - counts[pod.Status.Host]++ + counts[pod.Spec.Host]++ // Compute the maximum number of pods hosted on any minion - if counts[pod.Status.Host] > maxCount { - maxCount = counts[pod.Status.Host] + if counts[pod.Spec.Host] > maxCount { + maxCount = counts[pod.Spec.Host] } } } @@ -140,7 +140,7 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod api.Pod, podList podCounts := map[string]int{} for _, pod := range nsServicePods { - label, exists := labeledMinions[pod.Status.Host] + label, exists := labeledMinions[pod.Spec.Host] if !exists { continue } diff --git a/pkg/scheduler/spreading_test.go b/pkg/scheduler/spreading_test.go index e0b541459a5..00bb7c5b5b6 100644 --- a/pkg/scheduler/spreading_test.go +++ b/pkg/scheduler/spreading_test.go @@ -33,10 +33,10 @@ func TestServiceSpreadPriority(t *testing.T) { "bar": "foo", "baz": "blah", } - zone1Status := api.PodStatus{ + zone1Spec := api.PodSpec{ Host: "machine1", } - zone2Status := api.PodStatus{ + zone2Spec := api.PodSpec{ Host: "machine2", } tests := []struct { @@ -54,14 +54,14 @@ func TestServiceSpreadPriority(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, - pods: []api.Pod{{Status: zone1Status}}, + pods: []api.Pod{{Spec: zone1Spec}}, nodes: []string{"machine1", "machine2"}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, test: "no services", }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, - pods: []api.Pod{{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}}, + pods: []api.Pod{{Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}}, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, @@ -70,8 +70,8 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -81,11 +81,11 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -95,10 +95,10 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}, ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}}}, @@ -108,11 +108,11 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns2"}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns2"}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}}, @@ -122,9 +122,9 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -134,10 +134,10 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -147,9 +147,9 @@ func TestServiceSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: []string{"machine1", "machine2"}, services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"baz": "blah"}}}}, @@ -188,13 +188,13 @@ func TestZoneSpreadPriority(t *testing.T) { nozone := map[string]string{ "name": "value", } - zone0Status := api.PodStatus{ + zone0Spec := api.PodSpec{ Host: "machine01", } - zone1Status := api.PodStatus{ + zone1Spec := api.PodSpec{ Host: "machine11", } - zone2Status := api.PodStatus{ + zone2Spec := api.PodSpec{ Host: "machine21", } labeledNodes := map[string]map[string]string{ @@ -219,7 +219,7 @@ func TestZoneSpreadPriority(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, - pods: []api.Pod{{Status: zone1Status}}, + pods: []api.Pod{{Spec: zone1Spec}}, nodes: labeledNodes, expectedList: []HostPriority{{"machine11", 10}, {"machine12", 10}, {"machine21", 10}, {"machine22", 10}, @@ -228,7 +228,7 @@ func TestZoneSpreadPriority(t *testing.T) { }, { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, - pods: []api.Pod{{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}}, + pods: []api.Pod{{Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}}, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}}, expectedList: []HostPriority{{"machine11", 10}, {"machine12", 10}, @@ -239,9 +239,9 @@ func TestZoneSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone0Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone0Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -253,9 +253,9 @@ func TestZoneSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -267,10 +267,10 @@ func TestZoneSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, }, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}, ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}}}, @@ -282,10 +282,10 @@ func TestZoneSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, @@ -297,9 +297,9 @@ func TestZoneSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"baz": "blah"}}}}, @@ -311,10 +311,10 @@ func TestZoneSpreadPriority(t *testing.T) { { pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pods: []api.Pod{ - {Status: zone0Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, - {Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone0Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, + {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}}, }, nodes: labeledNodes, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, diff --git a/plugin/pkg/scheduler/factory/factory.go b/plugin/pkg/scheduler/factory/factory.go index 590394d75df..7c28775a78d 100644 --- a/plugin/pkg/scheduler/factory/factory.go +++ b/plugin/pkg/scheduler/factory/factory.go @@ -288,7 +288,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err) return } - if pod.Status.Host == "" { + if pod.Spec.Host == "" { podQueue.Add(pod) } }() diff --git a/plugin/pkg/scheduler/scheduler.go b/plugin/pkg/scheduler/scheduler.go index 3dcedb8e1d8..697bdb1ab60 100644 --- a/plugin/pkg/scheduler/scheduler.go +++ b/plugin/pkg/scheduler/scheduler.go @@ -128,7 +128,6 @@ func (s *Scheduler) scheduleOne() { // tell the model to assume that this binding took effect. assumed := *pod assumed.Spec.Host = dest - assumed.Status.Host = dest s.config.Modeler.AssumePod(&assumed) }) } diff --git a/plugin/pkg/scheduler/scheduler_test.go b/plugin/pkg/scheduler/scheduler_test.go index 22b0126a635..46355598626 100644 --- a/plugin/pkg/scheduler/scheduler_test.go +++ b/plugin/pkg/scheduler/scheduler_test.go @@ -40,9 +40,6 @@ func podWithID(id, desiredHost string) *api.Pod { Spec: api.PodSpec{ Host: desiredHost, }, - Status: api.PodStatus{ - Host: desiredHost, - }, } } diff --git a/test/e2e/density.go b/test/e2e/density.go index c159b68cc12..9398b03c578 100644 --- a/test/e2e/density.go +++ b/test/e2e/density.go @@ -150,7 +150,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) { if p.Status.Phase == api.PodRunning { current++ } else if p.Status.Phase == api.PodPending { - if p.Status.Host == "" { + if p.Spec.Host == "" { waiting++ } else { pending++ diff --git a/test/e2e/util.go b/test/e2e/util.go index 2fe21e971c0..cc744f0c5b1 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -337,7 +337,7 @@ func testContainerOutputInNamespace(ns, scenarioName string, c *client.Client, p } By(fmt.Sprintf("Trying to get logs from host %s pod %s container %s: %v", - podStatus.Status.Host, podStatus.Name, containerName, err)) + podStatus.Spec.Host, podStatus.Name, containerName, err)) var logs []byte start := time.Now() @@ -346,7 +346,7 @@ func testContainerOutputInNamespace(ns, scenarioName string, c *client.Client, p logs, err = c.Get(). Prefix("proxy"). Resource("minions"). - Name(podStatus.Status.Host). + Name(podStatus.Spec.Host). Suffix("containerLogs", ns, podStatus.Name, containerName). Do(). Raw() @@ -354,7 +354,7 @@ func testContainerOutputInNamespace(ns, scenarioName string, c *client.Client, p By(fmt.Sprintf("pod logs:%v\n", string(logs))) if strings.Contains(string(logs), "Internal Error") { By(fmt.Sprintf("Failed to get logs from host %q pod %q container %q: %v", - podStatus.Status.Host, podStatus.Name, containerName, string(logs))) + podStatus.Spec.Host, podStatus.Name, containerName, string(logs))) time.Sleep(5 * time.Second) continue } diff --git a/test/integration/client_test.go b/test/integration/client_test.go index a5e48c9cf89..eacb9d028a2 100644 --- a/test/integration/client_test.go +++ b/test/integration/client_test.go @@ -127,7 +127,7 @@ func TestClient(t *testing.T) { if actual.Name != got.Name { t.Errorf("expected pod %#v, got %#v", got, actual) } - if actual.Status.Host != "" { + if actual.Spec.Host != "" { t.Errorf("expected pod to be unscheduled, got %#v", actual) } }