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

Filter gated pods before calling isPodWorthRequeueing #124618

Merged
merged 4 commits into from
May 9, 2024

Conversation

gabesaba
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

When there are many gated pods and many events which trigger requeueing from the unschedulable pool (e.g. deletePodFromCache) , we observe increased scheduling latency. We mitigate this issue by exiting before hitting the hotspots identified in #124384.

Which issue(s) this PR fixes:

Fixes #124384

/sig scheduling

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Improved scheduling latency when many gated pods

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. labels Apr 29, 2024
@k8s-ci-robot k8s-ci-robot added area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/testing Categorizes an issue or PR as relevant to SIG Testing. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @gabesaba!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @gabesaba. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 29, 2024
@alculquicondor
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 29, 2024
@@ -2677,7 +2677,7 @@ func TestSchedulingGatesPluginEventsToRegister(t *testing.T) {
{
name: "preEnqueue plugin with event registered",
enqueuePlugin: &SchedulingGatesPluginWithEvents{SchedulingGates: schedulinggates.SchedulingGates{}},
count: 3,
count: 2,
Copy link
Member

Choose a reason for hiding this comment

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

@kerthcet you added this test. Do you think it still makes sense to keep?
Or should we be testing it a different way?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I was on vacation last week.

I think we can replace the schedulingGate plugin with other plugin simply, we can leave this as a follow up since we're considering cherrypick. If no one has context, I can do this later.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good, let's leave it for a follow up.

@alculquicondor
Copy link
Member

@sanposhiho do you want to give it a pass?

Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

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

Overall LGTM.
But, can we move TestGatedPodSchedulableAfterEvent and Test_queuedPodInfo_gatedSetUponCreationAndUnsetUponUpdate in a different PR? I cannot relate them to the core change.

@alculquicondor
Copy link
Member

But, can we move TestGatedPodSchedulableAfterEvent and Test_queuedPodInfo_gatedSetUponCreationAndUnsetUponUpdate in a different PR? I cannot relate them to the core change.

I asked for a change of this nature. Since we are changing how we are processing gated pods, I wanted to make sure they are still scheduled after a delete event for a different pod.

@sanposhiho
Copy link
Member

TestGatedPodSchedulableAfterEvent is ok then, but Test_queuedPodInfo_gatedSetUponCreationAndUnsetUponUpdate doesn't go thru any changed part at all.

// unschedulable pool, we skip calling the expensive isPodWorthRequeueing.
if pInfo.Gated {
continue
}
schedulingHint := p.isPodWorthRequeuing(logger, pInfo, event, oldObj, newObj)
Copy link
Member

Choose a reason for hiding this comment

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

How was the gated status checked before? Can we remove that check to avoid confusion with the new check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was done in isPodWorthRequeueing. There is no specific logic for gated, but rather general logic for unschedulable/pending plugins

Copy link
Member

Choose a reason for hiding this comment

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

was that by calling the PreEnqueue plugin?

@Huang-Wei, any concern with just using the .Gated field directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the PreEnqueue plugin. That's why I added this #124669 unit test alongside this change, to ensure that the plugin and the field stay in sync as we will now rely on derived field.

Copy link
Member

Choose a reason for hiding this comment

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

@Huang-Wei, any concern with just using the .Gated field directly?

No concern on my side. .gated is a field to store the state of calling all PreEnqueue plugins on the pod - mostly prior to adding the pod to activeQ.

@alculquicondor
Copy link
Member

alculquicondor commented May 1, 2024

Right, it can be added in a separate PR, so that it's not part of the cherry-pick.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit db82fd1 into kubernetes:master May 9, 2024
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.31 milestone May 9, 2024
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Minor changes to make integ tests compatable with 1.29:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - verify pods scheduled, rather than call ScheduleOne
 - remove PodsInActiveQ check, as not public interface
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Minor changes to make integ tests compatable with 1.29:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - remove PodsInActiveQ check, as not public interface
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Changes to make integ tests compatable with 1.29:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - Replace PodsInActiveQ check with PodSchedulingGated
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Changes to make integ tests compatable with 1.28:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - Replace PodsInActiveQ check with PodSchedulingGated
 - use wait.Poll rather than wait.PollUntilContextTimeout
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Changes to make integ tests compatable with 1.27:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - Replace PodsInActiveQ check with PodSchedulingGated
 - use wait.Poll rather than wait.PollUntilContextTimeout
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Changes to make integ tests compatable with 1.28:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - Replace PodsInActiveQ check with PodSchedulingGated
 - use wait.Poll rather than wait.PollUntilContextTimeout
 - update scheduling_queue_test type
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 13, 2024
Changes to make integ tests compatable with 1.29:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - Replace PodsInActiveQ check with PodSchedulingGated
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 14, 2024
Changes to make integ tests compatable with 1.28:
 - omit rename of "want" to "schedule" to reduce diff
 - call Scheduler.Run(), as ScheduleOne is not public interface
 - only verify pods scheduled; don't call ScheduleOne
 - Replace PodsInActiveQ check with PodSchedulingGated
 - update scheduling_queue_test type
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 14, 2024
gabesaba added a commit to gabesaba/kubernetes that referenced this pull request May 14, 2024
@gabesaba gabesaba deleted the gated_performance branch May 16, 2024 08:06
k8s-ci-robot added a commit that referenced this pull request Jun 4, 2024
k8s-ci-robot added a commit that referenced this pull request Jun 4, 2024
k8s-ci-robot added a commit that referenced this pull request Jun 4, 2024
k8s-ci-robot added a commit that referenced this pull request Jun 4, 2024
pohly added a commit to pohly/kubernetes that referenced this pull request Jun 15, 2024
pohly added a commit to pohly/kubernetes that referenced this pull request Jun 15, 2024
…ing"

The main part of PR kubernetes#124618 was
adding this if check:

pkg/scheduler/internal/queue/scheduling_queue.go:

    movePodsToActiveOrBackoffQueue

         if pInfo.Gated {
              continue
         }

This was supposed to shortcut expensive work. But if a pod is gated because a
plugin's PreEnqueue return false, then the event that caused
movePodsToActiveOrBackoffQueue to be called must not be ignored for the
pod. PreEnqueue has to be called for the pod again to check whether it is
now scheduleable.

This affects DRA when using claim templates. This is independent from using
classic DRA or structured parameters, in both cases a pod gets created, then
the claim, and pod scheduling can only start once the claim exists.

Depending on timing, the scheduler sees the pod update (because the claim name
is recorded in status) or the claim add first. If it first sees the pod update,
the pod gets stuck because the claim is still unknown. Then when the claim add
event is processed, the pod gets skipped because of the check above and remains
stuck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scheduler throughput reduced when many gated pods
7 participants