const message … type CriticalPodAdmissionHandler … var _ … func NewCriticalPodAdmissionHandler(getPodsFunc eviction.ActivePodsFunc, killPodFunc eviction.KillPodFunc, recorder record.EventRecorder) *CriticalPodAdmissionHandler { … } // HandleAdmissionFailure gracefully handles admission rejection, and, in some cases, // to allow admission of the pod despite its previous failure. func (c *CriticalPodAdmissionHandler) HandleAdmissionFailure(admitPod *v1.Pod, failureReasons []lifecycle.PredicateFailureReason) ([]lifecycle.PredicateFailureReason, error) { … } // evictPodsToFreeRequests takes a list of insufficient resources, and attempts to free them by evicting pods // based on requests. For example, if the only insufficient resource is 200Mb of memory, this function could // evict a pod with request=250Mb. func (c *CriticalPodAdmissionHandler) evictPodsToFreeRequests(admitPod *v1.Pod, insufficientResources admissionRequirementList) error { … } // getPodsToPreempt returns a list of pods that could be preempted to free requests >= requirements func getPodsToPreempt(pod *v1.Pod, pods []*v1.Pod, requirements admissionRequirementList) ([]*v1.Pod, error) { … } // getPodsToPreemptByDistance finds the pods that have pod requests >= admission requirements. // Chooses pods that minimize "distance" to the requirements. // If more than one pod exists that fulfills the remaining requirements, // it chooses the pod that has the "smaller resource request" // This method, by repeatedly choosing the pod that fulfills as much of the requirements as possible, // attempts to minimize the number of pods returned. func getPodsToPreemptByDistance(pods []*v1.Pod, requirements admissionRequirementList) ([]*v1.Pod, error) { … } type admissionRequirement … type admissionRequirementList … // distance returns distance of the pods requests from the admissionRequirements. // The distance is measured by the fraction of the requirement satisfied by the pod, // so that each requirement is weighted equally, regardless of absolute magnitude. func (a admissionRequirementList) distance(pod *v1.Pod) float64 { … } // subtract returns a new admissionRequirementList containing remaining requirements if the provided pod // were to be preempted func (a admissionRequirementList) subtract(pods ...*v1.Pod) admissionRequirementList { … } func (a admissionRequirementList) toString() string { … } // sortPodsByQOS returns lists containing besteffort, burstable, and guaranteed pods that // can be preempted by preemptor pod. func sortPodsByQOS(preemptor *v1.Pod, pods []*v1.Pod) (bestEffort, burstable, guaranteed []*v1.Pod) { … } // smallerResourceRequest returns true if pod1 has a smaller request than pod2 func smallerResourceRequest(pod1 *v1.Pod, pod2 *v1.Pod) bool { … }