@@ -1910,20 +1910,26 @@ func (kl *Kubelet) handleMirrorPod(mirrorPod *api.Pod, start time.Time) {
19101910func (kl * Kubelet ) HandlePodAdditions (pods []* api.Pod ) {
19111911 start := kl .clock .Now ()
19121912
1913- // Pass critical pods through admission check first.
1914- var criticalPods []* api.Pod
1915- var nonCriticalPods []* api.Pod
1916- for _ , p := range pods {
1917- if kubetypes .IsCriticalPod (p ) {
1918- criticalPods = append (criticalPods , p )
1919- } else {
1920- nonCriticalPods = append (nonCriticalPods , p )
1913+ if utilconfig .DefaultFeatureGate .ExperimentalCriticalPodAnnotation () {
1914+ // Pass critical pods through admission check first.
1915+ var criticalPods []* api.Pod
1916+ var nonCriticalPods []* api.Pod
1917+ for _ , p := range pods {
1918+ if kubetypes .IsCriticalPod (p ) {
1919+ criticalPods = append (criticalPods , p )
1920+ } else {
1921+ nonCriticalPods = append (nonCriticalPods , p )
1922+ }
19211923 }
1924+ sort .Sort (sliceutils .PodsByCreationTime (criticalPods ))
1925+ sort .Sort (sliceutils .PodsByCreationTime (nonCriticalPods ))
1926+ pods = append (criticalPods , nonCriticalPods ... )
1927+
1928+ } else {
1929+ sort .Sort (sliceutils .PodsByCreationTime (pods ))
19221930 }
1923- sort .Sort (sliceutils .PodsByCreationTime (criticalPods ))
1924- sort .Sort (sliceutils .PodsByCreationTime (nonCriticalPods ))
19251931
1926- for _ , pod := range append ( criticalPods , nonCriticalPods ... ) {
1932+ for _ , pod := range pods {
19271933 existingPods := kl .podManager .GetPods ()
19281934 // Always add the pod to the pod manager. Kubelet relies on the pod
19291935 // manager as the source of truth for the desired state. If a pod does
0 commit comments