diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index e3f393c241d..7f0c2fae264 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -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 } diff --git a/pkg/kubectl/resource_printer_test.go b/pkg/kubectl/resource_printer_test.go index f34e17cdffb..db7455f65e2 100644 --- a/pkg/kubectl/resource_printer_test.go +++ b/pkg/kubectl/resource_printer_test.go @@ -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 {