Removed PodStatus.Host

Fixes #6165
This commit is contained in:
Piotr Szczesniak 2015-04-02 14:52:03 +02:00
parent 860257e01f
commit 5c6439d449
31 changed files with 149 additions and 199 deletions

View File

@ -262,7 +262,7 @@ func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc {
podInfo := fakeKubeletClient{} podInfo := fakeKubeletClient{}
return func() (bool, error) { return func() (bool, error) {
for i := range pods.Items { 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) glog.Infof("Check whether pod %s.%s exists on node %q", id, namespace, host)
if len(host) == 0 { if len(host) == 0 {
glog.Infof("Pod %s.%s is not bound to a host yet", id, namespace) glog.Infof("Pod %s.%s is not bound to a host yet", id, namespace)

View File

@ -723,9 +723,6 @@ type PodStatus struct {
// A human readable message indicating details about why the pod is in this state. // A human readable message indicating details about why the pod is in this state.
Message string `json:"message,omitempty"` 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"` HostIP string `json:"hostIP,omitempty"`
PodIP string `json:"podIP,omitempty"` PodIP string `json:"podIP,omitempty"`

View File

@ -192,7 +192,6 @@ func init() {
return err return err
} }
out.Message = in.Message out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP out.HostIP = in.HostIP
out.PodIP = in.PodIP out.PodIP = in.PodIP
return nil return nil
@ -209,7 +208,6 @@ func init() {
} }
out.Message = in.Message out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP out.HostIP = in.HostIP
out.PodIP = in.PodIP out.PodIP = in.PodIP
return nil return nil
@ -368,6 +366,7 @@ func init() {
return err return err
} }
out.DesiredState.Host = in.Spec.Host out.DesiredState.Host = in.Spec.Host
out.CurrentState.Host = in.Spec.Host
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil { if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
return err return err
} }

View File

@ -178,6 +178,7 @@ func init() {
return err return err
} }
out.DesiredState.Host = in.Spec.Host out.DesiredState.Host = in.Spec.Host
out.CurrentState.Host = in.Spec.Host
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil { if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
return err return err
} }
@ -496,7 +497,6 @@ func init() {
return err return err
} }
out.Message = in.Message out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP out.HostIP = in.HostIP
out.PodIP = in.PodIP out.PodIP = in.PodIP
return nil return nil
@ -512,7 +512,6 @@ func init() {
return err return err
} }
out.Message = in.Message out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP out.HostIP = in.HostIP
out.PodIP = in.PodIP out.PodIP = in.PodIP
return nil return nil

View File

