Skip to content

Commit

Permalink
Removed PodStatus.Host
Browse files Browse the repository at this point in the history
Fixes #6165
  • Loading branch information
piosz committed Apr 2, 2015
1 parent 860257e commit 5c6439d
Show file tree
Hide file tree
Showing 31 changed files with 149 additions and 199 deletions.
2 changes: 1 addition & 1 deletion cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc {
podInfo := fakeKubeletClient{}
return func() (bool, error) {
for i := range pods.Items {
host, id, namespace := pods.Items[i].Status.Host, pods.Items[i].Name, pods.Items[i].Namespace
host, id, namespace := pods.Items[i].Spec.Host, pods.Items[i].Name, pods.Items[i].Namespace
glog.Infof("Check whether pod %s.%s exists on node %q", id, namespace, host)
if len(host) == 0 {
glog.Infof("Pod %s.%s is not bound to a host yet", id, namespace)
Expand Down
3 changes: 0 additions & 3 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,6 @@ type PodStatus struct {
// A human readable message indicating details about why the pod is in this state.
Message string `json:"message,omitempty"`

// Host is the name of the node that this Pod is currently bound to, or empty if no
// assignment has been done.
Host string `json:"host,omitempty"`
HostIP string `json:"hostIP,omitempty"`
PodIP string `json:"podIP,omitempty"`

Expand Down
3 changes: 1 addition & 2 deletions pkg/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func init() {
return err
}
out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP
out.PodIP = in.PodIP
return nil
Expand All @@ -209,7 +208,6 @@ func init() {
}

out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP
out.PodIP = in.PodIP
return nil
Expand Down Expand Up @@ -368,6 +366,7 @@ func init() {
return err
}
out.DesiredState.Host = in.Spec.Host
out.CurrentState.Host = in.Spec.Host
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/v1beta2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func init() {
return err
}
out.DesiredState.Host = in.Spec.Host
out.CurrentState.Host = in.Spec.Host
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
return err
}
Expand Down Expand Up @@ -496,7 +497,6 @@ func init() {
return err
}
out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP
out.PodIP = in.PodIP
return nil
Expand All @@ -512,7 +512,6 @@ func init() {
return err
}
out.Message = in.Message
out.Host = in.Host
out.HostIP = in.HostIP
out.PodIP = in.PodIP
return nil
Expand Down
3 changes: 0 additions & 3 deletions pkg/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,6 @@ type PodStatus struct {
// A human readable message indicating details about why the pod is in this state.
Message string `json:"message,omitempty" description:"human readable message indicating details about why the pod is in this condition"`

// Host is the name of the node that this Pod is currently bound to, or empty if no
// assignment has been done.
Host string `json:"host,omitempty" description:"host to which the pod is assigned; empty if not yet scheduled; cannot be updated"`
HostIP string `json:"hostIP,omitempty" description:"IP address of the host to which the pod is assigned; empty if not yet scheduled"`
PodIP string `json:"podIP,omitempty" description:"IP address allocated to the pod; routable at least within the cluster; empty if not yet allocated"`

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)

// TODO: allow change when bindings are properly decoupled from pods
if newPod.Status.Host != oldPod.Status.Host {
allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Status.Host, "pod host cannot be changed directly"))
if newPod.Spec.Host != oldPod.Spec.Host {
allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Spec.Host, "pod host cannot be changed directly"))
}

// For status update we ignore changes to pod spec.
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/controller/nodecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func (nc *NodeController) deletePods(nodeID string) error {
return err
}
for _, pod := range pods.Items {
if pod.Status.Host != nodeID {
if pod.Spec.Host != nodeID {
continue
}
glog.V(2).Infof("Delete pod %v", pod.Name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/controller/nodecontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ func newNode(name string) *api.Node {
}

func newPod(name, host string) *api.Pod {
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name}, Status: api.PodStatus{Host: host}}
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name}, Spec: api.PodSpec{Host: host}}
}

