Merge pull request #54685 from zjj2wry/node_detail_unschedule

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add unchedule information to kubectl describe node

**What this PR does / why we need it**:
Fixes #53721

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:
cc @smarterclayton
now output: 
```
		Name:               bar
		Roles:              <none>
		Labels:             <none>
		Annotations:        <none>
		Taints:             <none>
		Unschedulable:      true
		CreationTimestamp:  Mon, 01 Jan 0001 00:00:00 +0000
```

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-02-08 04:13:21 -08:00 committed by GitHub
commit b922ffc491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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