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.
This commit is contained in:
Eric Paris 2015-04-20 07:53:55 -05:00
commit bd1bf11129
2 changed files with 37 additions and 8 deletions

View File

@ -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
}

View File

@ -555,6 +555,14 @@ func TestPrintMinionStatus(t *testing.T) {
},
status: "Ready",
},
{
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"},
@ -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 {