func sortedNodeNames(nodes []*api.Node) []string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func RunExec(f *Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.C
req := client.RESTClient.Get().
Prefix("proxy").
Resource("minions").
Name(pod.Status.Host).
Name(pod.Spec.Host).
Suffix("exec", namespace, podName, containerName)

e := remotecommand.New(req, config, args, stdin, cmdOut, cmdErr, tty)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func RunLog(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error
readCloser, err := client.RESTClient.Get().
Prefix("proxy").
Resource("minions").
Name(pod.Status.Host).
Name(pod.Spec.Host).
Suffix("containerLogs", namespace, podID, container).
Param("follow", strconv.FormatBool(follow)).
Stream()
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/cmd/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func RunPortForward(f *Factory, cmd *cobra.Command, args []string) error {
req := client.RESTClient.Get().
Prefix("proxy").
Resource("minions").
Name(pod.Status.Host).
Name(pod.Spec.Host).
Suffix("portForward", namespace, podName)

pf, err := portforward.New(req, config, args, stopCh)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", pod.Name)
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&pod.Spec))
fmt.Fprintf(out, "Host:\t%s\n", pod.Status.Host+"/"+pod.Status.HostIP)
fmt.Fprintf(out, "Host:\t%s\n", pod.Spec.Host+"/"+pod.Status.HostIP)
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels))
fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase))
fmt.Fprintf(out, "Replication Controllers:\t%s\n", printReplicationControllersByLabels(rcs))
Expand Down Expand Up @@ -369,7 +369,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
return "", err
}
for _, pod := range allPods.Items {
if pod.Status.Host != name {
if pod.Spec.Host != name {
continue
}
pods = append(pods, pod)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/resource_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func printPod(pod *api.Pod, w io.Writer) error {
pod.Status.PodIP,
firstContainer.Name,
firstContainer.Image,
podHostString(pod.Status.Host, pod.Status.HostIP),
podHostString(pod.Spec.Host, pod.Status.HostIP),
formatLabels(pod.Labels),
pod.Status.Phase,
units.HumanDuration(time.Now().Sub(pod.CreationTimestamp.Time)))
Expand Down
2 changes: 0 additions & 2 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,6 @@ func (kl *Kubelet) generatePodStatusByPod(pod *api.Pod) (api.PodStatus, error) {
} else {
pendingStatus := api.PodStatus{
Phase: api.PodPending,
Host: kl.GetHostname(),
Message: fmt.Sprintf("Query docker container info failed with error (%v)", err),
}
return pendingStatus, nil
Expand All @@ -1979,7 +1978,6 @@ func (kl *Kubelet) generatePodStatusByPod(pod *api.Pod) (api.PodStatus, error) {
}
}
podStatus.Conditions = append(podStatus.Conditions, getPodReadyCondition(spec, podStatus.ContainerStatuses)...)
podStatus.Host = kl.GetHostname()
hostIP, err := kl.GetHostIP()
if err != nil {
glog.Errorf("Cannot get host IP: %v", err)
Expand Down
32 changes: 6 additions & 26 deletions pkg/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2169,22 +2169,20 @@ func failedState(cName string) api.ContainerStatus {

func TestPodPhaseWithRestartAlways(t *testing.T) {
desiredState := api.PodSpec{
Host: "machine",
Containers: []api.Container{
{Name: "containerA"},
{Name: "containerB"},
},
RestartPolicy: api.RestartPolicyAlways,
}
currentState := api.PodStatus{
Host: "machine",
}

tests := []struct {
pod *api.Pod
status api.PodPhase
test string
}{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"},
{&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"},
{
&api.Pod{
Spec: desiredState,
Expand All @@ -2193,7 +2191,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
runningState("containerA"),
runningState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2207,7 +2204,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
stoppedState("containerA"),
stoppedState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2221,7 +2217,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
runningState("containerA"),
stoppedState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2234,7 +2229,6 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
ContainerStatuses: []api.ContainerStatus{
runningState("containerA"),
},
Host: "machine",
},
},
api.PodPending,
Expand All @@ -2250,22 +2244,20 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {

func TestPodPhaseWithRestartNever(t *testing.T) {
desiredState := api.PodSpec{
Host: "machine",
Containers: []api.Container{
{Name: "containerA"},
{Name: "containerB"},
},
RestartPolicy: api.RestartPolicyNever,
}
currentState := api.PodStatus{
Host: "machine",
}

tests := []struct {
pod *api.Pod
status api.PodPhase
test string
}{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"},
{&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"},
{
&api.Pod{
Spec: desiredState,
Expand All @@ -2274,7 +2266,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
runningState("containerA"),
runningState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2288,7 +2279,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
succeededState("containerA"),
succeededState("containerB"),
},
Host: "machine",
},
},
api.PodSucceeded,
Expand All @@ -2302,7 +2292,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
failedState("containerA"),
failedState("containerB"),
},
Host: "machine",
},
},
api.PodFailed,
Expand All @@ -2316,7 +2305,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
runningState("containerA"),
succeededState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2329,7 +2317,6 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
ContainerStatuses: []api.ContainerStatus{
runningState("containerA"),
},
Host: "machine",
},
},
api.PodPending,
Expand All @@ -2345,22 +2332,20 @@ func TestPodPhaseWithRestartNever(t *testing.T) {

func TestPodPhaseWithRestartOnFailure(t *testing.T) {
desiredState := api.PodSpec{
Host: "machine",
Containers: []api.Container{
{Name: "containerA"},
{Name: "containerB"},
},
RestartPolicy: api.RestartPolicyOnFailure,
}
currentState := api.PodStatus{
Host: "machine",
}

tests := []struct {
pod *api.Pod
status api.PodPhase
test string
}{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"},
{&api.Pod{Spec: desiredState, Status: api.PodStatus{}}, api.PodPending, "waiting"},
{
&api.Pod{
Spec: desiredState,
Expand All @@ -2369,7 +2354,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
runningState("containerA"),
runningState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2383,7 +2367,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
succeededState("containerA"),
succeededState("containerB"),
},
Host: "machine",
},
},
api.PodSucceeded,
Expand All @@ -2397,7 +2380,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
failedState("containerA"),
failedState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2411,7 +2393,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
runningState("containerA"),
succeededState("containerB"),
},
Host: "machine",
},
},
api.PodRunning,
Expand All @@ -2424,7 +2405,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
ContainerStatuses: []api.ContainerStatus{
runningState("containerA"),
},
Host: "machine",
},
},
api.PodPending,
Expand Down
Loading

0 comments on commit 5c6439d

Please sign in to comment.