mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
v1beta3 Pod refactor
This commit is contained in:
@@ -33,12 +33,10 @@ func TestMakeBoundPodNoServices(t *testing.T) {
|
||||
|
||||
pod, err := factory.MakeBoundPod("machine", &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -83,12 +81,11 @@ func TestMakeBoundPodServices(t *testing.T) {
|
||||
}
|
||||
|
||||
pod, err := factory.MakeBoundPod("machine", &api.Pod{
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foo",
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -161,15 +158,13 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
|
||||
}
|
||||
|
||||
pod, err := factory.MakeBoundPod("machine", &api.Pod{
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Env: []api.EnvVar{
|
||||
{
|
||||
Name: "foo",
|
||||
Value: "bar",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Env: []api.EnvVar{
|
||||
{
|
||||
Name: "foo",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -29,7 +29,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
|
||||
"github.com/golang/glog"
|
||||
@@ -92,17 +91,15 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
|
||||
if !api.ValidNamespace(ctx, &pod.ObjectMeta) {
|
||||
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
|
||||
}
|
||||
pod.DesiredState.Manifest.UUID = util.NewUUID().String()
|
||||
api.FillObjectMetaSystemFields(ctx, &pod.ObjectMeta)
|
||||
if len(pod.Name) == 0 {
|
||||
pod.Name = pod.DesiredState.Manifest.UUID
|
||||
// TODO properly handle auto-generated names.
|
||||
// See https://github.com/GoogleCloudPlatform/kubernetes/issues/148 170 & 1135
|
||||
pod.Name = pod.UID
|
||||
}
|
||||
pod.DesiredState.Manifest.ID = pod.Name
|
||||
if errs := validation.ValidatePod(pod); len(errs) > 0 {
|
||||
return nil, errors.NewInvalid("pod", pod.Name, errs)
|
||||
}
|
||||
|
||||
api.FillObjectMetaSystemFields(ctx, &pod.ObjectMeta)
|
||||
|
||||
return apiserver.MakeAsync(func() (runtime.Object, error) {
|
||||
if err := rs.registry.CreatePod(ctx, pod); err != nil {
|
||||
return nil, err
|
||||
@@ -131,19 +128,19 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
|
||||
if err != nil {
|
||||
return pod, err
|
||||
}
|
||||
pod.CurrentState.Status = status
|
||||
pod.Status.Condition = status
|
||||
}
|
||||
if pod.CurrentState.Host != "" {
|
||||
pod.CurrentState.HostIP = rs.getInstanceIP(pod.CurrentState.Host)
|
||||
if pod.Status.Host != "" {
|
||||
pod.Status.HostIP = rs.getInstanceIP(pod.Status.Host)
|
||||
}
|
||||
return pod, err
|
||||
}
|
||||
|
||||
func (rs *REST) podToSelectableFields(pod *api.Pod) labels.Set {
|
||||
return labels.Set{
|
||||
"name": pod.Name,
|
||||
"DesiredState.Status": string(pod.DesiredState.Status),
|
||||
"DesiredState.Host": pod.DesiredState.Host,
|
||||
"name": pod.Name,
|
||||
"Status.Condition": string(pod.Status.Condition),
|
||||
"Status.Host": pod.Status.Host,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +163,9 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
|
||||
if err != nil {
|
||||
return pod, err
|
||||
}
|
||||
pod.CurrentState.Status = status
|
||||
if pod.CurrentState.Host != "" {
|
||||
pod.CurrentState.HostIP = rs.getInstanceIP(pod.CurrentState.Host)
|
||||
pod.Status.Condition = status
|
||||
if pod.Status.Host != "" {
|
||||
pod.Status.HostIP = rs.getInstanceIP(pod.Status.Host)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,20 +198,19 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
|
||||
}
|
||||
|
||||
func (rs *REST) fillPodInfo(pod *api.Pod) {
|
||||
pod.CurrentState.Host = pod.DesiredState.Host
|
||||
if pod.CurrentState.Host == "" {
|
||||
if pod.Status.Host == "" {
|
||||
return
|
||||
}
|
||||
// Get cached info for the list currently.
|
||||
// TODO: Optionally use fresh info
|
||||
if rs.podCache != nil {
|
||||
info, err := rs.podCache.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
|
||||
info, err := rs.podCache.GetPodInfo(pod.Status.Host, pod.Namespace, pod.Name)
|
||||
if err != nil {
|
||||
if err != client.ErrPodInfoNotAvailable {
|
||||
glog.Errorf("Error getting container info from cache: %#v", err)
|
||||
}
|
||||
if rs.podInfoGetter != nil {
|
||||
info, err = rs.podInfoGetter.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
|
||||
info, err = rs.podInfoGetter.GetPodInfo(pod.Status.Host, pod.Namespace, pod.Name)
|
||||
}
|
||||
if err != nil {
|
||||
if err != client.ErrPodInfoNotAvailable {
|
||||
@@ -223,11 +219,11 @@ func (rs *REST) fillPodInfo(pod *api.Pod) {
|
||||
return
|
||||
}
|
||||
}
|
||||
pod.CurrentState.Info = info
|
||||
pod.Status.Info = info
|
||||
netContainerInfo, ok := info["net"]
|
||||
if ok {
|
||||
if netContainerInfo.PodIP != "" {
|
||||
pod.CurrentState.PodIP = netContainerInfo.PodIP
|
||||
pod.Status.PodIP = netContainerInfo.PodIP
|
||||
} else {
|
||||
glog.Warningf("No network settings: %#v", netContainerInfo)
|
||||
}
|
||||
@@ -269,7 +265,7 @@ func getInstanceIPFromCloud(cloud cloudprovider.Interface, host string) string {
|
||||
}
|
||||
|
||||
func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodCondition, error) {
|
||||
if pod.CurrentState.Host == "" {
|
||||
if pod.Status.Host == "" {
|
||||
return api.PodPending, nil
|
||||
}
|
||||
if minions != nil {
|
||||
@@ -280,7 +276,7 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodConditio
|
||||
}
|
||||
found := false
|
||||
for _, minion := range res.Items {
|
||||
if minion.Name == pod.CurrentState.Host {
|
||||
if minion.Name == pod.Status.Host {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -291,14 +287,14 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodConditio
|
||||
} else {
|
||||
glog.Errorf("Unexpected missing minion interface, status may be in-accurate")
|
||||
}
|
||||
if pod.CurrentState.Info == nil {
|
||||
if pod.Status.Info == nil {
|
||||
return api.PodPending, nil
|
||||
}
|
||||
running := 0
|
||||
stopped := 0
|
||||
unknown := 0
|
||||
for _, container := range pod.DesiredState.Manifest.Containers {
|
||||
if containerStatus, ok := pod.CurrentState.Info[container.Name]; ok {
|
||||
for _, container := range pod.Spec.Containers {
|
||||
if containerStatus, ok := pod.Status.Info[container.Name]; ok {
|
||||
if containerStatus.State.Running != nil {
|
||||
running++
|
||||
} else if containerStatus.State.Termination != nil {
|
||||
|
@@ -28,7 +28,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
||||
fake_cloud "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
@@ -62,12 +62,7 @@ func TestCreatePodRegistryError(t *testing.T) {
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
},
|
||||
}
|
||||
pod := &api.Pod{DesiredState: desiredState}
|
||||
pod := &api.Pod{}
|
||||
ctx := api.NewDefaultContext()
|
||||
ch, err := storage.Create(ctx, pod)
|
||||
if err != nil {
|
||||
@@ -82,12 +77,7 @@ func TestCreatePodSetsIds(t *testing.T) {
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
},
|
||||
}
|
||||
pod := &api.Pod{DesiredState: desiredState}
|
||||
pod := &api.Pod{}
|
||||
ctx := api.NewDefaultContext()
|
||||
ch, err := storage.Create(ctx, pod)
|
||||
if err != nil {
|
||||
@@ -98,23 +88,18 @@ func TestCreatePodSetsIds(t *testing.T) {
|
||||
if len(podRegistry.Pod.Name) == 0 {
|
||||
t.Errorf("Expected pod ID to be set, Got %#v", pod)
|
||||
}
|
||||
if podRegistry.Pod.DesiredState.Manifest.ID != podRegistry.Pod.Name {
|
||||
if pod.Name != podRegistry.Pod.Name {
|
||||
t.Errorf("Expected manifest ID to be equal to pod ID, Got %#v", pod)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePodSetsUUIDs(t *testing.T) {
|
||||
func TestCreatePodSetsUID(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Err = fmt.Errorf("test error")
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
},
|
||||
}
|
||||
pod := &api.Pod{DesiredState: desiredState}
|
||||
pod := &api.Pod{}
|
||||
ctx := api.NewDefaultContext()
|
||||
ch, err := storage.Create(ctx, pod)
|
||||
if err != nil {
|
||||
@@ -122,8 +107,8 @@ func TestCreatePodSetsUUIDs(t *testing.T) {
|
||||
}
|
||||
expectApiStatusError(t, ch, podRegistry.Err.Error())
|
||||
|
||||
if len(podRegistry.Pod.DesiredState.Manifest.UUID) == 0 {
|
||||
t.Errorf("Expected pod UUID to be set, Got %#v", pod)
|
||||
if len(podRegistry.Pod.UID) == 0 {
|
||||
t.Errorf("Expected pod UID to be set, Got %#v", pod)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,11 +201,11 @@ func TestListPodListSelection(t *testing.T) {
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}, {
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "barhost"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Status: api.PodStatus{Host: "barhost"},
|
||||
}, {
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
DesiredState: api.PodState{Status: "bazstatus"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
Status: api.PodStatus{Condition: "bazstatus"},
|
||||
}, {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "qux",
|
||||
@@ -251,16 +236,16 @@ func TestListPodListSelection(t *testing.T) {
|
||||
label: "label=qux",
|
||||
expectedIDs: util.NewStringSet("qux"),
|
||||
}, {
|
||||
field: "DesiredState.Status=bazstatus",
|
||||
field: "Status.Condition=bazstatus",
|
||||
expectedIDs: util.NewStringSet("baz"),
|
||||
}, {
|
||||
field: "DesiredState.Host=barhost",
|
||||
field: "Status.Host=barhost",
|
||||
expectedIDs: util.NewStringSet("bar"),
|
||||
}, {
|
||||
field: "DesiredState.Host=",
|
||||
field: "Status.Host=",
|
||||
expectedIDs: util.NewStringSet("foo", "baz", "qux", "zot"),
|
||||
}, {
|
||||
field: "DesiredState.Host!=",
|
||||
field: "Status.Host!=",
|
||||
expectedIDs: util.NewStringSet("bar"),
|
||||
},
|
||||
}
|
||||
@@ -342,7 +327,7 @@ func TestGetPod(t *testing.T) {
|
||||
func TestGetPodCloud(t *testing.T) {
|
||||
fakeCloud := &fake_cloud.FakeCloud{}
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
|
||||
podRegistry.Pod = &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}, Status: api.PodStatus{Host: "machine"}}
|
||||
|
||||
clock := &fakeClock{t: time.Now()}
|
||||
|
||||
@@ -393,16 +378,13 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
Containers: []api.Container{
|
||||
{Name: "containerA"},
|
||||
{Name: "containerB"},
|
||||
},
|
||||
desiredState := api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{Name: "containerA"},
|
||||
{Name: "containerB"},
|
||||
},
|
||||
}
|
||||
currentState := api.PodState{
|
||||
currentState := api.PodStatus{
|
||||
Host: "machine",
|
||||
}
|
||||
runningState := api.ContainerStatus{
|
||||
@@ -421,11 +403,11 @@ func TestMakePodStatus(t *testing.T) {
|
||||
status api.PodCondition
|
||||
test string
|
||||
}{
|
||||
{&api.Pod{DesiredState: desiredState, CurrentState: currentState}, api.PodPending, "waiting"},
|
||||
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Host: "machine-2",
|
||||
},
|
||||
},
|
||||
@@ -434,8 +416,8 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Info: map[string]api.ContainerStatus{
|
||||
"containerA": runningState,
|
||||
"containerB": runningState,
|
||||
@@ -448,8 +430,8 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Info: map[string]api.ContainerStatus{
|
||||
"containerA": runningState,
|
||||
"containerB": runningState,
|
||||
@@ -462,8 +444,8 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Info: map[string]api.ContainerStatus{
|
||||
"containerA": stoppedState,
|
||||
"containerB": stoppedState,
|
||||
@@ -476,8 +458,8 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Info: map[string]api.ContainerStatus{
|
||||
"containerA": stoppedState,
|
||||
"containerB": stoppedState,
|
||||
@@ -490,8 +472,8 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Info: map[string]api.ContainerStatus{
|
||||
"containerA": runningState,
|
||||
"containerB": stoppedState,
|
||||
@@ -504,8 +486,8 @@ func TestMakePodStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&api.Pod{
|
||||
DesiredState: desiredState,
|
||||
CurrentState: api.PodState{
|
||||
Spec: desiredState,
|
||||
Status: api.PodStatus{
|
||||
Info: map[string]api.ContainerStatus{
|
||||
"containerA": runningState,
|
||||
},
|
||||
@@ -533,7 +515,13 @@ func TestPodStorageValidatesCreate(t *testing.T) {
|
||||
registry: podRegistry,
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
pod := &api.Pod{}
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"invalid-label-to-cause-validation-failure": "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
c, err := storage.Create(ctx, pod)
|
||||
if c != nil {
|
||||
t.Errorf("Expected nil channel")
|
||||
@@ -543,28 +531,11 @@ func TestPodStorageValidatesCreate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPodStorageValidatesUpdate(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Err = fmt.Errorf("test error")
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
pod := &api.Pod{}
|
||||
c, err := storage.Update(ctx, pod)
|
||||
if c != nil {
|
||||
t.Errorf("Expected nil channel")
|
||||
}
|
||||
if !errors.IsInvalid(err) {
|
||||
t.Errorf("Expected to get an invalid resource error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePod(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
CurrentState: api.PodState{
|
||||
Status: api.PodStatus{
|
||||
Host: "machine",
|
||||
},
|
||||
}
|
||||
@@ -572,15 +543,8 @@ func TestCreatePod(t *testing.T) {
|
||||
registry: podRegistry,
|
||||
podPollPeriod: time.Millisecond * 100,
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
},
|
||||
}
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: desiredState,
|
||||
}
|
||||
pod := &api.Pod{}
|
||||
pod.Name = "foo"
|
||||
ctx := api.NewDefaultContext()
|
||||
channel, err := storage.Create(ctx, pod)
|
||||
if err != nil {
|
||||
@@ -625,13 +589,13 @@ func TestFillPodInfo(t *testing.T) {
|
||||
storage := REST{
|
||||
podCache: &fakeGetter,
|
||||
}
|
||||
pod := api.Pod{DesiredState: api.PodState{Host: "foo"}}
|
||||
pod := api.Pod{Status: api.PodStatus{Host: "foo"}}
|
||||
storage.fillPodInfo(&pod)
|
||||
if !reflect.DeepEqual(fakeGetter.info, pod.CurrentState.Info) {
|
||||
t.Errorf("Expected: %#v, Got %#v", fakeGetter.info, pod.CurrentState.Info)
|
||||
if !reflect.DeepEqual(fakeGetter.info, pod.Status.Info) {
|
||||
t.Errorf("Expected: %#v, Got %#v", fakeGetter.info, pod.Status.Info)
|
||||
}
|
||||
if pod.CurrentState.PodIP != expectedIP {
|
||||
t.Errorf("Expected %s, Got %s", expectedIP, pod.CurrentState.PodIP)
|
||||
if pod.Status.PodIP != expectedIP {
|
||||
t.Errorf("Expected %s, Got %s", expectedIP, pod.Status.PodIP)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,13 +611,13 @@ func TestFillPodInfoNoData(t *testing.T) {
|
||||
storage := REST{
|
||||
podCache: &fakeGetter,
|
||||
}
|
||||
pod := api.Pod{DesiredState: api.PodState{Host: "foo"}}
|
||||
pod := api.Pod{Status: api.PodStatus{Host: "foo"}}
|
||||
storage.fillPodInfo(&pod)
|
||||
if !reflect.DeepEqual(fakeGetter.info, pod.CurrentState.Info) {
|
||||
t.Errorf("Expected %#v, Got %#v", fakeGetter.info, pod.CurrentState.Info)
|
||||
if !reflect.DeepEqual(fakeGetter.info, pod.Status.Info) {
|
||||
t.Errorf("Expected %#v, Got %#v", fakeGetter.info, pod.Status.Info)
|
||||
}
|
||||
if pod.CurrentState.PodIP != expectedIP {
|
||||
t.Errorf("Expected %s, Got %s", expectedIP, pod.CurrentState.PodIP)
|
||||
if pod.Status.PodIP != expectedIP {
|
||||
t.Errorf("Expected %s, Got %s", expectedIP, pod.Status.PodIP)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user