Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Preemption Toleration Plugin Implementation and Tests #2

Closed

Conversation

everpeace
Copy link
Owner

@everpeace everpeace commented Jun 24, 2021

This PR is a PoC implementation of "Preemption Toleration" plugin proposed in (kubernetes-sigs#205).

Many code is borrowed from default preemption plugin in kube-scheduler because this plugin requires almost identical logics with this but most of them are not exposed. I believe kubernetes/kubernetes#95131 resolves it.

@everpeace everpeace force-pushed the preemption-toleration-kep branch 2 times, most recently from fcc90e3 to 3465f9a Compare June 24, 2021 11:20
@everpeace everpeace force-pushed the preemption-toleration-impl branch from 755bf93 to 8b4b6b8 Compare June 24, 2021 11:29
@everpeace everpeace force-pushed the preemption-toleration-kep branch 2 times, most recently from 1820505 to 599614e Compare June 24, 2021 11:47
@everpeace everpeace force-pushed the preemption-toleration-impl branch from 8b4b6b8 to 245aa60 Compare June 24, 2021 11:48
@everpeace everpeace force-pushed the preemption-toleration-kep branch from 599614e to 63b20e7 Compare June 24, 2021 11:51
@everpeace everpeace force-pushed the preemption-toleration-impl branch from 245aa60 to 4a029e0 Compare June 24, 2021 11:51
@everpeace everpeace changed the title POC: Preemption Toleration Implementation POC: Preemption Toleration Plugin Implementation and Tests Jun 24, 2021
Copy link
Collaborator

@ordovicia ordovicia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall design looks good. I left some comments on implementation details.

}

// check it can tolerate the preemption in terms of priority value
canTolerateOnPriorityValue := preemptorPriority < *pt.MinimumPreemptablePriority
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pt can be nil when the priority class does not have the toleration policy annotation.

// check it can tolerate the preemption in terms of toleration seconds
_, scheduledCondition := podutil.GetPodCondition(&victimCandidate.Status, v1.PodScheduled)
if scheduledCondition == nil {
// if victim is not scheduled, skip evaluating tolerationSeconds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what case a pod becomes a victim candidate even though it has not been scheduled yet?

Copy link
Owner Author

@everpeace everpeace Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood that nominated pods would be passed here. It should not happen here. But I would like to keep this guard. So, I will just delete the comment. Thanks for the catch.

if tt.canTolerate {
// - the victim candidate pod keeps being scheduled, and
// - the preemptor pod is not scheduled
if err := wait.Poll(1*time.Second, 30*time.Second, func() (bool, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait.Poll() returns immediately once the given condition function returns true, but here we should assert that the function continuously returns true for some seconds instead.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I will fix this gomega's Consistently like assertion.

@everpeace
Copy link
Owner Author

@ordovicia @shioshiota I fixed things commented. PTAL.

Copy link
Collaborator

@shioshiota shioshiota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@everpeace everpeace force-pushed the preemption-toleration-impl branch from c1d51fa to a5cf119 Compare June 30, 2021 06:54
@everpeace
Copy link
Owner Author

squashed.

@everpeace everpeace force-pushed the preemption-toleration-impl branch 2 times, most recently from 4582a67 to b97edf6 Compare July 8, 2021 14:10
@shioshiota shioshiota self-requested a review July 9, 2021 10:47
Copy link
Collaborator

@shioshiota shioshiota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I found an issue with handling a preemption policy.
Could you check it?

Copy link
Collaborator

@shioshiota shioshiota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment was wrong. I approve of this again.

@everpeace everpeace force-pushed the preemption-toleration-kep branch 3 times, most recently from f8042eb to cd1f519 Compare August 4, 2021 05:22
@everpeace everpeace force-pushed the preemption-toleration-kep branch 4 times, most recently from 4fae905 to aa22f0c Compare August 5, 2021 01:22
@everpeace everpeace force-pushed the preemption-toleration-impl branch from b97edf6 to 66a6703 Compare August 6, 2021 04:46
@everpeace everpeace closed this Aug 7, 2021
@everpeace everpeace deleted the preemption-toleration-impl branch August 7, 2021 13:26
@everpeace
Copy link
Owner Author

everpeace commented Aug 7, 2021

I close this PR and delete the preemption-toleration-impl branch because the branch name will be used for upstream PR. The poc is preserved at preemption-toleration-impl-poc branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants