mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
update PodSpec.Host to PodSpec.NodeName in /pkg/api/types.go and /pkg/api/v1beta3/types.go
This commit is contained in:
@@ -147,10 +147,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 {
|
||||
return nil, 0, fmt.Errorf("pod %v is already assigned to host %q", pod.Name, pod.Spec.Host)
|
||||
if pod.Spec.NodeName != oldMachine {
|
||||
return nil, 0, fmt.Errorf("pod %v is already assigned to node %q", pod.Name, pod.Spec.NodeName)
|
||||
}
|
||||
pod.Spec.Host = machine
|
||||
pod.Spec.NodeName = machine
|
||||
if pod.Annotations == nil {
|
||||
pod.Annotations = make(map[string]string)
|
||||
}
|
||||
|
@@ -231,14 +231,14 @@ func TestListPodList(t *testing.T) {
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
Status: api.PodStatus{Phase: api.PodRunning},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -255,10 +255,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].Spec.Host != "machine" {
|
||||
if pods.Items[0].Name != "foo" || pods.Items[0].Status.Phase != api.PodRunning || pods.Items[0].Spec.NodeName != "machine" {
|
||||
t.Errorf("Unexpected pod: %#v", pods.Items[0])
|
||||
}
|
||||
if pods.Items[1].Name != "bar" || pods.Items[1].Spec.Host != "machine" {
|
||||
if pods.Items[1].Name != "bar" || pods.Items[1].Spec.NodeName != "machine" {
|
||||
t.Errorf("Unexpected pod: %#v", pods.Items[1])
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ func TestListPodListSelection(t *testing.T) {
|
||||
})},
|
||||
{Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Spec: api.PodSpec{Host: "barhost"},
|
||||
Spec: api.PodSpec{NodeName: "barhost"},
|
||||
})},
|
||||
{Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
@@ -388,7 +388,7 @@ func TestPodDecode(t *testing.T) {
|
||||
func TestGet(t *testing.T) {
|
||||
expect := validNewPod()
|
||||
expect.Status.Phase = api.PodRunning
|
||||
expect.Spec.Host = "machine"
|
||||
expect.Spec.NodeName = "machine"
|
||||
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
key := etcdtest.AddPrefix("/pods/test/foo")
|
||||
@@ -485,7 +485,7 @@ func TestUpdateWithConflictingNamespace(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}),
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
@@ -645,7 +645,7 @@ func TestDeletePod(t *testing.T) {
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}),
|
||||
ModifiedIndex: 1,
|
||||
CreatedIndex: 1,
|
||||
@@ -1035,8 +1035,8 @@ func TestEtcdCreateBinding(t *testing.T) {
|
||||
pod, err := registry.Get(ctx, validNewPod().ObjectMeta.Name)
|
||||
if err != nil {
|
||||
t.Errorf("%s: unexpected error: %v", k, err)
|
||||
} else if pod.(*api.Pod).Spec.Host != test.binding.Target.Name {
|
||||
t.Errorf("%s: expected: %v, got: %v", k, pod.(*api.Pod).Spec.Host, test.binding.Target.Name)
|
||||
} else if pod.(*api.Pod).Spec.NodeName != test.binding.Target.Name {
|
||||
t.Errorf("%s: expected: %v, got: %v", k, pod.(*api.Pod).Spec.NodeName, test.binding.Target.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1107,7 +1107,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Host: "machine",
|
||||
NodeName: "machine",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foobar",
|
||||
@@ -1127,7 +1127,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Host: "machine",
|
||||
NodeName: "machine",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foobar",
|
||||
@@ -1170,7 +1170,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Host: "machine",
|
||||
NodeName: "machine",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Image: "foo:v1",
|
||||
@@ -1190,7 +1190,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Host: "machine",
|
||||
NodeName: "machine",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Image: "foo:v2",
|
||||
@@ -1238,7 +1238,7 @@ func TestEtcdDeletePod(t *testing.T) {
|
||||
key = etcdtest.AddPrefix(key)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}), 0)
|
||||
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
|
||||
if err != nil {
|
||||
@@ -1260,7 +1260,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
||||
key = etcdtest.AddPrefix(key)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}), 0)
|
||||
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
|
||||
if err != nil {
|
||||
@@ -1330,13 +1330,13 @@ func TestEtcdList(t *testing.T) {
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Spec: api.PodSpec{Host: "machine"},
|
||||
Spec: api.PodSpec{NodeName: "machine"},
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -1353,8 +1353,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].Spec.Host != "machine" ||
|
||||
pods.Items[1].Spec.Host != "machine" {
|
||||
if pods.Items[0].Spec.NodeName != "machine" ||
|
||||
pods.Items[1].Spec.NodeName != "machine" {
|
||||
t.Errorf("Failed to populate host name.")
|
||||
}
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
func PodToSelectableFields(pod *api.Pod) fields.Set {
|
||||
return fields.Set{
|
||||
"metadata.name": pod.Name,
|
||||
"spec.host": pod.Spec.Host,
|
||||
"spec.host": pod.Spec.NodeName,
|
||||
"status.phase": string(pod.Status.Phase),
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ func LogLocation(getter ResourceGetter, connInfo client.ConnectionInfoGetter, ct
|
||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("a container name must be specified for pod %s", name))
|
||||
}
|
||||
}
|
||||
nodeHost := pod.Spec.Host
|
||||
nodeHost := pod.Spec.NodeName
|
||||
if len(nodeHost) == 0 {
|
||||
// If pod has not been assigned a host, return an empty location
|
||||
return nil, nil, nil
|
||||
@@ -242,7 +242,7 @@ func ExecLocation(getter ResourceGetter, connInfo client.ConnectionInfoGetter, c
|
||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("a container name must be specified for pod %s", name))
|
||||
}
|
||||
}
|
||||
nodeHost := pod.Spec.Host
|
||||
nodeHost := pod.Spec.NodeName
|
||||
if len(nodeHost) == 0 {
|
||||
// If pod has not been assigned a host, return an empty location
|
||||
return nil, nil, fmt.Errorf("pod %s does not have a host assigned", name)
|
||||
@@ -284,7 +284,7 @@ func PortForwardLocation(getter ResourceGetter, connInfo client.ConnectionInfoGe
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
nodeHost := pod.Spec.Host
|
||||
nodeHost := pod.Spec.NodeName
|
||||
if len(nodeHost) == 0 {
|
||||
// If pod has not been assigned a host, return an empty location
|
||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("pod %s does not have a host assigned", name))
|
||||
|
Reference in New Issue
Block a user