Merge pull request #110914 from yeahdongcn/RuntimeClassName
Print pod.Spec.RuntimeClassName in kubectl describe Kubernetes-commit: bbd2f8fa09d4b759caf4ccd860bdbe7077a4ae73
This commit is contained in:
commit
e31dc45257
12
go.mod
12
go.mod
|
|
@ -30,10 +30,10 @@ require (
|
|||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.0.0-20220722161209-9a18f7af64ea
|
||||
k8s.io/apimachinery v0.0.0-20220722160306-066110477272
|
||||
k8s.io/api v0.0.0-20220722161209-f77fa25e8904
|
||||
k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb
|
||||
k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c
|
||||
k8s.io/client-go v0.0.0-20220722162230-95a40e254c5f
|
||||
k8s.io/client-go v0.0.0-20220722162231-4db4856058cc
|
||||
k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7
|
||||
k8s.io/component-helpers v0.0.0-20220722164708-7cd6476d8900
|
||||
k8s.io/klog/v2 v2.70.1
|
||||
|
|
@ -94,10 +94,10 @@ require (
|
|||
)
|
||||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20220722161209-9a18f7af64ea
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220722160306-066110477272
|
||||
k8s.io/api => k8s.io/api v0.0.0-20220722161209-f77fa25e8904
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20220722162230-95a40e254c5f
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20220722162231-4db4856058cc
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20220719123406-a08f67b4c688
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20220722164708-7cd6476d8900
|
||||
|
|
|
|||
12
go.sum
12
go.sum
|
|
@ -741,14 +741,14 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20220722161209-9a18f7af64ea h1:MiYxdszYyKHmf2sdDWFDd98Np+DMLLUDrBeRd1Ke6EI=
|
||||
k8s.io/api v0.0.0-20220722161209-9a18f7af64ea/go.mod h1:ohV8ZX/DUd8BAQLw1YBcZo6qQ0u5oW1obsjteznQh6s=
|
||||
k8s.io/apimachinery v0.0.0-20220722160306-066110477272 h1:lP7eyx/jwkCcmKA3LYf1pYGcsflSINRJLdLuhDZBcmc=
|
||||
k8s.io/apimachinery v0.0.0-20220722160306-066110477272/go.mod h1:E6C2QnwpsJTXktTwPqd4nAJ/xmsdi1AHqDD0iPB61j0=
|
||||
k8s.io/api v0.0.0-20220722161209-f77fa25e8904 h1:0e3sqfqka9TQC0vBbSDYxUYkxuIjA4xBOErf8T4ldhU=
|
||||
k8s.io/api v0.0.0-20220722161209-f77fa25e8904/go.mod h1:ohV8ZX/DUd8BAQLw1YBcZo6qQ0u5oW1obsjteznQh6s=
|
||||
k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb h1:CkEjGDsYVgTZod3JtHw5+t2LG2ZoEQpGlvjdQTiiosA=
|
||||
k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb/go.mod h1:E6C2QnwpsJTXktTwPqd4nAJ/xmsdi1AHqDD0iPB61j0=
|
||||
k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c h1:3Pt53df9gpA8ag85fLTsSyk9iGuHkwECtnaRW6qD+UM=
|
||||
k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c/go.mod h1:po7EOvUazqFFYOb4kOhPOiXcSZJWCYiJB02p7D7Woi8=
|
||||
k8s.io/client-go v0.0.0-20220722162230-95a40e254c5f h1:JO2UKNbXmllH9IGhanNDNN3AhEqy9yaSFhtU3Y4ClK0=
|
||||
k8s.io/client-go v0.0.0-20220722162230-95a40e254c5f/go.mod h1:3zUxVad6vwmBCMeqE4RAlOrAuioKG3MQgO6Zl4PJwqo=
|
||||
k8s.io/client-go v0.0.0-20220722162231-4db4856058cc h1:3mrn9B1x+4hTiKqQ3yz1Q6ojGJTwQtGE9aPvWL2kYFk=
|
||||
k8s.io/client-go v0.0.0-20220722162231-4db4856058cc/go.mod h1:3zUxVad6vwmBCMeqE4RAlOrAuioKG3MQgO6Zl4PJwqo=
|
||||
k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7 h1:RpWbFycy+h6+lA57wCIP4GAntYp1YXQ6BibP4Db20mQ=
|
||||
k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7/go.mod h1:MKzPOLrISkhaw9g2iJytMZf0obKe8Z/P7IVIotfVbeA=
|
||||
k8s.io/component-helpers v0.0.0-20220722164708-7cd6476d8900 h1:lZRiZ42GZuXZfPXa5A+Vbed4mr00HiH4H1Spmq8zraI=
|
||||
|
|
|
|||
|
|
@ -764,7 +764,10 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
|
|||
w.Write(LEVEL_0, "Priority:\t%d\n", *pod.Spec.Priority)
|
||||
}
|
||||
if len(pod.Spec.PriorityClassName) > 0 {
|
||||
w.Write(LEVEL_0, "Priority Class Name:\t%s\n", stringOrNone(pod.Spec.PriorityClassName))
|
||||
w.Write(LEVEL_0, "Priority Class Name:\t%s\n", pod.Spec.PriorityClassName)
|
||||
}
|
||||
if pod.Spec.RuntimeClassName != nil && len(*pod.Spec.RuntimeClassName) > 0 {
|
||||
w.Write(LEVEL_0, "Runtime Class Name:\t%s\n", *pod.Spec.RuntimeClassName)
|
||||
}
|
||||
if pod.Spec.NodeName == "" {
|
||||
w.Write(LEVEL_0, "Node:\t<none>\n")
|
||||
|
|
|
|||
|
|
@ -378,6 +378,86 @@ func TestDescribePodPriority(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDescribePodRuntimeClass(t *testing.T) {
|
||||
runtimeClassNames := []string{"test1", ""}
|
||||
testCases := []struct {
|
||||
name string
|
||||
pod *corev1.Pod
|
||||
expect []string
|
||||
unexpect []string
|
||||
}{
|
||||
{
|
||||
name: "test1",
|
||||
pod: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
RuntimeClassName: &runtimeClassNames[0],
|
||||
},
|
||||
},
|
||||
expect: []string{
|
||||
"Name", "bar",
|
||||
"Runtime Class Name", "test1",
|
||||
},
|
||||
unexpect: []string{},
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
pod: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
RuntimeClassName: &runtimeClassNames[1],
|
||||
},
|
||||
},
|
||||
expect: []string{
|
||||
"Name", "bar",
|
||||
},
|
||||
unexpect: []string{
|
||||
"Runtime Class Name",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "test3",
|
||||
pod: &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
Spec: corev1.PodSpec{},
|
||||
},
|
||||
expect: []string{
|
||||
"Name", "bar",
|
||||
},
|
||||
unexpect: []string{
|
||||
"Runtime Class Name",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
fake := fake.NewSimpleClientset(testCase.pod)
|
||||
c := &describeClient{T: t, Interface: fake}
|
||||
d := PodDescriber{c}
|
||||
out, err := d.Describe("", "bar", DescriberSettings{ShowEvents: true})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
for _, expected := range testCase.expect {
|
||||
if !strings.Contains(out, expected) {
|
||||
t.Errorf("expected to find %q in output: %q", expected, out)
|
||||
}
|
||||
}
|
||||
for _, unexpected := range testCase.unexpect {
|
||||
if strings.Contains(out, unexpected) {
|
||||
t.Errorf("unexpected to find %q in output: %q", unexpected, out)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribePriorityClass(t *testing.T) {
|
||||
preemptLowerPriority := corev1.PreemptLowerPriority
|
||||
preemptNever := corev1.PreemptNever
|
||||
|
|
|
|||
Loading…
Reference in New Issue