@ -722,9 +722,6 @@ type PodStatus struct {
// A human readable message indicating details about why the pod is in this state. // 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"` 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"` 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"` PodIP string `json:"podIP,omitempty" description:"IP address allocated to the pod; routable at least within the cluster; empty if not yet allocated"`

View File

@ -769,8 +769,8 @@ func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
// TODO: allow change when bindings are properly decoupled from pods // TODO: allow change when bindings are properly decoupled from pods
if newPod.Status.Host != oldPod.Status.Host { if newPod.Spec.Host != oldPod.Spec.Host {
allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Status.Host, "pod host cannot be changed directly")) 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. // For status update we ignore changes to pod spec.

View File

@ -636,7 +636,7 @@ func (nc *NodeController) deletePods(nodeID string) error {
return err return err
} }
for _, pod := range pods.Items { for _, pod := range pods.Items {
if pod.Status.Host != nodeID { if pod.Spec.Host != nodeID {
continue continue
} }
glog.V(2).Infof("Delete pod %v", pod.Name) glog.V(2).Infof("Delete pod %v", pod.Name)

View File

@ -1447,7 +1447,7 @@ func newNode(name string) *api.Node {
} }
func newPod(name, host string) *api.Pod { 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 { func sortedNodeNames(nodes []*api.Node) []string {

View File

@ -135,7 +135,7 @@ func RunExec(f *Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.C
req := client.RESTClient.Get(). req := client.RESTClient.Get().
Prefix("proxy"). Prefix("proxy").
Resource("minions"). Resource("minions").
Name(pod.Status.Host). Name(pod.Spec.Host).
Suffix("exec", namespace, podName, containerName) Suffix("exec", namespace, podName, containerName)
e := remotecommand.New(req, config, args, stdin, cmdOut, cmdErr, tty) e := remotecommand.New(req, config, args, stdin, cmdOut, cmdErr, tty)

View File

@ -116,7 +116,7 @@ func RunLog(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error
readCloser, err := client.RESTClient.Get(). readCloser, err := client.RESTClient.Get().
Prefix("proxy"). Prefix("proxy").
Resource("minions"). Resource("minions").
Name(pod.Status.Host). Name(pod.Spec.Host).
Suffix("containerLogs", namespace, podID, container). Suffix("containerLogs", namespace, podID, container).
Param("follow", strconv.FormatBool(follow)). Param("follow", strconv.FormatBool(follow)).
Stream() Stream()

View File

@ -105,7 +105,7 @@ func RunPortForward(f *Factory, cmd *cobra.Command, args []string) error {
req := client.RESTClient.Get(). req := client.RESTClient.Get().
Prefix("proxy"). Prefix("proxy").
Resource("minions"). Resource("minions").
Name(pod.Status.Host). Name(pod.Spec.Host).
Suffix("portForward", namespace, podName) Suffix("portForward", namespace, podName)
pf, err := portforward.New(req, config, args, stopCh) pf, err := portforward.New(req, config, args, stopCh)

View File

@ -238,7 +238,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
return tabbedString(func(out io.Writer) error { return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", pod.Name) fmt.Fprintf(out, "Name:\t%s\n", pod.Name)
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&pod.Spec)) 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, "Labels:\t%s\n", formatLabels(pod.Labels))
fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase)) fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase))
fmt.Fprintf(out, "Replication Controllers:\t%s\n", printReplicationControllersByLabels(rcs)) 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 return "", err
} }
for _, pod := range allPods.Items { for _, pod := range allPods.Items {
if pod.Status.Host != name { if pod.Spec.Host != name {
continue continue
} }
pods = append(pods, pod) pods = append(pods, pod)

View File

@ -329,7 +329,7 @@ func printPod(pod *api.Pod, w io.Writer) error {
pod.Status.PodIP, pod.Status.PodIP,
firstContainer.Name, firstContainer.Name,
firstContainer.Image, firstContainer.Image,
podHostString(pod.Status.Host, pod.Status.HostIP), podHostString(pod.Spec.Host, pod.Status.HostIP),
formatLabels(pod.Labels), formatLabels(pod.Labels),
pod.Status.Phase, pod.Status.Phase,
units.HumanDuration(time.Now().Sub(pod.CreationTimestamp.Time))) units.HumanDuration(time.Now().Sub(pod.CreationTimestamp.Time)))

View File

@ -1960,7 +1960,6 @@ func (kl *Kubelet) generatePodStatusByPod(pod *api.Pod) (api.PodStatus, error) {
} else { } else {
pendingStatus := api.PodStatus{ pendingStatus := api.PodStatus{
Phase: api.PodPending, Phase: api.PodPending,
Host: kl.GetHostname(),
Message: fmt.Sprintf("Query docker container info failed with error (%v)", err), Message: fmt.Sprintf("Query docker container info failed with error (%v)", err),
} }
return pendingStatus, nil 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.Conditions = append(podStatus.Conditions, getPodReadyCondition(spec, podStatus.ContainerStatuses)...)
podStatus.Host = kl.GetHostname()
hostIP, err := kl.GetHostIP() hostIP, err := kl.GetHostIP()
if err != nil { if err != nil {
glog.Errorf("Cannot get host IP: %v", err) glog.Errorf("Cannot get host IP: %v", err)

View File

@ -2169,22 +2169,20 @@ func failedState(cName string) api.ContainerStatus {
func TestPodPhaseWithRestartAlways(t *testing.T) { func TestPodPhaseWithRestartAlways(t *testing.T) {
desiredState := api.PodSpec{ desiredState := api.PodSpec{
Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{Name: "containerA"}, {Name: "containerA"},
{Name: "containerB"}, {Name: "containerB"},
}, },
RestartPolicy: api.RestartPolicyAlways, RestartPolicy: api.RestartPolicyAlways,
} }
currentState := api.PodStatus{
Host: "machine",
}
tests := []struct { tests := []struct {
pod *api.Pod pod *api.Pod
status api.PodPhase status api.PodPhase
test string test string
}{ }{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"}, {&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"},
{ {
&api.Pod{ &api.Pod{
Spec: desiredState, Spec: desiredState,
@ -2193,7 +2191,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
runningState("containerA"), runningState("containerA"),
runningState("containerB"), runningState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2207,7 +2204,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
stoppedState("containerA"), stoppedState("containerA"),
stoppedState("containerB"), stoppedState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2221,7 +2217,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
runningState("containerA"), runningState("containerA"),
stoppedState("containerB"), stoppedState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2234,7 +2229,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
ContainerStatuses: []api.ContainerStatus{ ContainerStatuses: []api.ContainerStatus{
runningState("containerA"), runningState("containerA"),
}, },
Host: "machine",
}, },
}, },
api.PodPending, api.PodPending,
@ -2250,22 +2244,20 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
func TestPodPhaseWithRestartNever(t *testing.T) { func TestPodPhaseWithRestartNever(t *testing.T) {
desiredState := api.PodSpec{ desiredState := api.PodSpec{
Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{Name: "containerA"}, {Name: "containerA"},
{Name: "containerB"}, {Name: "containerB"},
}, },
RestartPolicy: api.RestartPolicyNever, RestartPolicy: api.RestartPolicyNever,
} }
currentState := api.PodStatus{
Host: "machine",
}
tests := []struct { tests := []struct {
pod *api.Pod pod *api.Pod
status api.PodPhase status api.PodPhase
test string test string
}{ }{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"}, {&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"},
{ {
&api.Pod{ &api.Pod{
Spec: desiredState, Spec: desiredState,
@ -2274,7 +2266,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
runningState("containerA"), runningState("containerA"),
runningState("containerB"), runningState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2288,7 +2279,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
succeededState("containerA"), succeededState("containerA"),
succeededState("containerB"), succeededState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodSucceeded, api.PodSucceeded,
@ -2302,7 +2292,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
failedState("containerA"), failedState("containerA"),
failedState("containerB"), failedState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodFailed, api.PodFailed,
@ -2316,7 +2305,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
runningState("containerA"), runningState("containerA"),
succeededState("containerB"), succeededState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2329,7 +2317,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
ContainerStatuses: []api.ContainerStatus{ ContainerStatuses: []api.ContainerStatus{
runningState("containerA"), runningState("containerA"),
}, },
Host: "machine",
}, },
}, },
api.PodPending, api.PodPending,
@ -2345,22 +2332,20 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
func TestPodPhaseWithRestartOnFailure(t *testing.T) { func TestPodPhaseWithRestartOnFailure(t *testing.T) {
desiredState := api.PodSpec{ desiredState := api.PodSpec{
Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{Name: "containerA"}, {Name: "containerA"},
{Name: "containerB"}, {Name: "containerB"},
}, },
RestartPolicy: api.RestartPolicyOnFailure, RestartPolicy: api.RestartPolicyOnFailure,
} }
currentState := api.PodStatus{
Host: "machine",
}
tests := []struct { tests := []struct {
pod *api.Pod pod *api.Pod
status api.PodPhase status api.PodPhase
test string test string
}{ }{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"}, {&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"},
{ {
&api.Pod{ &api.Pod{
Spec: desiredState, Spec: desiredState,
@ -2369,7 +2354,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
runningState("containerA"), runningState("containerA"),
runningState("containerB"), runningState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2383,7 +2367,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
succeededState("containerA"), succeededState("containerA"),
succeededState("containerB"), succeededState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodSucceeded, api.PodSucceeded,
@ -2397,7 +2380,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
failedState("containerA"), failedState("containerA"),
failedState("containerB"), failedState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2411,7 +2393,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
runningState("containerA"), runningState("containerA"),
succeededState("containerB"), succeededState("containerB"),
}, },
Host: "machine",
}, },
}, },
api.PodRunning, api.PodRunning,
@ -2424,7 +2405,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
ContainerStatuses: []api.ContainerStatus{ ContainerStatuses: []api.ContainerStatus{
runningState("containerA"), runningState("containerA"),
}, },
Host: "machine",
}, },
}, },
api.PodPending, api.PodPending,

View File

@ -107,11 +107,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) {
func TestEtcdList(t *testing.T) { func TestEtcdList(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "bar"}, ObjectMeta: api.ObjectMeta{Name: "bar"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
normalListResp := &etcd.Response{ normalListResp := &etcd.Response{
@ -189,11 +189,11 @@ func TestEtcdList(t *testing.T) {
func TestEtcdCreate(t *testing.T) { func TestEtcdCreate(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
Status: api.PodStatus{Host: "machine2"}, Spec: api.PodSpec{Host: "machine2"},
} }
nodeWithPodA := tools.EtcdResponseWithError{ nodeWithPodA := tools.EtcdResponseWithError{
@ -268,11 +268,11 @@ func TestEtcdCreate(t *testing.T) {
func TestEtcdCreateWithName(t *testing.T) { func TestEtcdCreateWithName(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
Status: api.PodStatus{Host: "machine2"}, Spec: api.PodSpec{Host: "machine2"},
} }
nodeWithPodA := tools.EtcdResponseWithError{ nodeWithPodA := tools.EtcdResponseWithError{
@ -344,11 +344,11 @@ func TestEtcdCreateWithName(t *testing.T) {
func TestEtcdUpdate(t *testing.T) { func TestEtcdUpdate(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault, ResourceVersion: "1"}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault, ResourceVersion: "1"},
Status: api.PodStatus{Host: "machine2"}, Spec: api.PodSpec{Host: "machine2"},
} }
nodeWithPodA := tools.EtcdResponseWithError{ nodeWithPodA := tools.EtcdResponseWithError{
@ -460,11 +460,11 @@ func TestEtcdUpdate(t *testing.T) {
func TestEtcdUpdateWithName(t *testing.T) { func TestEtcdUpdateWithName(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
podB := &api.Pod{ podB := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
Status: api.PodStatus{Host: "machine2"}, Spec: api.PodSpec{Host: "machine2"},
} }
nodeWithPodA := tools.EtcdResponseWithError{ nodeWithPodA := tools.EtcdResponseWithError{
@ -535,7 +535,7 @@ func TestEtcdUpdateWithName(t *testing.T) {
func TestEtcdGet(t *testing.T) { func TestEtcdGet(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
nodeWithPodA := tools.EtcdResponseWithError{ nodeWithPodA := tools.EtcdResponseWithError{
@ -591,7 +591,7 @@ func TestEtcdGet(t *testing.T) {
func TestEtcdDelete(t *testing.T) { func TestEtcdDelete(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
nodeWithPodA := tools.EtcdResponseWithError{ nodeWithPodA := tools.EtcdResponseWithError{
@ -650,7 +650,7 @@ func TestEtcdDelete(t *testing.T) {
func TestEtcdWatch(t *testing.T) { func TestEtcdWatch(t *testing.T) {
podA := &api.Pod{ podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
} }
respWithPodA := &etcd.Response{ respWithPodA := &etcd.Response{
Node: &etcd.Node{ Node: &etcd.Node{

View File

@ -122,11 +122,10 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx api.Context, podID, oldMachin
if !ok { if !ok {
return nil, 0, fmt.Errorf("unexpected object: %#v", obj) return nil, 0, fmt.Errorf("unexpected object: %#v", obj)
} }
if pod.Spec.Host != oldMachine || pod.Status.Host != oldMachine { if pod.Spec.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) return nil, 0, fmt.Errorf("pod %v is already assigned to host %q", pod.Name, pod.Spec.Host)
} }
pod.Spec.Host = machine pod.Spec.Host = machine
pod.Status.Host = machine
if pod.Annotations == nil { if pod.Annotations == nil {
pod.Annotations = make(map[string]string) pod.Annotations = make(map[string]string)
} }

View File

@ -217,13 +217,14 @@ func TestListPodList(t *testing.T) {
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo"}, 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{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "bar"}, 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 { if len(pods.Items) != 2 {
t.Errorf("Unexpected pod list: %#v", pods) 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]) 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]) t.Errorf("Unexpected pod: %#v", pods.Items[1])
} }
} }
@ -364,7 +365,7 @@ func TestPodDecode(t *testing.T) {
func TestGet(t *testing.T) { func TestGet(t *testing.T) {
expect := validNewPod() expect := validNewPod()
expect.Status.Phase = api.PodRunning expect.Status.Phase = api.PodRunning
expect.Status.Host = "machine" expect.Spec.Host = "machine"
fakeEtcdClient, helper := newHelper(t) fakeEtcdClient, helper := newHelper(t)
fakeEtcdClient.Data["/registry/pods/test/foo"] = tools.EtcdResponseWithError{ fakeEtcdClient.Data["/registry/pods/test/foo"] = tools.EtcdResponseWithError{
@ -454,7 +455,7 @@ func TestUpdateWithConflictingNamespace(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
}), }),
ModifiedIndex: 1, ModifiedIndex: 1,
}, },
@ -608,7 +609,7 @@ func TestDeletePod(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
}), }),
ModifiedIndex: 1, ModifiedIndex: 1,
CreatedIndex: 1, CreatedIndex: 1,
@ -1058,16 +1059,13 @@ func TestEtcdUpdateScheduled(t *testing.T) {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
// Host: "machine", Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{ {
Image: "foo:v1", Image: "foo:v1",
}, },
}, },
}, },
Status: api.PodStatus{
Host: "machine",
},
}), 1) }), 1)
podIn := api.Pod{ podIn := api.Pod{
@ -1079,6 +1077,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
}, },
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{ {
Image: "foo:v2", Image: "foo:v2",
@ -1089,9 +1088,6 @@ func TestEtcdUpdateScheduled(t *testing.T) {
RestartPolicy: api.RestartPolicyAlways, RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst, DNSPolicy: api.DNSClusterFirst,
}, },
Status: api.PodStatus{
Host: "machine",
},
} }
_, _, err := registry.Update(ctx, &podIn) _, _, err := registry.Update(ctx, &podIn)
if err != nil { if err != nil {
@ -1121,15 +1117,13 @@ func TestEtcdUpdateStatus(t *testing.T) {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{ {
Image: "foo:v1", Image: "foo:v1",
}, },
}, },
}, },
Status: api.PodStatus{
Host: "machine",
},
} }
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &podStart), 1) fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &podStart), 1)
@ -1141,8 +1135,8 @@ func TestEtcdUpdateStatus(t *testing.T) {
"foo": "bar", "foo": "bar",
}, },
}, },
// should be ignored
Spec: api.PodSpec{ Spec: api.PodSpec{
Host: "machine",
Containers: []api.Container{ Containers: []api.Container{
{ {
Image: "foo:v2", Image: "foo:v2",
@ -1152,7 +1146,6 @@ func TestEtcdUpdateStatus(t *testing.T) {
}, },
}, },
Status: api.PodStatus{ Status: api.PodStatus{
Host: "machine",
Phase: api.PodRunning, Phase: api.PodRunning,
PodIP: "127.0.0.1", PodIP: "127.0.0.1",
Message: "is now scheduled", Message: "is now scheduled",
@ -1189,7 +1182,7 @@ func TestEtcdDeletePod(t *testing.T) {
key, _ := registry.KeyFunc(ctx, "foo") key, _ := registry.KeyFunc(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
}), 0) }), 0)
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0)) _, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
if err != nil { if err != nil {
@ -1210,7 +1203,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
key, _ := registry.KeyFunc(ctx, "foo") key, _ := registry.KeyFunc(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
}), 0) }), 0)
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0)) _, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
if err != nil { if err != nil {
@ -1277,13 +1270,13 @@ func TestEtcdList(t *testing.T) {
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Status: api.PodStatus{Host: "machine"}, Spec: api.PodSpec{Host: "machine"},
}), }),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "bar"}, 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" { if len(pods.Items) != 2 || pods.Items[0].Name != "foo" || pods.Items[1].Name != "bar" {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
if pods.Items[0].Status.Host != "machine" || if pods.Items[0].Spec.Host != "machine" ||
pods.Items[1].Status.Host != "machine" { pods.Items[1].Spec.Host != "machine" {
t.Errorf("Failed to populate host name.") t.Errorf("Failed to populate host name.")
} }
} }

View File

@ -54,7 +54,6 @@ func (podStrategy) NamespaceScoped() bool {
func (podStrategy) PrepareForCreate(obj runtime.Object) { func (podStrategy) PrepareForCreate(obj runtime.Object) {
pod := obj.(*api.Pod) pod := obj.(*api.Pod)
pod.Status = api.PodStatus{ pod.Status = api.PodStatus{
Host: pod.Spec.Host,
Phase: api.PodPending, Phase: api.PodPending,
} }
} }

View File

@ -290,7 +290,7 @@ func (s *ServiceAffinity) CheckServiceAffinity(pod api.Pod, existingPods []api.P
} }
if len(nsServicePods) > 0 { if len(nsServicePods) > 0 {
// consider any service pod and fetch the minion its hosted on // 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 { if err != nil {
return false, err return false, err
} }
@ -359,16 +359,7 @@ func MapPodsToMachines(lister PodLister) (map[string][]api.Pod, error) {
return map[string][]api.Pod{}, err return map[string][]api.Pod{}, err
} }
for _, scheduledPod := range pods { for _, scheduledPod := range pods {
// TODO: switch to Spec.Host! There was some confusion previously host := scheduledPod.Spec.Host
// 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
machineToPods[host] = append(machineToPods[host], scheduledPod) machineToPods[host] = append(machineToPods[host], scheduledPod)
} }
return machineToPods, nil return machineToPods, nil

View File

@ -517,7 +517,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
fits: true, fits: true,
@ -526,7 +526,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
fits: true, fits: true,
@ -535,7 +535,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
fits: false, fits: false,
@ -544,7 +544,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns2"}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns2"}}},
fits: true, fits: true,
@ -553,7 +553,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
fits: true, fits: true,
@ -562,7 +562,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
fits: false, fits: false,
@ -571,7 +571,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, 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", node: "machine1",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
fits: false, fits: false,
@ -580,7 +580,7 @@ func TestServiceAffinity(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}}, 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", node: "machine4",
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
fits: true, fits: true,

View File

@ -46,16 +46,17 @@ func TestLeastRequested(t *testing.T) {
"bar": "foo", "bar": "foo",
"baz": "blah", "baz": "blah",
} }
machine1Status := api.PodStatus{ machine1Spec := api.PodSpec{
Host: "machine1", Host: "machine1",
} }
machine2Status := api.PodStatus{ machine2Spec := api.PodSpec{
Host: "machine2", Host: "machine2",
} }
noResources := api.PodSpec{ noResources := api.PodSpec{
Containers: []api.Container{}, Containers: []api.Container{},
} }
cpuOnly := api.PodSpec{ cpuOnly := api.PodSpec{
Host: "machine1",
Containers: []api.Container{ Containers: []api.Container{
{ {
Resources: api.ResourceRequirements{ Resources: api.ResourceRequirements{
@ -73,7 +74,10 @@ func TestLeastRequested(t *testing.T) {
}, },
}, },
} }
cpuOnly2 := cpuOnly
cpuOnly2.Host = "machine2"
cpuAndMemory := api.PodSpec{ cpuAndMemory := api.PodSpec{
Host: "machine2",
Containers: []api.Container{ Containers: []api.Container{
{ {
Resources: api.ResourceRequirements{ Resources: api.ResourceRequirements{
@ -151,10 +155,10 @@ func TestLeastRequested(t *testing.T) {
expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}},
test: "no resources requested, pods scheduled", test: "no resources requested, pods scheduled",
pods: []api.Pod{ pods: []api.Pod{
{Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: machine1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: machine1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: machine2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: machine2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: machine2Status, 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}}, expectedList: []HostPriority{{"machine1", 7}, {"machine2", 5}},
test: "no resources requested, pods scheduled with resources", test: "no resources requested, pods scheduled with resources",
pods: []api.Pod{ pods: []api.Pod{
{Spec: cpuOnly, Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Spec: cpuOnly, Status: machine1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Spec: cpuOnly, Status: machine2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: cpuOnly2, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Spec: cpuAndMemory, Status: machine2Status, 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}}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 4}},
test: "resources requested, pods scheduled with resources", test: "resources requested, pods scheduled with resources",
pods: []api.Pod{ pods: []api.Pod{
{Spec: cpuOnly, Status: machine1Status}, {Spec: cpuOnly},
{Spec: cpuAndMemory, Status: machine2Status}, {Spec: cpuAndMemory},
}, },
}, },
{ {
@ -218,8 +222,8 @@ func TestLeastRequested(t *testing.T) {
expectedList: []HostPriority{{"machine1", 5}, {"machine2", 6}}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 6}},
test: "resources requested, pods scheduled with resources, differently sized machines", test: "resources requested, pods scheduled with resources, differently sized machines",
pods: []api.Pod{ pods: []api.Pod{
{Spec: cpuOnly, Status: machine1Status}, {Spec: cpuOnly},
{Spec: cpuAndMemory, Status: machine2Status}, {Spec: cpuAndMemory},
}, },
}, },
{ {
@ -239,8 +243,8 @@ func TestLeastRequested(t *testing.T) {
expectedList: []HostPriority{{"machine1", 5}, {"machine2", 2}}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 2}},
test: "requested resources exceed minion capacity", test: "requested resources exceed minion capacity",
pods: []api.Pod{ pods: []api.Pod{
{Spec: cpuOnly, Status: machine1Status}, {Spec: cpuOnly},
{Spec: cpuAndMemory, Status: machine2Status}, {Spec: cpuAndMemory},
}, },
}, },
{ {

View File

@ -65,10 +65,8 @@ func newPod(host string, hostPorts ...int) api.Pod {
networkPorts = append(networkPorts, api.ContainerPort{HostPort: port}) networkPorts = append(networkPorts, api.ContainerPort{HostPort: port})
} }
return api.Pod{ return api.Pod{
Status: api.PodStatus{
Host: host,
},
Spec: api.PodSpec{ Spec: api.PodSpec{
Host: host,
Containers: []api.Container{ Containers: []api.Container{
{ {
Ports: networkPorts, Ports: networkPorts,

View File

@ -63,10 +63,10 @@ func (s *ServiceSpread) CalculateSpreadPriority(pod api.Pod, podLister PodLister
counts := map[string]int{} counts := map[string]int{}
if len(nsServicePods) > 0 { if len(nsServicePods) > 0 {
for _, pod := range nsServicePods { for _, pod := range nsServicePods {
counts[pod.Status.Host]++ counts[pod.Spec.Host]++
// Compute the maximum number of pods hosted on any minion // Compute the maximum number of pods hosted on any minion
if counts[pod.Status.Host] > maxCount { if counts[pod.Spec.Host] > maxCount {
maxCount = counts[pod.Status.Host] maxCount = counts[pod.Spec.Host]
} }
} }
} }
@ -140,7 +140,7 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod api.Pod, podList
podCounts := map[string]int{} podCounts := map[string]int{}
for _, pod := range nsServicePods { for _, pod := range nsServicePods {
label, exists := labeledMinions[pod.Status.Host] label, exists := labeledMinions[pod.Spec.Host]
if !exists { if !exists {
continue continue
} }

View File

@ -33,10 +33,10 @@ func TestServiceSpreadPriority(t *testing.T) {
"bar": "foo", "bar": "foo",
"baz": "blah", "baz": "blah",
} }
zone1Status := api.PodStatus{ zone1Spec := api.PodSpec{
Host: "machine1", Host: "machine1",
} }
zone2Status := api.PodStatus{ zone2Spec := api.PodSpec{
Host: "machine2", Host: "machine2",
} }
tests := []struct { tests := []struct {
@ -54,14 +54,14 @@ func TestServiceSpreadPriority(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{{Status: zone1Status}}, pods: []api.Pod{{Spec: zone1Spec}},
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}},
test: "no services", test: "no services",
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, 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"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}},
expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}},
@ -70,8 +70,8 @@ func TestServiceSpreadPriority(t *testing.T) {
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}, ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}}}, 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"}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns2"}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns2"}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: []string{"machine1", "machine2"}, nodes: []string{"machine1", "machine2"},
services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"baz": "blah"}}}}, 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{ nozone := map[string]string{
"name": "value", "name": "value",
} }
zone0Status := api.PodStatus{ zone0Spec := api.PodSpec{
Host: "machine01", Host: "machine01",
} }
zone1Status := api.PodStatus{ zone1Spec := api.PodSpec{
Host: "machine11", Host: "machine11",
} }
zone2Status := api.PodStatus{ zone2Spec := api.PodSpec{
Host: "machine21", Host: "machine21",
} }
labeledNodes := map[string]map[string]string{ labeledNodes := map[string]map[string]string{
@ -219,7 +219,7 @@ func TestZoneSpreadPriority(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{{Status: zone1Status}}, pods: []api.Pod{{Spec: zone1Spec}},
nodes: labeledNodes, nodes: labeledNodes,
expectedList: []HostPriority{{"machine11", 10}, {"machine12", 10}, expectedList: []HostPriority{{"machine11", 10}, {"machine12", 10},
{"machine21", 10}, {"machine22", 10}, {"machine21", 10}, {"machine22", 10},
@ -228,7 +228,7 @@ func TestZoneSpreadPriority(t *testing.T) {
}, },
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, 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, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"key": "value"}}}},
expectedList: []HostPriority{{"machine11", 10}, {"machine12", 10}, expectedList: []HostPriority{{"machine11", 10}, {"machine12", 10},
@ -239,9 +239,9 @@ func TestZoneSpreadPriority(t *testing.T) {
{ {
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone0Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone0Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: labeledNodes, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: labeledNodes, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: api.NamespaceDefault}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1, Namespace: "ns1"}},
}, },
nodes: labeledNodes, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}, ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: labeledNodes, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels2}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels2}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: labeledNodes, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: map[string]string{"baz": "blah"}}}}, 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}}, pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
pods: []api.Pod{ pods: []api.Pod{
{Status: zone0Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone0Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone1Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone1Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
{Status: zone2Status, ObjectMeta: api.ObjectMeta{Labels: labels1}}, {Spec: zone2Spec, ObjectMeta: api.ObjectMeta{Labels: labels1}},
}, },
nodes: labeledNodes, nodes: labeledNodes,
services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}}, services: []api.Service{{Spec: api.ServiceSpec{Selector: labels1}}},

