Commit bd1bf111 authored by Eric Paris's avatar Eric Paris

Merge pull request #6886 from aveshagarwal/kubectl-get-nodes-issue

This commit fixes "kubectl get nodes" output and makes it more sane. It also fixes related test case resource_printer_test.
parents eb1ea269 a2ac72c4
......@@ -503,12 +503,6 @@ func printNode(node *api.Node, w io.Writer) error {
cond := node.Status.Conditions[i]
conditionMap[cond.Type] = &cond
}
var schedulable string
if node.Spec.Unschedulable {
schedulable = "Unschedulable"
} else {
schedulable = "Schedulable"
}
var status []string
for _, validCondition := range NodeAllConditions {
if condition, ok := conditionMap[validCondition]; ok {
......@@ -522,7 +516,10 @@ func printNode(node *api.Node, w io.Writer) error {
if len(status) == 0 {
status = append(status, "Unknown")
}
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", node.Name, schedulable, formatLabels(node.Labels), strings.Join(status, ","))
if node.Spec.Unschedulable {
status = append(status, "SchedulingDisabled")
}
_, err := fmt.Fprintf(w, "%s\t%s\t%s\n", node.Name, formatLabels(node.Labels), strings.Join(status, ","))
return err
}
......
......@@ -557,6 +557,14 @@ func TestPrintMinionStatus(t *testing.T) {
},
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo2"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
},
status: "Ready,SchedulingDisabled",
},
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo3"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{
{Type: api.NodeReady, Status: api.ConditionTrue},
......@@ -574,17 +582,41 @@ func TestPrintMinionStatus(t *testing.T) {
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo5"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
},
status: "NotReady,SchedulingDisabled",
},
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo6"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionTrue}}},
},
status: "Unknown",
},
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo6"},
ObjectMeta: api.ObjectMeta{Name: "foo7"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{}}},
},
status: "Unknown",
},
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo8"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionTrue}}},
},
status: "Unknown,SchedulingDisabled",
},
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo9"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{}}},
},
status: "Unknown,SchedulingDisabled",
},
}
for _, test := range table {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment