mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #54625 from wackxu/pppri
Automatic merge from submit-queue (batch tested with PRs 53796, 54666, 54516, 54625, 54704). 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>. print priority when describe pod **What this PR does / why we need it**: show the priority of pod when describe pod when we use pod priority **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #54624 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
25a98328b6
@ -622,6 +622,10 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%s\n", pod.Name)
|
||||
w.Write(LEVEL_0, "Namespace:\t%s\n", pod.Namespace)
|
||||
if pod.Spec.Priority != nil {
|
||||
w.Write(LEVEL_0, "Priority:\t%d\n", *pod.Spec.Priority)
|
||||
w.Write(LEVEL_0, "PriorityClassName:\t%s\n", stringOrNone(pod.Spec.PriorityClassName))
|
||||
}
|
||||
if pod.Spec.NodeName == "" {
|
||||
w.Write(LEVEL_0, "Node:\t<none>\n")
|
||||
} else {
|
||||
|
@ -142,6 +142,28 @@ func TestDescribeNamespace(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribePodPriority(t *testing.T) {
|
||||
priority := int32(1000)
|
||||
fake := fake.NewSimpleClientset(&api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
PriorityClassName: "high-priority",
|
||||
Priority: &priority,
|
||||
},
|
||||
})
|
||||
c := &describeClient{T: t, Namespace: "", Interface: fake}
|
||||
d := PodDescriber{c}
|
||||
out, err := d.Describe("", "bar", printers.DescriberSettings{ShowEvents: true})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !strings.Contains(out, "high-priority") || !strings.Contains(out, "1000") {
|
||||
t.Errorf("unexpected out: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribeConfigMap(t *testing.T) {
|
||||
fake := fake.NewSimpleClientset(&api.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
Loading…
Reference in New Issue
Block a user