Merge pull request #2522 from markturansky/v1beta3_podphaserefactor

Refactor PodCondition to PodPhase
pull/6/head
bgrant0607 2014-11-21 13:49:50 -08:00
commit ec1d4f8a7c
16 changed files with 57 additions and 57 deletions

View File

@ -46,10 +46,10 @@ func waitForPodRunning(c *client.Client, id string) {
glog.Warningf("Get pod failed: %v", err)
continue
}
if pod.Status.Condition == api.PodRunning {
if pod.Status.Phase == api.PodRunning {
break
}
glog.Infof("Waiting for pod status to be running (%s)", pod.Status.Condition)
glog.Infof("Waiting for pod status to be running (%s)", pod.Status.Phase)
}
}

View File

@ -71,8 +71,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
j.FieldPath = c.RandString()
},
func(j *internal.PodCondition, c fuzz.Continue) {
statuses := []internal.PodCondition{internal.PodPending, internal.PodRunning, internal.PodFailed}
func(j *internal.PodPhase, c fuzz.Continue) {
statuses := []internal.PodPhase{internal.PodPending, internal.PodRunning, internal.PodFailed}
*j = statuses[c.Rand.Intn(len(statuses))]
},
func(j *internal.ReplicationControllerSpec, c fuzz.Continue) {

View File

@ -86,8 +86,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
j.SelfLink = c.RandString()
},
func(j *api.PodCondition, c fuzz.Continue) {
statuses := []api.PodCondition{api.PodPending, api.PodRunning, api.PodFailed}
func(j *api.PodPhase, c fuzz.Continue) {
statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed}
*j = statuses[c.Rand.Intn(len(statuses))]
},
func(j *api.ReplicationControllerSpec, c fuzz.Continue) {

View File

@ -337,24 +337,24 @@ type Lifecycle struct {
// The below types are used by kube_client and api_server.
// PodCondition is a label for the condition of a pod at the current time.
type PodCondition string
// PodPhase is a label for the condition of a pod at the current time.
type PodPhase string
// These are the valid statuses of pods.
const (
// PodPending means the pod has been accepted by the system, but one or more of the containers
// has not been started. This includes time before being bound to a node, as well as time spent
// pulling images onto the host.
PodPending PodCondition = "Pending"
PodPending PodPhase = "Pending"
// PodRunning means the pod has been bound to a node and all of the containers have been started.
// At least one container is still running or is in the process of being restarted.
PodRunning PodCondition = "Running"
PodRunning PodPhase = "Running"
// PodSucceeded means that all containers in the pod have voluntarily terminated
// with a container exit code of 0, and the system is not going to restart any of these containers.
PodSucceeded PodCondition = "Succeeded"
PodSucceeded PodPhase = "Succeeded"
// PodFailed means that all containers in the pod have terminated, and at least one container has
// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
PodFailed PodCondition = "Failed"
PodFailed PodPhase = "Failed"
)
type ContainerStateWaiting struct {
@ -422,7 +422,7 @@ type RestartPolicy struct {
// PodState is the state of a pod, used as either input (desired state) or output (current state).
type PodState struct {
Manifest ContainerManifest `json:"manifest,omitempty" yaml:"manifest,omitempty"`
Status PodCondition `json:"status,omitempty" yaml:"status,omitempty"`
Status PodPhase `json:"status,omitempty" yaml:"status,omitempty"`
// A human readable message indicating details about why the pod is in this state.
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
@ -458,7 +458,7 @@ type PodSpec struct {
// PodStatus represents information about the status of a pod. Status may trail the actual
// state of a system.
type PodStatus struct {
Condition PodCondition `json:"condition,omitempty" yaml:"condition,omitempty"`
Phase PodPhase `json:"phase,omitempty" yaml:"phase,omitempty"`
// Host is the name of the node that this Pod is currently bound to, or empty if no
// assignment has been done.

View File

@ -161,7 +161,7 @@ func init() {
},
func(in *newer.PodStatus, out *PodState, s conversion.Scope) error {
if err := s.Convert(&in.Condition, &out.Status, 0); err != nil {
if err := s.Convert(&in.Phase, &out.Status, 0); err != nil {
return err
}
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
@ -173,7 +173,7 @@ func init() {
return nil
},
func(in *PodState, out *newer.PodStatus, s conversion.Scope) error {
if err := s.Convert(&in.Status, &out.Condition, 0); err != nil {
if err := s.Convert(&in.Status, &out.Phase, 0); err != nil {
return err
}
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
@ -186,8 +186,8 @@ func init() {
return nil
},
// Convert all to the new PodCondition constants
func(in *newer.PodCondition, out *PodStatus, s conversion.Scope) error {
// Convert all to the new PodPhase constants
func(in *newer.PodPhase, out *PodStatus, s conversion.Scope) error {
switch *in {
case "":
*out = ""
@ -200,13 +200,13 @@ func init() {
case newer.PodFailed:
*out = PodTerminated
default:
return errors.New("The string provided is not a valid PodCondition constant value")
return errors.New("The string provided is not a valid PodPhase constant value")
}
return nil
},
func(in *PodStatus, out *newer.PodCondition, s conversion.Scope) error {
func(in *PodStatus, out *newer.PodPhase, s conversion.Scope) error {
switch *in {
case "":
*out = ""
@ -218,7 +218,7 @@ func init() {
// Older API versions did not contain enough info to map to PodSucceeded
*out = newer.PodFailed
default:
return errors.New("The string provided is not a valid PodCondition constant value")
return errors.New("The string provided is not a valid PodPhase constant value")
}
return nil
},

View File

@ -90,8 +90,8 @@ func init() {
return s.Convert(&in.Annotations, &out.Annotations, 0)
},
// Convert all to the new PodCondition constants
func(in *newer.PodCondition, out *PodStatus, s conversion.Scope) error {
// Convert all to the new PodPhase constants
func(in *newer.PodPhase, out *PodStatus, s conversion.Scope) error {
switch *in {
case "":
*out = ""
@ -104,13 +104,13 @@ func init() {
case newer.PodFailed:
*out = PodTerminated
default:
return errors.New("The string provided is not a valid PodCondition constant value")
return errors.New("The string provided is not a valid PodPhase constant value")
}
return nil
},
func(in *PodStatus, out *newer.PodCondition, s conversion.Scope) error {
func(in *PodStatus, out *newer.PodPhase, s conversion.Scope) error {
switch *in {
case "":
*out = ""
@ -122,7 +122,7 @@ func init() {
// Older API versions did not contain enough info to map to PodSucceeded
*out = newer.PodFailed
default:
return errors.New("The string provided is not a valid PodCondition constant value")
return errors.New("The string provided is not a valid PodPhase constant value")
}
return nil
},
@ -279,7 +279,7 @@ func init() {
},
func(in *newer.PodStatus, out *PodState, s conversion.Scope) error {
if err := s.Convert(&in.Condition, &out.Status, 0); err != nil {
if err := s.Convert(&in.Phase, &out.Status, 0); err != nil {
return err
}
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
@ -291,7 +291,7 @@ func init() {
return nil
},
func(in *PodState, out *newer.PodStatus, s conversion.Scope) error {
if err := s.Convert(&in.Status, &out.Condition, 0); err != nil {
if err := s.Convert(&in.Status, &out.Phase, 0); err != nil {
return err
}
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {

View File

@ -366,24 +366,24 @@ type Lifecycle struct {
PreStop *Handler `json:"preStop,omitempty" yaml:"preStop,omitempty"`
}
// PodCondition is a label for the condition of a pod at the current time.
type PodCondition string
// PodPhase is a label for the condition of a pod at the current time.
type PodPhase string
// These are the valid states of pods.
const (
// PodPending means the pod has been accepted by the system, but one or more of the containers
// has not been started. This includes time before being bound to a node, as well as time spent
// pulling images onto the host.
PodPending PodCondition = "Pending"
PodPending PodPhase = "Pending"
// PodRunning means the pod has been bound to a node and all of the containers have been started.
// At least one container is still running or is in the process of being restarted.
PodRunning PodCondition = "Running"
PodRunning PodPhase = "Running"
// PodSucceeded means that all containers in the pod have voluntarily terminated
// with a container exit code of 0, and the system is not going to restart any of these containers.
PodSucceeded PodCondition = "Succeeded"
PodSucceeded PodPhase = "Succeeded"
// PodFailed means that all containers in the pod have terminated, and at least one container has
// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
PodFailed PodCondition = "Failed"
PodFailed PodPhase = "Failed"
)
type ContainerStateWaiting struct {
@ -456,7 +456,7 @@ type PodSpec struct {
// PodStatus represents information about the status of a pod. Status may trail the actual
// state of a system.
type PodStatus struct {
Condition PodCondition `json:"condition,omitempty" yaml:"condition,omitempty"`
Phase PodPhase `json:"phase,omitempty" yaml:"phase,omitempty"`
// A human readable message indicating details about why the pod is in this state.
Message string `json:"message,omitempty" yaml:"message,omitempty"`

View File

@ -88,8 +88,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
j.SelfLink = c.RandString()
},
func(j *api.PodCondition, c fuzz.Continue) {
statuses := []api.PodCondition{api.PodPending, api.PodRunning, api.PodFailed}
func(j *api.PodPhase, c fuzz.Continue) {
statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed}
*j = statuses[c.Rand.Intn(len(statuses))]
},
func(j *api.ReplicationControllerSpec, c fuzz.Continue) {

View File

@ -173,7 +173,7 @@ func TestListPods(t *testing.T) {
Items: []api.Pod{
{
Status: api.PodStatus{
Condition: api.PodRunning,
Phase: api.PodRunning,
},
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
@ -206,7 +206,7 @@ func TestListPodsLabels(t *testing.T) {
Items: []api.Pod{
{
Status: api.PodStatus{
Condition: api.PodRunning,
Phase: api.PodRunning,
},
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
@ -234,7 +234,7 @@ func TestGetPod(t *testing.T) {
StatusCode: 200,
Body: &api.Pod{
Status: api.PodStatus{
Condition: api.PodRunning,
Phase: api.PodRunning,
},
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
@ -261,7 +261,7 @@ func TestDeletePod(t *testing.T) {
func TestCreatePod(t *testing.T) {
requestPod := &api.Pod{
Status: api.PodStatus{
Condition: api.PodRunning,
Phase: api.PodRunning,
},
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
@ -292,7 +292,7 @@ func TestUpdatePod(t *testing.T) {
},
},
Status: api.PodStatus{
Condition: api.PodRunning,
Phase: api.PodRunning,
},
}
c := &testClient{

View File

@ -143,8 +143,8 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
func (rm *ReplicationManager) filterActivePods(pods []api.Pod) []api.Pod {
var result []api.Pod
for _, value := range pods {
if api.PodSucceeded != value.Status.Condition &&
api.PodFailed != value.Status.Condition {
if api.PodSucceeded != value.Status.Phase &&
api.PodFailed != value.Status.Phase {
result = append(result, value)
}
}

View File

@ -204,7 +204,7 @@ func printPod(pod *api.Pod, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
pod.Name, makeImageList(pod.Spec),
podHostString(pod.Status.Host, pod.Status.HostIP),
labels.Set(pod.Labels), pod.Status.Condition)
labels.Set(pod.Labels), pod.Status.Phase)
return err
}

View File

@ -93,7 +93,7 @@ func (d *PodDescriber) Describe(namespace, name string) (string, error) {
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(spec))
fmt.Fprintf(out, "Host:\t%s\n", pod.Status.Host+"/"+pod.Status.HostIP)
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels))
fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Condition))
fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase))
fmt.Fprintf(out, "Replication Controllers:\t%s\n", getReplicationControllersForLabels(rc, labels.Set(pod.Labels)))
if events != nil {
describeEvents(events, out)
@ -247,7 +247,7 @@ func getPodStatusForReplicationController(c client.PodInterface, controller *api
return
}
for _, pod := range rcPods.Items {
switch pod.Status.Condition {
switch pod.Status.Phase {
case api.PodRunning:
running++
case api.PodPending:

View File

@ -243,7 +243,7 @@ func printPod(pod *api.Pod, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
pod.Name, firstImage,
podHostString(pod.Status.Host, pod.Status.HostIP),
labels.Set(pod.Labels), pod.Status.Condition)
labels.Set(pod.Labels), pod.Status.Phase)
if err != nil {
return err
}

View File

@ -159,7 +159,7 @@ func makeContainerKey(machine string) string {
// CreatePod creates a pod based on a specification.
func (r *Registry) CreatePod(ctx api.Context, pod *api.Pod) error {
// Set current status to "Waiting".
pod.Status.Condition = api.PodPending
pod.Status.Phase = api.PodPending
pod.Status.Host = ""
key, err := makePodKey(ctx, pod.Name)
if err != nil {

View File

@ -129,7 +129,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
if err != nil {
return pod, err
}
pod.Status.Condition = status
pod.Status.Phase = status
}
if pod.Status.Host != "" {
pod.Status.HostIP = rs.getInstanceIP(pod.Status.Host)
@ -143,11 +143,11 @@ func (rs *REST) podToSelectableFields(pod *api.Pod) labels.Set {
// see https://github.com/GoogleCloudPlatform/kubernetes/pull/2503
var olderPodStatus v1beta1.PodStatus
api.Scheme.Convert(pod.Status.Condition, &olderPodStatus)
api.Scheme.Convert(pod.Status.Phase, &olderPodStatus)
return labels.Set{
"name": pod.Name,
"Status.Condition": string(pod.Status.Condition),
"Status.Phase": string(pod.Status.Phase),
"Status.Host": pod.Status.Host,
"DesiredState.Status": string(olderPodStatus),
"DesiredState.Host": pod.Status.Host,
@ -173,7 +173,7 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
if err != nil {
return pod, err
}
pod.Status.Condition = status
pod.Status.Phase = status
if pod.Status.Host != "" {
pod.Status.HostIP = rs.getInstanceIP(pod.Status.Host)
}
@ -274,7 +274,7 @@ func getInstanceIPFromCloud(cloud cloudprovider.Interface, host string) string {
return addr.String()
}
func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodCondition, error) {
func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodPhase, error) {
if pod.Status.Host == "" {
return api.PodPending, nil
}

View File

@ -205,7 +205,7 @@ func TestListPodListSelection(t *testing.T) {
Status: api.PodStatus{Host: "barhost"},
}, {
ObjectMeta: api.ObjectMeta{Name: "baz"},
Status: api.PodStatus{Condition: "bazstatus"},
Status: api.PodStatus{Phase: "bazstatus"},
}, {
ObjectMeta: api.ObjectMeta{
Name: "qux",
@ -236,7 +236,7 @@ func TestListPodListSelection(t *testing.T) {
label: "label=qux",
expectedIDs: util.NewStringSet("qux"),
}, {
field: "Status.Condition=bazstatus",
field: "Status.Phase=bazstatus",
expectedIDs: util.NewStringSet("baz"),
}, {
field: "Status.Host=barhost",
@ -400,7 +400,7 @@ func TestMakePodStatus(t *testing.T) {
tests := []struct {
pod *api.Pod
status api.PodCondition
status api.PodPhase
test string
}{
{&api.Pod{Spec: desiredState, Status: currentState}, api.PodPending, "waiting"},