mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
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:
commit
bd1bf11129
@ -503,12 +503,6 @@ func printNode(node *api.Node, w io.Writer) error {
|
|||||||
cond := node.Status.Conditions[i]
|
cond := node.Status.Conditions[i]
|
||||||
conditionMap[cond.Type] = &cond
|
conditionMap[cond.Type] = &cond
|
||||||
}
|
}
|
||||||
var schedulable string
|
|
||||||
if node.Spec.Unschedulable {
|
|
||||||
schedulable = "Unschedulable"
|
|
||||||
} else {
|
|
||||||
schedulable = "Schedulable"
|
|
||||||
}
|
|
||||||
var status []string
|
var status []string
|
||||||
for _, validCondition := range NodeAllConditions {
|
for _, validCondition := range NodeAllConditions {
|
||||||
if condition, ok := conditionMap[validCondition]; ok {
|
if condition, ok := conditionMap[validCondition]; ok {
|
||||||
@ -522,7 +516,10 @@ func printNode(node *api.Node, w io.Writer) error {
|
|||||||
if len(status) == 0 {
|
if len(status) == 0 {
|
||||||
status = append(status, "Unknown")
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,6 +555,14 @@ func TestPrintMinionStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
status: "Ready",
|
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{
|
minion: api.Node{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo3"},
|
ObjectMeta: api.ObjectMeta{Name: "foo3"},
|
||||||
@ -574,17 +582,41 @@ func TestPrintMinionStatus(t *testing.T) {
|
|||||||
{
|
{
|
||||||
minion: api.Node{
|
minion: api.Node{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo5"},
|
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: api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionTrue}}},
|
||||||
},
|
},
|
||||||
status: "Unknown",
|
status: "Unknown",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
minion: api.Node{
|
minion: api.Node{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo6"},
|
ObjectMeta: api.ObjectMeta{Name: "foo7"},
|
||||||
Status: api.NodeStatus{Conditions: []api.NodeCondition{{}}},
|
Status: api.NodeStatus{Conditions: []api.NodeCondition{{}}},
|
||||||
},
|
},
|
||||||
status: "Unknown",
|
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 {
|
for _, test := range table {
|
||||||
|
Loading…
Reference in New Issue
Block a user