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

apf: ensure exempt request is noted with classification #106827

Merged
merged 1 commit into from
Dec 11, 2021

Conversation

tkashem
Copy link
Contributor

@tkashem tkashem commented Dec 5, 2021

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?

NONE

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


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. labels Dec 5, 2021
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 5, 2021
// 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, "")
Copy link
Contributor Author

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.

Copy link
Member

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.

@tkashem
Copy link
Contributor Author

tkashem commented Dec 5, 2021

/retest

@MikeSpreitzer
Copy link
Member

/assign

@fedebongio
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 7, 2021
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 8, 2021
@tkashem tkashem force-pushed the apf-exempt-note branch 3 times, most recently from 01a0ce4 to f8640d5 Compare December 8, 2021 23:08
@tkashem
Copy link
Contributor Author

tkashem commented Dec 8, 2021

/test pull-kubernetes-conformance-kind-ga-only-parallel

@tkashem
Copy link
Contributor Author

tkashem commented Dec 9, 2021

/test pull-kubernetes-e2e-kind

@tkashem
Copy link
Contributor Author

tkashem commented Dec 9, 2021

@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
Copy link
Member

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,
Copy link
Member

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).

@tkashem tkashem force-pushed the apf-exempt-note branch 2 times, most recently from df834fc to 5eaa00a Compare December 10, 2021 15:07
Copy link
Member

@MikeSpreitzer MikeSpreitzer left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 10, 2021
@tkashem
Copy link
Contributor Author

tkashem commented Dec 10, 2021

/assign @wojtek-t

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 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))
Copy link
Member

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.

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, i agree with that. replaced it with logging an error and falling back to empty string

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 10, 2021
@wojtek-t
Copy link
Member

/lgtm
/approve

/retest

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

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2021
@tkashem
Copy link
Contributor Author

tkashem commented Dec 10, 2021

/test pull-kubernetes-e2e-kind-ipv6

@tkashem
Copy link
Contributor Author

tkashem commented Dec 10, 2021

/test pull-kubernetes-integration

@k8s-triage-robot
Copy link

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:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@k8s-ci-robot k8s-ci-robot merged commit 0ae6ef6 into kubernetes:master Dec 11, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Dec 11, 2021
k8s-ci-robot added a commit that referenced this pull request Jan 3, 2022
…827-upstream-release-1.23

Automated cherry pick of #106827: apf: ensure exempt request notes the classification
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/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. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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
None yet
Development

Successfully merging this pull request may close these issues.

apf: exempt request does not note flowschema and prioritylevelconfiguration in the response header
6 participants