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

Track executing requests #119009

Merged

Conversation

MikeSpreitzer
Copy link
Member

@MikeSpreitzer MikeSpreitzer commented Jul 1, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR extends API Priority and Fairness to track the individual executing requests and optionally report them through a debug URL.

Which issue(s) this PR fixes:

Fixes #118746

Special notes for your reviewer:

This PR is not done yet, there is an interface design question in #118746 to be resolved first.

This PR builds on #118955 and will be rebased after that one merges.

Does this PR introduce a user-facing change?

The apiserver debug endpoint `/debug/api_priority_and_fairness/dump_requests` has been extended to dump executing requests as well as queued ones.  A column for StartTime has been added to the returned table, with the queued requests having a StartTime of "0001-01-01T00:00:00Z".  The executing requests have a RequestIndexInQueue of -1, and the QueueIndex is also -1 for priority levels without queues.

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


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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. labels Jul 1, 2023
@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 1, 2023
@MikeSpreitzer
Copy link
Member Author

/cc @wojtek-t
@tkashem
/uncc @yue9944882

@k8s-ci-robot k8s-ci-robot requested review from wojtek-t and removed request for yue9944882 July 1, 2023 03:24
@MikeSpreitzer
Copy link
Member Author

@natherz97

@MikeSpreitzer
Copy link
Member Author

/retest

@natherz97
Copy link

Thank you for taking this up! When possible, can you share example output from the new debug command?

@jiahuif
Copy link
Member

jiahuif commented Jul 6, 2023

/assign @wojtek-t @tkashem
/triage accepted

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jul 6, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jul 6, 2023
@MikeSpreitzer
Copy link
Member Author

@natherz97 : I realized that the design is not obvious (to me, anyway) and posted about that in the issue. I am waiting for feedback on #118746 (comment)

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 14, 2023
@MikeSpreitzer
Copy link
Member Author

@natherz97: See the Release Note in the opening comment here. The added column for StartTime is inserted right after the AdditionalLatency column.

@MikeSpreitzer
Copy link
Member Author

The tracking of executing requests in QueueSet is wrong --- the requests are tracked in each queue, but not every QueueSet has queues.
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 14, 2023
@MikeSpreitzer
Copy link
Member Author

Bug fixed.
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2023
@MikeSpreitzer
Copy link
Member Author

@natherz97 : here is an example.

root@ubu2204a:/var/run/kubernetes# kubectl get --raw /debug/api_priority_and_fairness/dump_requests
PriorityLevelName, FlowSchemaName, QueueIndex, RequestIndexInQueue, FlowDistingsher, ArriveTime,                     InitialSeats, FinalSeats, AdditionalLatency, StartTime
exempt,            exempt,         -1,         -1,                  ,                2023-07-15T04:51:25.596404345Z, 1,            0,          0s,                2023-07-15T04:51:25.596404345Z

@natherz97
Copy link

@natherz97 : here is an example.

root@ubu2204a:/var/run/kubernetes# kubectl get --raw /debug/api_priority_and_fairness/dump_requests
PriorityLevelName, FlowSchemaName, QueueIndex, RequestIndexInQueue, FlowDistingsher, ArriveTime,                     InitialSeats, FinalSeats, AdditionalLatency, StartTime
exempt,            exempt,         -1,         -1,                  ,                2023-07-15T04:51:25.596404345Z, 1,            0,          0s,                2023-07-15T04:51:25.596404345Z

@MikeSpreitzer thank you! It also looks like dump_requests supports the includeRequestDetails=1 parameter to provide information like the username, verb, and path?

@MikeSpreitzer
Copy link
Member Author

MikeSpreitzer commented Jul 17, 2023

Yes. I just gave an example of the simpler usage. The columns added by includeRequestDetails=1 are the same as before.

Copy link
Member

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

I have two comments, but overall this looks reasonable to me.

return ans
}

func Curry2of2[T1, T2, Return any](f func(T1, T2) Return, v2 T2) func(T1) Return {
Copy link
Member

Choose a reason for hiding this comment

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

IMHO introducing generic functions if they are used only in a single pattern is an overkill and makes it harder to understand the code (btw the name doesn't really help).

I would much rather prefer to just have:

func dumpRequestsSet(s *sets.Set[*request], includeDetails bool) []RequestDump {
  res := make([]RequestDump, 0, s.Len())
  for elem := range s {
    res = append(res, elem.dump(includeDetails)
  }
}

return ans
}

func OrFuncOverSlice[Elt any](f func(Elt) bool) func([]Elt) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Given it's a function that is used only in the test, can we move it to that test file? I doubt we will ever remember about this function exists here...

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a form of map-reduce, I am sure I will remember that map-reduce exists and that I am tired of writing it over and over.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps it should be

func SliceMapReduce[Elt, Result any](mapFn func(Elt) Result, reduceFn func(Result,Result) Result) func([]Elt) Result {...{

Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>
@MikeSpreitzer
Copy link
Member Author

The force-push to a8a2fb3 removes the currying function and restates the two map-reduce functions in the general form that hopefully makes the hope for more future use clear.

@wojtek-t
Copy link
Member

/lgtm
/approve

Thanks!

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

LGTM label has been added.

Git tree hash: 6d471ceb06c3f0cb48ab112ae624d413bda42f86

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MikeSpreitzer, wojtek-t

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

@k8s-ci-robot k8s-ci-robot merged commit 31d662e into kubernetes:master Jul 18, 2023
12 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone Jul 18, 2023
@MikeSpreitzer MikeSpreitzer deleted the track-executing-requests branch July 21, 2023 01:34
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/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug endpoint to dump currently executing requests
6 participants