View File

@ -288,7 +288,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err) glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err)
return return
} }
if pod.Status.Host == "" { if pod.Spec.Host == "" {
podQueue.Add(pod) podQueue.Add(pod)
} }
}() }()

View File

@ -128,7 +128,6 @@ func (s *Scheduler) scheduleOne() {
// tell the model to assume that this binding took effect. // tell the model to assume that this binding took effect.
assumed := *pod assumed := *pod
assumed.Spec.Host = dest assumed.Spec.Host = dest
assumed.Status.Host = dest
s.config.Modeler.AssumePod(&assumed) s.config.Modeler.AssumePod(&assumed)
}) })
} }

View File

@ -40,9 +40,6 @@ func podWithID(id, desiredHost string) *api.Pod {
Spec: api.PodSpec{ Spec: api.PodSpec{
Host: desiredHost, Host: desiredHost,
}, },
Status: api.PodStatus{
Host: desiredHost,
},
} }
} }

View File

@ -150,7 +150,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) {
if p.Status.Phase == api.PodRunning { if p.Status.Phase == api.PodRunning {
current++ current++
} else if p.Status.Phase == api.PodPending { } else if p.Status.Phase == api.PodPending {
if p.Status.Host == "" { if p.Spec.Host == "" {
waiting++ waiting++
} else { } else {
pending++ pending++

View File

@ -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", 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 var logs []byte
start := time.Now() start := time.Now()
@ -346,7 +346,7 @@ func testContainerOutputInNamespace(ns, scenarioName string, c *client.Client, p
logs, err = c.Get(). logs, err = c.Get().
Prefix("proxy"). Prefix("proxy").
Resource("minions"). Resource("minions").
Name(podStatus.Status.Host). Name(podStatus.Spec.Host).
Suffix("containerLogs", ns, podStatus.Name, containerName). Suffix("containerLogs", ns, podStatus.Name, containerName).
Do(). Do().
Raw() Raw()
@ -354,7 +354,7 @@ func testContainerOutputInNamespace(ns, scenarioName string, c *client.Client, p
By(fmt.Sprintf("pod logs:%v\n", string(logs))) By(fmt.Sprintf("pod logs:%v\n", string(logs)))
if strings.Contains(string(logs), "Internal Error") { if strings.Contains(string(logs), "Internal Error") {
By(fmt.Sprintf("Failed to get logs from host %q pod %q container %q: %v", 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) time.Sleep(5 * time.Second)
continue continue
} }

View File

@ -127,7 +127,7 @@ func TestClient(t *testing.T) {
if actual.Name != got.Name { if actual.Name != got.Name {
t.Errorf("expected pod %#v, got %#v", got, actual) 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) t.Errorf("expected pod to be unscheduled, got %#v", actual)
} }
} }