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

Unset gated podinfo InitialAttemptTimestamp in addToActiveQ #118049

Merged

Conversation

helayoty
Copy link
Member

@helayoty helayoty commented May 16, 2023

  • Unset podInfo InitialAttemptTimestamp to exclude the preEnqueue failure time from the pod_scheduling_duration_seconds metric.
  • Use a pointer to an InitialAttemptTimestamp.
  • Add a new case for the TestPerPodSchedulingMetrics unit test

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #117979

Special notes for your reviewer:

Does this PR introduce a user-facing change?

the `pod_scheduling_duration_seconds` metrics won't consider the time when a Pod fails PreEnqueue (like being gated). 

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

@helayoty helayoty added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label May 16, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 16, 2023
@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 May 16, 2023
@helayoty
Copy link
Member Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label May 16, 2023
@helayoty helayoty force-pushed the sched-queue-gated-timestamp branch from 3ea2543 to 8d1849b Compare May 16, 2023 18:35
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 16, 2023
@helayoty helayoty force-pushed the sched-queue-gated-timestamp branch from 8d1849b to 46687c3 Compare May 16, 2023 18:37
@helayoty
Copy link
Member Author

/retest

@alculquicondor
Copy link
Member

I'll leave this review to @Huang-Wei

@helayoty
Copy link
Member Author

/test pull-kubernetes-verify

@helayoty helayoty requested a review from Huang-Wei May 16, 2023 21:18
@helayoty helayoty requested a review from Huang-Wei May 16, 2023 21:55
@Huang-Wei
Copy link
Member

@helayoty the latest logic looks good, it's just some UTs may have assumed Timestamp/InitialAttemptTimestamp in another way, so may need to adapt those UTs.

@helayoty
Copy link
Member Author

helayoty commented May 16, 2023

@helayoty the latest logic looks good, it's just some UTs may have assumed Timestamp/InitialAttemptTimestamp in another way, so may need to adapt those UTs.

@Huang-Wei , This UT doesn’t make sense with the change as it tests that the InitialAttemptTimestamp is not changed with a different number of attempts while it will change now. Should we remove it? Or reverse the logic to make sure it fails if it didn't change?

@Huang-Wei
Copy link
Member

@Huang-Wei , This UT doesn’t make sense with the change as it tests that the InitialAttemptTimestamp is not changed with a different number of attempts while it will change now. Should we remove it? Or reverse the logic to make sure it fails if it didn't change?

I'm wondering if it's possible to leverage help a fakeClock? Like, initialize the podInfo with a fakeClock to ensure the time is the same when it's created and firstly time added to activeQ, and then step() when it needs to do another attempt or movement.

@helayoty helayoty changed the title Unset gated pod info timestamp in addToActiveQ Unset gated podinfo InitialAttemptTimestamp in addToActiveQ May 18, 2023
Copy link
Member

@Huang-Wei Huang-Wei left a comment

Choose a reason for hiding this comment

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

LGTM. Would you mind squashing the commits?

And could you fill the release note section? as it changes how pod_scheduling_duration_seconds is calculated.

cc @sanposhiho for awareness.

@Huang-Wei
Copy link
Member

Yes I've reached out to Heba offline. Let's hold this pr for now.

@helayoty helayoty removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 24, 2023
@Huang-Wei
Copy link
Member

Per discussion in https://github.com/kubernetes/enhancements/pull/4065/files#r1231487092, we reached a concensus to change the semantics of pod_scheduling_duration_seconds to exclude PreEnqueue by default, and then cherrypick the changes along with a few follow-ups.

/lgtm
/approve

cc @alculquicondor

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 20, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: dd97b62bc824836afb219596dc1aecaa2efbb811

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 20, 2023
Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

/approve

@@ -1870,6 +1870,38 @@ func TestPerPodSchedulingMetrics(t *testing.T) {
t.Fatalf("Failed to pop a pod %v", err)
}
checkPerPodSchedulingMetrics("Attempt twice with update", t, pInfo, 2, timestamp)

// Case 4: A gated pod is created and scheduled after lifting gate. The queue operations are
Copy link
Member

Choose a reason for hiding this comment

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

We should be using a test table for these cases or split into separate test functions. That should make tests easier to debug in the future.

This is beyond the scope of this PR, but please consider working on this after this has been merged and cherry-picked.

Although, I would prefer this new test goes into a separate function in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

we do have some test code not following the table-driven test style. it can be followed-up with other tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree to follow the table-driven test style. I didn't want to have an out-of-scope change in this PR. I will follow up with another PR to address this comment.

pkg/scheduler/internal/queue/scheduling_queue_test.go Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, helayoty, Huang-Wei

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Huang-Wei
Copy link
Member

@helayoty could you squash the commits, and it will be ease cherrypicking.

@helayoty helayoty force-pushed the sched-queue-gated-timestamp branch from 3a314ba to 4e01556 Compare June 21, 2023 20:36
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 21, 2023
@helayoty helayoty force-pushed the sched-queue-gated-timestamp branch from 4e01556 to fb973f6 Compare June 21, 2023 20:42
@helayoty
Copy link
Member Author

@helayoty could you squash the commits, and it will be ease cherrypicking.

@Huang-Wei Done.

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
@helayoty helayoty force-pushed the sched-queue-gated-timestamp branch from 63974a0 to 902c711 Compare June 21, 2023 21:16
@Huang-Wei
Copy link
Member

/lgtm

And feel free to /unhold when the CIs are all green.

Thanks @helayoty . Sorry for the discussion back and forth, but I think it helps clarify the overall picture.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 21, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 20b865fd72eb4874a6fa5bc36e1be9558181870e

@helayoty
Copy link
Member Author

/retest

@helayoty helayoty removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 21, 2023
@Huang-Wei
Copy link
Member

/unhold

@k8s-ci-robot k8s-ci-robot merged commit d0accc3 into kubernetes:master Jun 22, 2023
12 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone Jun 22, 2023
@helayoty helayoty deleted the sched-queue-gated-timestamp branch June 22, 2023 01:03
@alculquicondor
Copy link
Member

Can you prepare a cherry-pick for the release-1.27 branch?

k8s-ci-robot added a commit that referenced this pull request Jun 23, 2023
…8049-upstream-release-1.27

Automated cherry pick of #118049: Unset gated pod info timestamp in addToActiveQ
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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

pod_scheduling_durating_seconds includes the time a Pod fails PreEnqueue
4 participants