Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Preempt tasks with lower priority #894

Closed
mateuszlitwin opened this issue Oct 21, 2019 · 1 comment · Fixed by #895
Closed

Preempt tasks with lower priority #894

mateuszlitwin opened this issue Oct 21, 2019 · 1 comment · Fixed by #895
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@mateuszlitwin
Copy link
Contributor

mateuszlitwin commented Oct 21, 2019

Is this a BUG REPORT or FEATURE REQUEST?:

/kind feature

Description:

You should be able to configure kube-batch, so it preempts tasks of lower priority jobs when higher priority job arrives. Based on the code I read and what I observed on the cluster it looks like there is no way to enforce that. It looks like only gang, drf and conformance provide "preemptable functions".

Possible solution is to add preemptable function to priority plugin:

preemptableFn := func(preemptor *api.TaskInfo, preemptees []*api.TaskInfo) []*api.TaskInfo {
	preemptorJob := ssn.Jobs[preemptor.Job]
	var victims []*api.TaskInfo
	for _, preemptee := range preemptees {
		preempteeJob := ssn.Jobs[preemptee.Job]
		if preempteeJob.Priority >= preemptorJob.Priority {
			glog.V(3).Infof("Can not preempt task <%v/%v> because "+
				"preemptee has greater or equal job priority (%d) than preemptor (%d)",
				preemptee.Namespace, preemptee.Name, preempteeJob.Priority, preemptorJob.Priority)
		} else {
			victims = append(victims, preemptee)
		}
	}
	glog.V(3).Infof("Victims from Priority plugins are %+v", victims)
	return victims
}
ssn.AddPreemptableFn(pp.Name(), preemptableFn)

Let me know if this make sense.

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 21, 2019
@mateuszlitwin mateuszlitwin changed the title Preempt only tasks with lower priority Preempt tasks with lower priority Oct 21, 2019
@k82cn
Copy link
Contributor

k82cn commented Oct 23, 2019

yes, that makes sense to me :)

mateuszlitwin added a commit to mateuszlitwin/kube-batch that referenced this issue Oct 23, 2019
Priority plugin now adds preemptable function which makes preemptee a victim iff job priority of the preemptee is strictly lower than job priority of the preemptor.

This is consistent with default behavior of the standard kubernetes scheduler: if a Pod cannot be scheduled, the scheduler tries to preempt (evict) lower priority Pods to make scheduling of the pending Pod possible (see https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/).

Closes kubernetes-retired#894
mateuszlitwin added a commit to mateuszlitwin/kube-batch that referenced this issue Oct 23, 2019
Priority plugin now adds preemptable function which makes preemptee a victim iff job priority of the preemptee is strictly lower than job priority of the preemptor.

This is consistent with default behavior of the standard kubernetes scheduler: if a Pod cannot be scheduled, the scheduler tries to preempt (evict) lower priority Pods to make scheduling of the pending Pod possible (see https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/).

Closes kubernetes-retired#894
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants