Change:
<!-- Please only use this template for submitting reports about failing tests in Kubernetes CI jobs --Setting PodPriority directly when adminssion Priority enable,the Pod is rejected. To fix this, we need to create new priority classes for these tests. Which jobs are failing: Which test(s) are failing: I0822 19:01:41.165] should be able to create and delete a critical pod [It] Since when has it been failing: Testgrid link: Reason for failure: because adminssion Priority enableIf the priority class is not found, the Pod is rejected. Anything else we need to know:
/area e2e-test-framework /sig testing /kind bug /priority important-soon
This has now changed to this error: /reopen
Reopened this issue. <detailsIn response to : This has now changed to this error: /reopen Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
For reference: testgrid link /milestone v1.17
is this still in progress?
pr has updated, PTAL.
looks like has to merge for this to close
/milestone v1.18

Discussion:
"fmt" v1 "k8s.io/api/core/v1" <del> schedulingv1 "k8s.io/api/scheduling/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" </del> "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kubeapi "k8s.io/kubernetes/pkg/apis/core"

) const ( <del> criticalPodName            = "critical-pod" guaranteedPodName          = "guaranteed" burstablePodName           = "burstable" bestEffortPodName          = "best-effort" systemCriticalPriorityName = "critical-pod-test-high-priority" </del> <ins> criticalPodName   = "static-critical-pod" guaranteedPodName = "guaranteed" burstablePodName  = "burstable" bestEffortPodName = "best-effort" </ins> ) var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:CriticalPod]", func() {

framework.Skipf("unable to run test without dynamic kubelet config enabled.") } // because adminssion Priority enable, If the priority class is not found, the Pod is rejected. <del> systemCriticalPriority := &schedulingv1.PriorityClass{ObjectMeta: metav1.ObjectMeta{Name: systemCriticalPriorityName}, Value: scheduling.SystemCriticalPriority} </del> <ins> node := getNodeName(f) </ins> // Define test pods nonCriticalGuaranteed := getTestPod(false, guaranteedPodName, v1.ResourceRequirements{ Requests: v1.ResourceList{

v1.ResourceCPU:    resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), }, <del> }) </del> <ins> }, node) </ins> nonCriticalBurstable := getTestPod(false, burstablePodName, v1.ResourceRequirements{ Requests: v1.ResourceList{ v1.ResourceCPU:    resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), }, <del> }) nonCriticalBestEffort := getTestPod(false, bestEffortPodName, v1.ResourceRequirements{}) </del> <ins> }, node) nonCriticalBestEffort := getTestPod(false, bestEffortPodName, v1.ResourceRequirements{}, node) </ins> criticalPod := getTestPod(true, criticalPodName, v1.ResourceRequirements{ // request the entire resource capacity of the node, so that // admitting this pod requires the other pod to be preempted Requests: getNodeCPUAndMemoryCapacity(f), <del> }) _, err = f.ClientSet.SchedulingV1().PriorityClasses().Create(systemCriticalPriority) framework.ExpectEqual(err == nil || apierrors.IsAlreadyExists(err), true, "failed to create PriorityClasses with an error: %v", err) </del> <ins> }, node) </ins> // Create pods, starting with non-critical so that the critical preempts the other pods. f.PodClient().CreateBatch([]*v1.Pod{nonCriticalBestEffort, nonCriticalBurstable, nonCriticalGuaranteed})

framework.ExpectNoError(err) for _, p := range updatedPodList.Items { if p.Name == nonCriticalBestEffort.Name { <del> framework.ExpectNotEqual(p.Status.Phase, v1.PodFailed, fmt.Sprintf("pod: %v should be preempted", p.Name)) </del> <ins> framework.ExpectEqual(p.Status.Phase, v1.PodRunning, fmt.Sprintf("pod: %v should not be preempted with status: %#v", p.Name, p.Status)) </ins> } else { <del> framework.ExpectEqual(p.Status.Phase, v1.PodFailed, fmt.Sprintf("pod: %v should not be preempted", p.Name)) </del> <ins> framework.ExpectEqual(p.Status.Phase, v1.PodFailed, fmt.Sprintf("pod: %v should be preempted with status: %#v", p.Name, p.Status)) </ins> } } })

f.PodClient().DeleteSync(burstablePodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) f.PodClient().DeleteSync(bestEffortPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) f.PodClientNS(kubeapi.NamespaceSystem).DeleteSync(criticalPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout) <del> err := f.ClientSet.SchedulingV1().PriorityClasses().Delete(systemCriticalPriorityName, &metav1.DeleteOptions{}) framework.ExpectNoError(err) </del> // Log Events logPodEvents(f) logNodeEvents(f)

} } <del> func getTestPod(critical bool, name string, resources v1.ResourceRequirements) *v1.Pod { value := scheduling.SystemCriticalPriority </del> <ins> func getNodeName(f *framework.Framework) string { nodeList, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{}) framework.ExpectNoError(err) // Assuming that there is only one node, because this is a node e2e test. framework.ExpectEqual(len(nodeList.Items), 1) return nodeList.Items[0].GetName() } func getTestPod(critical bool, name string, resources v1.ResourceRequirements, node string) *v1.Pod { </ins> pod := &v1.Pod{ TypeMeta: metav1.TypeMeta{ Kind:       "Pod",

Resources: resources, }, }, <ins> NodeName: node, </ins> }, } if critical {

pod.ObjectMeta.Annotations = map[string]string{ kubelettypes.ConfigSourceAnnotationKey: kubelettypes.FileSource, } <del> pod.Spec.PriorityClassName = systemCriticalPriorityName pod.Spec.Priority = &value </del> <ins> pod.Spec.PriorityClassName = scheduling.SystemNodeCritical </ins> framework.ExpectEqual(kubelettypes.IsCriticalPod(pod), true, "pod should be a critical pod") } else {