-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
apf: ensure exempt request is noted with classification #106827
Conversation
// TODO: this is a quick and dirty fix. workEstimator does two things, it estimates work | ||
// and also notes the classification of the request. work estimation is not applicable to | ||
// an exempt request, only noting is. | ||
workEstimator(selectedFlowSchema, plState.pl, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MikeSpreitzer I can change Handle
to take these separately:
Handle(ctx context.Context,
requestDigest RequestDigest,
noteFn func(fs *flowcontrol.FlowSchema, pl *flowcontrol.PriorityLevelConfiguration, flowDistinguisher string),
workEstimator func() fcrequest.WorkEstimate
...
Let me know if this okay with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkashem : If I understand your suggestion correctly, you are agreeing with #106826 (comment) and proposing to replace the one function parameter of Handle that both consumes the classification and does the work estimation with two function parameters that separate those two jobs. If so then I agree.
/retest |
/assign |
/triage accepted |
a7ab2a5
to
2d86f42
Compare
01a0ce4
to
f8640d5
Compare
/test pull-kubernetes-conformance-kind-ga-only-parallel |
/test pull-kubernetes-e2e-kind |
@MikeSpreitzer it's ready for another pass |
// characterized by the given digest. The given `noteFn` will be | ||
// invoked with the results of request classification. | ||
// The given `workEstimator` will be invoked if the | ||
// request is not classified as 'exempt' and it must |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word "it" refers to the most recent noun phrase, which in this case is "the request" --- but that is not what you mean. Strike the word "it" here.
@@ -55,7 +57,8 @@ type Interface interface { | |||
// ctx is cancelled or times out. | |||
Handle(ctx context.Context, | |||
requestDigest RequestDigest, | |||
workEstimator func(fs *flowcontrol.FlowSchema, pl *flowcontrol.PriorityLevelConfiguration, flowDistinguisher string) fcrequest.WorkEstimate, | |||
noteFn func(fs *flowcontrol.FlowSchema, pl *flowcontrol.PriorityLevelConfiguration, flowDistinguisher string), | |||
workEstimator func(flowSchemaName, priorityLevelName string) fcrequest.WorkEstimate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend removing the parameters from the workEstimator
so that there is no possibility of inconsistency between the values given to workEstimator
and those given to noteFn
. Also, explicitly document that workEstimator
is called, if at all, after noteFn
(so that the client knows how to get the needed names).
f8640d5
to
4e9294e
Compare
df834fc
to
5eaa00a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/assign @wojtek-t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one comment
if classification == nil { | ||
// workEstimator is being invoked before classification of | ||
// the request has completed, we should never be here though. | ||
panic(fmt.Sprintf("workEstimator is being invoked before classification of the request has completed, verb: %s, URI: %s", r.Method, r.RequestURI)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't panic.
Let's log an error, return an error or sth.
I really prefer to have bad estimate or fail an individual request than to fire a panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i agree with that. replaced it with logging an error and falling back to empty string
5eaa00a
to
8b2dd74
Compare
/lgtm /retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MikeSpreitzer, tkashem, 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 |
/test pull-kubernetes-e2e-kind-ipv6 |
/test pull-kubernetes-integration |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
…827-upstream-release-1.23 Automated cherry pick of #106827: apf: ensure exempt request notes the classification
What type of PR is this?
/kind bug
What this PR does / why we need it:
apf: ensure that exempt request notes the classification in the response headers and httplog
Which issue(s) this PR fixes:
Fixes #106826
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: