add unchedule information to kubectl describe node

This commit is contained in:
zhengjiajin 2018-02-06 20:14:46 +08:00
parent 551f73d324
commit df4586b775
2 changed files with 28 additions and 1 deletions

View File

@ -2588,8 +2588,9 @@ func describeNode(node *api.Node, nodeNonTerminatedPodsList *api.PodList, events
}
printLabelsMultiline(w, "Labels", node.Labels)
printAnnotationsMultiline(w, "Annotations", node.Annotations)
printNodeTaintsMultiline(w, "Taints", node.Spec.Taints)
w.Write(LEVEL_0, "CreationTimestamp:\t%s\n", node.CreationTimestamp.Time.Format(time.RFC1123Z))
printNodeTaintsMultiline(w, "Taints", node.Spec.Taints)
w.Write(LEVEL_0, "Unschedulable:\t%v\n", node.Spec.Unschedulable)
if len(node.Status.Conditions) > 0 {
w.Write(LEVEL_0, "Conditions:\n Type\tStatus\tLastHeartbeatTime\tLastTransitionTime\tReason\tMessage\n")
w.Write(LEVEL_1, "----\t------\t-----------------\t------------------\t------\t-------\n")

View File

@ -2108,6 +2108,32 @@ Events: <none>` + "\n"
}
func TestDescribeNode(t *testing.T) {
fake := fake.NewSimpleClientset(&api.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
Namespace: "foo",
},
Spec: api.NodeSpec{
Unschedulable: true,
},
})
c := &describeClient{T: t, Namespace: "foo", Interface: fake}
d := NodeDescriber{c}
out, err := d.Describe("foo", "bar", printers.DescriberSettings{ShowEvents: true})
if err != nil {
t.Errorf("unexpected error: %v", err)
}
expectedOut := []string{"Unschedulable", "true"}
for _, expected := range expectedOut {
if !strings.Contains(out, expected) {
t.Errorf("expected to find %q in output: %q", expected, out)
}
}
}
// boolPtr returns a pointer to a bool
func boolPtr(b bool) *bool {
o := b