mirror of https://github.com/k3s-io/k3s
Merge pull request #75739 from Huang-Wei/cleanup-preemption-comments
scheduler: correct dated comments on pod preemptionk3s-v1.15.3
commit
2e05cdb7ae
|
@ -90,7 +90,8 @@ type Config struct {
|
|||
// with scheduling, PodScheduled condition will be updated in apiserver in /bind
|
||||
// handler so that binding and setting PodCondition it is atomic.
|
||||
PodConditionUpdater PodConditionUpdater
|
||||
// PodPreemptor is used to evict pods and update pod annotations.
|
||||
// PodPreemptor is used to evict pods and update 'NominatedNode' field of
|
||||
// the preemptor pod.
|
||||
PodPreemptor PodPreemptor
|
||||
// PlugingSet has a set of plugins and data used to run them.
|
||||
PluginSet pluginsv1alpha1.PluginSet
|
||||
|
@ -125,8 +126,8 @@ type Config struct {
|
|||
SchedulingQueue internalqueue.SchedulingQueue
|
||||
}
|
||||
|
||||
// PodPreemptor has methods needed to delete a pod and to update
|
||||
// annotations of the preemptor pod.
|
||||
// PodPreemptor has methods needed to delete a pod and to update 'NominatedPod'
|
||||
// field of the preemptor pod.
|
||||
type PodPreemptor interface {
|
||||
GetUpdatedPod(pod *v1.Pod) (*v1.Pod, error)
|
||||
DeletePod(pod *v1.Pod) error
|
||||
|
|
|
@ -285,7 +285,7 @@ func (sched *Scheduler) schedule(pod *v1.Pod) (core.ScheduleResult, error) {
|
|||
}
|
||||
|
||||
// preempt tries to create room for a pod that has failed to schedule, by preempting lower priority pods if possible.
|
||||
// If it succeeds, it adds the name of the node where preemption has happened to the pod annotations.
|
||||
// If it succeeds, it adds the name of the node where preemption has happened to the pod spec.
|
||||
// It returns the node name and an error if any.
|
||||
func (sched *Scheduler) preempt(preemptor *v1.Pod, scheduleErr error) (string, error) {
|
||||
preemptor, err := sched.config.PodPreemptor.GetUpdatedPod(preemptor)
|
||||
|
@ -310,7 +310,7 @@ func (sched *Scheduler) preempt(preemptor *v1.Pod, scheduleErr error) (string, e
|
|||
// Make a call to update nominated node name of the pod on the API server.
|
||||
err = sched.config.PodPreemptor.SetNominatedNodeName(preemptor, nodeName)
|
||||
if err != nil {
|
||||
klog.Errorf("Error in preemption process. Cannot update pod %v/%v annotations: %v", preemptor.Namespace, preemptor.Name, err)
|
||||
klog.Errorf("Error in preemption process. Cannot set 'NominatedPod' on pod %v/%v: %v", preemptor.Namespace, preemptor.Name, err)
|
||||
sched.config.SchedulingQueue.DeleteNominatedPodIfExists(preemptor)
|
||||
return "", err
|
||||
}
|
||||
|
@ -327,11 +327,12 @@ func (sched *Scheduler) preempt(preemptor *v1.Pod, scheduleErr error) (string, e
|
|||
// Clearing nominated pods should happen outside of "if node != nil". Node could
|
||||
// be nil when a pod with nominated node name is eligible to preempt again,
|
||||
// but preemption logic does not find any node for it. In that case Preempt()
|
||||
// function of generic_scheduler.go returns the pod itself for removal of the annotation.
|
||||
// function of generic_scheduler.go returns the pod itself for removal of
|
||||
// the 'NominatedPod' field.
|
||||
for _, p := range nominatedPodsToClear {
|
||||
rErr := sched.config.PodPreemptor.RemoveNominatedNodeName(p)
|
||||
if rErr != nil {
|
||||
klog.Errorf("Cannot remove nominated node annotation of pod: %v", rErr)
|
||||
klog.Errorf("Cannot remove 'NominatedPod' field of pod: %v", rErr)
|
||||
// We do not return as this error is not critical.
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue