mirror of https://github.com/k3s-io/k3s
Merge pull request #4767 from mikedanese/kind-to-type
Rename {Node,Pod}ConditionKind -> {Node,Pod}ConditionTypepull/6/head
commit
590a62ffe5
|
@ -472,18 +472,18 @@ const (
|
|||
PodUnknown PodPhase = "Unknown"
|
||||
)
|
||||
|
||||
type PodConditionKind string
|
||||
type PodConditionType string
|
||||
|
||||
// These are valid conditions of pod.
|
||||
const (
|
||||
// PodReady means the pod is able to service requests and should be added to the
|
||||
// load balancing pools of all matching services.
|
||||
PodReady PodConditionKind = "Ready"
|
||||
PodReady PodConditionType = "Ready"
|
||||
)
|
||||
|
||||
// TODO: add LastTransitionTime, Reason, Message to match NodeCondition api.
|
||||
type PodCondition struct {
|
||||
Kind PodConditionKind `json:"kind"`
|
||||
Type PodConditionType `json:"type"`
|
||||
Status ConditionStatus `json:"status"`
|
||||
}
|
||||
|
||||
|
@ -805,20 +805,20 @@ const (
|
|||
NodeTerminated NodePhase = "Terminated"
|
||||
)
|
||||
|
||||
type NodeConditionKind string
|
||||
type NodeConditionType string
|
||||
|
||||
// These are valid conditions of node. Currently, we don't have enough information to decide
|
||||
// node condition. In the future, we will add more. The proposed set of conditions are:
|
||||
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
|
||||
const (
|
||||
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
|
||||
NodeReachable NodeConditionKind = "Reachable"
|
||||
NodeReachable NodeConditionType = "Reachable"
|
||||
// NodeReady means the node returns StatusOK for HTTP health check.
|
||||
NodeReady NodeConditionKind = "Ready"
|
||||
NodeReady NodeConditionType = "Ready"
|
||||
)
|
||||
|
||||
type NodeCondition struct {
|
||||
Kind NodeConditionKind `json:"kind"`
|
||||
Type NodeConditionType `json:"type"`
|
||||
Status ConditionStatus `json:"status"`
|
||||
LastProbeTime util.Time `json:"lastProbeTime,omitempty"`
|
||||
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
|
||||
|
|
|
@ -1158,6 +1158,132 @@ func init() {
|
|||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.NodeCondition, out *NodeCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *NodeCondition, out *newer.NodeCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.NodeConditionType, out *NodeConditionKind, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case newer.NodeReachable:
|
||||
*out = NodeReachable
|
||||
break
|
||||
case newer.NodeReady:
|
||||
*out = NodeReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = NodeConditionKind(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *NodeConditionKind, out *newer.NodeConditionType, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case NodeReachable:
|
||||
*out = newer.NodeReachable
|
||||
break
|
||||
case NodeReady:
|
||||
*out = newer.NodeReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = newer.NodeConditionType(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.PodCondition, out *PodCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *PodCondition, out *newer.PodCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.PodConditionType, out *PodConditionKind, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case newer.PodReady:
|
||||
*out = PodReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = PodConditionKind(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *PodConditionKind, out *newer.PodConditionType, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case PodReady:
|
||||
*out = newer.PodReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = newer.PodConditionType(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
|
|
|
@ -1073,6 +1073,132 @@ func init() {
|
|||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.NodeCondition, out *NodeCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *NodeCondition, out *newer.NodeCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastProbeTime, &out.LastProbeTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.LastTransitionTime, &out.LastTransitionTime, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Reason, &out.Reason, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Message, &out.Message, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.NodeConditionType, out *NodeConditionKind, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case newer.NodeReachable:
|
||||
*out = NodeReachable
|
||||
break
|
||||
case newer.NodeReady:
|
||||
*out = NodeReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = NodeConditionKind(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *NodeConditionKind, out *newer.NodeConditionType, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case NodeReachable:
|
||||
*out = newer.NodeReachable
|
||||
break
|
||||
case NodeReady:
|
||||
*out = newer.NodeReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = newer.NodeConditionType(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.PodCondition, out *PodCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Type, &out.Kind, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *PodCondition, out *newer.PodCondition, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.Kind, &out.Type, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Status, &out.Status, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.PodConditionType, out *PodConditionKind, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case newer.PodReady:
|
||||
*out = PodReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = PodConditionKind(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *PodConditionKind, out *newer.PodConditionType, s conversion.Scope) error {
|
||||
switch *in {
|
||||
case PodReady:
|
||||
*out = newer.PodReady
|
||||
break
|
||||
case "":
|
||||
*out = ""
|
||||
default:
|
||||
*out = newer.PodConditionType(*in)
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
|
|
|
@ -490,20 +490,20 @@ const (
|
|||
PodUnknown PodPhase = "Unknown"
|
||||
)
|
||||
|
||||
// PodConditionKind is a valid value for PodCondition.Kind
|
||||
type PodConditionKind string
|
||||
// PodConditionType is a valid value for PodCondition.Type
|
||||
type PodConditionType string
|
||||
|
||||
// These are valid conditions of pod.
|
||||
const (
|
||||
// PodReady means the pod is able to service requests and should be added to the
|
||||
// load balancing pools of all matching services.
|
||||
PodReady PodConditionKind = "Ready"
|
||||
PodReady PodConditionType = "Ready"
|
||||
)
|
||||
|
||||
// TODO: add LastTransitionTime, Reason, Message to match NodeCondition api.
|
||||
type PodCondition struct {
|
||||
// Status is the status of the condition
|
||||
Kind PodConditionKind `json:"kind"`
|
||||
// Type is the type of the condition
|
||||
Type PodConditionType `json:"type"`
|
||||
// Status is the status of the condition
|
||||
Status ConditionStatus `json:"status"`
|
||||
}
|
||||
|
@ -838,20 +838,20 @@ const (
|
|||
NodeTerminated NodePhase = "Terminated"
|
||||
)
|
||||
|
||||
type NodeConditionKind string
|
||||
type NodeConditionType string
|
||||
|
||||
// These are valid conditions of node. Currently, we don't have enough information to decide
|
||||
// node condition. In the future, we will add more. The proposed set of conditions are:
|
||||
// NodeReachable, NodeLive, NodeReady, NodeSchedulable, NodeRunnable.
|
||||
const (
|
||||
// NodeReachable means the node can be reached (in the sense of HTTP connection) from node controller.
|
||||
NodeReachable NodeConditionKind = "Reachable"
|
||||
NodeReachable NodeConditionType = "Reachable"
|
||||
// NodeReady means the node returns StatusOK for HTTP health check.
|
||||
NodeReady NodeConditionKind = "Ready"
|
||||
NodeReady NodeConditionType = "Ready"
|
||||
)
|
||||
|
||||
type NodeCondition struct {
|
||||
Kind NodeConditionKind `json:"kind"`
|
||||
Type NodeConditionType `json:"type"`
|
||||
Status ConditionStatus `json:"status"`
|
||||
LastProbeTime util.Time `json:"lastProbeTime,omitempty"`
|
||||
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
|
||||
|
|
|
@ -304,21 +304,21 @@ func (s *NodeController) checkNodeReady(node *api.Node) *api.NodeCondition {
|
|||
case err != nil:
|
||||
glog.V(2).Infof("NodeController: node %s health check error: %v", node.Name, err)
|
||||
return &api.NodeCondition{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionUnknown,
|
||||
Reason: fmt.Sprintf("Node health check error: %v", err),
|
||||
LastProbeTime: util.Now(),
|
||||
}
|
||||
case status == probe.Failure:
|
||||
return &api.NodeCondition{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionNone,
|
||||
Reason: fmt.Sprintf("Node health check failed: kubelet /healthz endpoint returns not ok"),
|
||||
LastProbeTime: util.Now(),
|
||||
}
|
||||
default:
|
||||
return &api.NodeCondition{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: fmt.Sprintf("Node health check succeeded: kubelet /healthz endpoint returns ok"),
|
||||
LastProbeTime: util.Now(),
|
||||
|
@ -405,10 +405,10 @@ func (s *NodeController) canonicalizeName(nodes *api.NodeList) *api.NodeList {
|
|||
}
|
||||
|
||||
// getCondition returns a condition object for the specific condition
|
||||
// kind, nil if the condition is not set.
|
||||
func (s *NodeController) getCondition(node *api.Node, kind api.NodeConditionKind) *api.NodeCondition {
|
||||
// type, nil if the condition is not set.
|
||||
func (s *NodeController) getCondition(node *api.Node, conditionType api.NodeConditionType) *api.NodeCondition {
|
||||
for i := range node.Status.Conditions {
|
||||
if node.Status.Conditions[i].Kind == kind {
|
||||
if node.Status.Conditions[i].Type == conditionType {
|
||||
return &node.Status.Conditions[i]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -533,7 +533,7 @@ func TestHealthCheckNode(t *testing.T) {
|
|||
},
|
||||
expectedConditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
},
|
||||
|
@ -547,7 +547,7 @@ func TestHealthCheckNode(t *testing.T) {
|
|||
},
|
||||
expectedConditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionNone,
|
||||
Reason: "Node health check failed: kubelet /healthz endpoint returns not ok",
|
||||
},
|
||||
|
@ -561,7 +561,7 @@ func TestHealthCheckNode(t *testing.T) {
|
|||
},
|
||||
expectedConditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionUnknown,
|
||||
Reason: "Node health check error: Error",
|
||||
},
|
||||
|
@ -638,7 +638,7 @@ func TestSyncNodeStatusTransitionTime(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
LastTransitionTime: util.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
|
@ -664,7 +664,7 @@ func TestSyncNodeStatusTransitionTime(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
LastTransitionTime: util.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
|
@ -725,7 +725,7 @@ func TestSyncNodeStatusDeletePods(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
LastTransitionTime: util.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
|
@ -755,7 +755,7 @@ func TestSyncNodeStatusDeletePods(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
LastTransitionTime: util.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
|
@ -784,7 +784,7 @@ func TestSyncNodeStatusDeletePods(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionNone,
|
||||
Reason: "Node health check failed: kubelet /healthz endpoint returns not ok",
|
||||
// Here, last transition time is Now(). In node controller, the new condition's probe time is
|
||||
|
@ -816,7 +816,7 @@ func TestSyncNodeStatusDeletePods(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionNone,
|
||||
Reason: "Node health check failed: kubelet /healthz endpoint returns not ok",
|
||||
// Here, last transition time is in the past, and in node controller, the
|
||||
|
@ -881,7 +881,7 @@ func TestSyncNodeStatus(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
},
|
||||
|
@ -894,7 +894,7 @@ func TestSyncNodeStatus(t *testing.T) {
|
|||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Kind: api.NodeReady,
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: "Node health check succeeded: kubelet /healthz endpoint returns ok",
|
||||
},
|
||||
|
|
|
@ -194,10 +194,10 @@ func (d *PodDescriber) Describe(namespace, name string) (string, error) {
|
|||
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 len(pod.Status.Conditions) > 0 {
|
||||
fmt.Fprint(out, "Conditions:\n Kind\tStatus\n")
|
||||
fmt.Fprint(out, "Conditions:\n Type\tStatus\n")
|
||||
for _, c := range pod.Status.Conditions {
|
||||
fmt.Fprintf(out, " %v \t%v \n",
|
||||
c.Kind,
|
||||
c.Type,
|
||||
c.Status)
|
||||
}
|
||||
}
|
||||
|
@ -312,10 +312,10 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
|
|||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", minion.Name)
|
||||
if len(minion.Status.Conditions) > 0 {
|
||||
fmt.Fprint(out, "Conditions:\n Kind\tStatus\tLastProbeTime\tLastTransitionTime\tReason\tMessage\n")
|
||||
fmt.Fprint(out, "Conditions:\n Type\tStatus\tLastProbeTime\tLastTransitionTime\tReason\tMessage\n")
|
||||
for _, c := range minion.Status.Conditions {
|
||||
fmt.Fprintf(out, " %v \t%v \t%s \t%s \t%v \t%v\n",
|
||||
c.Kind,
|
||||
c.Type,
|
||||
c.Status,
|
||||
c.LastProbeTime.Time.Format(time.RFC1123Z),
|
||||
c.LastTransitionTime.Time.Format(time.RFC1123Z),
|
||||
|
|
|
@ -409,19 +409,19 @@ func printSecretList(list *api.SecretList, w io.Writer) error {
|
|||
}
|
||||
|
||||
func printNode(node *api.Node, w io.Writer) error {
|
||||
conditionMap := make(map[api.NodeConditionKind]*api.NodeCondition)
|
||||
NodeAllConditions := []api.NodeConditionKind{api.NodeReady, api.NodeReachable}
|
||||
conditionMap := make(map[api.NodeConditionType]*api.NodeCondition)
|
||||
NodeAllConditions := []api.NodeConditionType{api.NodeReady, api.NodeReachable}
|
||||
for i := range node.Status.Conditions {
|
||||
cond := node.Status.Conditions[i]
|
||||
conditionMap[cond.Kind] = &cond
|
||||
conditionMap[cond.Type] = &cond
|
||||
}
|
||||
var status []string
|
||||
for _, validCondition := range NodeAllConditions {
|
||||
if condition, ok := conditionMap[validCondition]; ok {
|
||||
if condition.Status == api.ConditionFull {
|
||||
status = append(status, string(condition.Kind))
|
||||
status = append(status, string(condition.Type))
|
||||
} else {
|
||||
status = append(status, "Not"+string(condition.Kind))
|
||||
status = append(status, "Not"+string(condition.Type))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -524,7 +524,7 @@ func TestPrintMinionStatus(t *testing.T) {
|
|||
{
|
||||
minion: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo1"},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Kind: api.NodeReady, Status: api.ConditionFull}}},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFull}}},
|
||||
},
|
||||
status: "Ready",
|
||||
},
|
||||
|
@ -532,8 +532,8 @@ func TestPrintMinionStatus(t *testing.T) {
|
|||
minion: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo2"},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Kind: api.NodeReachable, Status: api.ConditionFull}}},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReachable, Status: api.ConditionFull}}},
|
||||
},
|
||||
status: "Ready,Reachable",
|
||||
},
|
||||
|
@ -541,22 +541,22 @@ func TestPrintMinionStatus(t *testing.T) {
|
|||
minion: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo3"},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull}}},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull}}},
|
||||
},
|
||||
status: "Ready",
|
||||
},
|
||||
{
|
||||
minion: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo4"},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Kind: api.NodeReady, Status: api.ConditionNone}}},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionNone}}},
|
||||
},
|
||||
status: "NotReady",
|
||||
},
|
||||
{
|
||||
minion: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo5"},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Kind: "InvalidValue", Status: api.ConditionFull}}},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionFull}}},
|
||||
},
|
||||
status: "Unknown",
|
||||
},
|
||||
|
|
|
@ -1599,11 +1599,11 @@ func getPhase(spec *api.PodSpec, info api.PodInfo) api.PodPhase {
|
|||
// getPodReadyCondition returns ready condition if all containers in a pod are ready, else it returns an unready condition.
|
||||
func getPodReadyCondition(spec *api.PodSpec, info api.PodInfo) []api.PodCondition {
|
||||
ready := []api.PodCondition{{
|
||||
Kind: api.PodReady,
|
||||
Type: api.PodReady,
|
||||
Status: api.ConditionFull,
|
||||
}}
|
||||
unready := []api.PodCondition{{
|
||||
Kind: api.PodReady,
|
||||
Type: api.PodReady,
|
||||
Status: api.ConditionNone,
|
||||
}}
|
||||
if info == nil {
|
||||
|
|
|
@ -2743,11 +2743,11 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
|
|||
|
||||
func TestGetPodReadyCondition(t *testing.T) {
|
||||
ready := []api.PodCondition{{
|
||||
Kind: api.PodReady,
|
||||
Type: api.PodReady,
|
||||
Status: api.ConditionFull,
|
||||
}}
|
||||
unready := []api.PodCondition{{
|
||||
Kind: api.PodReady,
|
||||
Type: api.PodReady,
|
||||
Status: api.ConditionNone,
|
||||
}}
|
||||
tests := []struct {
|
||||
|
|
|
@ -180,7 +180,7 @@ func (p *PodCache) computePodStatus(pod *api.Pod) (api.PodStatus, error) {
|
|||
|
||||
// Assigned to an unhealthy node.
|
||||
for _, condition := range nodeStatus.Conditions {
|
||||
if (condition.Kind == api.NodeReady || condition.Kind == api.NodeReachable) && condition.Status == api.ConditionNone {
|
||||
if (condition.Type == api.NodeReady || condition.Type == api.NodeReachable) && condition.Status == api.ConditionNone {
|
||||
glog.V(5).Infof("node status: %v, setting pod %q status to unknown", condition, pod.Name)
|
||||
newStatus.Phase = api.PodUnknown
|
||||
newStatus.Conditions = append(newStatus.Conditions, pod.Status.Conditions...)
|
||||
|
|
|
@ -226,7 +226,7 @@ func makeHealthyNode(name string, ip string) *api.Node {
|
|||
Status: api.NodeStatus{
|
||||
HostIP: ip,
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ func makeUnhealthyNode(name string) *api.Node {
|
|||
return &api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: name},
|
||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionNone},
|
||||
{Type: api.NodeReady, Status: api.ConditionNone},
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ func (e *EndpointController) SyncServiceEndpoints() error {
|
|||
|
||||
inService := false
|
||||
for _, c := range pod.Status.Conditions {
|
||||
if c.Kind == api.PodReady && c.Status == api.ConditionFull {
|
||||
if c.Type == api.PodReady && c.Status == api.ConditionFull {
|
||||
inService = true
|
||||
break
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func newPodList(count int) *api.PodList {
|
|||
PodIP: "1.2.3.4",
|
||||
Conditions: []api.PodCondition{
|
||||
{
|
||||
Kind: api.PodReady,
|
||||
Type: api.PodReady,
|
||||
Status: api.ConditionFull,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -179,10 +179,10 @@ func (factory *ConfigFactory) pollMinions() (cache.Enumerator, error) {
|
|||
ListMeta: allNodes.ListMeta,
|
||||
}
|
||||
for _, node := range allNodes.Items {
|
||||
conditionMap := make(map[api.NodeConditionKind]*api.NodeCondition)
|
||||
conditionMap := make(map[api.NodeConditionType]*api.NodeCondition)
|
||||
for i := range node.Status.Conditions {
|
||||
cond := node.Status.Conditions[i]
|
||||
conditionMap[cond.Kind] = &cond
|
||||
conditionMap[cond.Type] = &cond
|
||||
}
|
||||
if condition, ok := conditionMap[api.NodeReady]; ok {
|
||||
if condition.Status == api.ConditionFull {
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -65,7 +65,7 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReachable, Status: api.ConditionFull},
|
||||
{Type: api.NodeReachable, Status: api.ConditionFull},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -73,8 +73,8 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Kind: api.NodeReachable, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReachable, Status: api.ConditionFull},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -82,8 +82,8 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -96,7 +96,7 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -104,7 +104,7 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionNone},
|
||||
{Type: api.NodeReady, Status: api.ConditionNone},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -117,8 +117,8 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReady, Status: api.ConditionFull},
|
||||
{Kind: api.NodeReachable, Status: api.ConditionNone}},
|
||||
{Type: api.NodeReady, Status: api.ConditionFull},
|
||||
{Type: api.NodeReachable, Status: api.ConditionNone}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -130,8 +130,8 @@ func TestPollMinions(t *testing.T) {
|
|||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Status: api.NodeStatus{
|
||||
Conditions: []api.NodeCondition{
|
||||
{Kind: api.NodeReachable, Status: api.ConditionFull},
|
||||
{Kind: "invalidValue", Status: api.ConditionNone}},
|
||||
{Type: api.NodeReachable, Status: api.ConditionFull},
|
||||
{Type: "invalidValue", Status: api.ConditionNone}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue