@@ -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{
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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.")
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user