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

Factor-out metrics related logic from authentication logic. #87631

Merged
merged 1 commit into from Mar 3, 2020

Conversation

immutableT
Copy link
Contributor

@immutableT immutableT commented Jan 28, 2020

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Improve readability of the filters/authenticator package by extracting metrics' related logic into a separate file.
Cover metrics' related logic by unit tests.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 28, 2020
@immutableT
Copy link
Contributor Author

Reducing the diff of #85113

@immutableT
Copy link
Contributor Author

/assign @timstclair
/assign @awly

@immutableT
Copy link
Contributor Author

/assign @logicalhan

Copy link
Member

@tallclair tallclair left a comment

Choose a reason for hiding this comment

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

Thanks for breaking this out into a separate PR.

// Anything else (custom service accounts, custom external identities, etc.)
default:
return "other"
func audiencesIntersect(apiAuds, responseAudiences authenticator.Audiences) bool {
Copy link
Member

Choose a reason for hiding this comment

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

/cc @mikedanese

To double check security critical change

Copy link
Member

Choose a reason for hiding this comment

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

I agree this preserves the existing logic, but the method name is fairly misleading, since it short-circuits on empty parameters. Consider renaming to audiencesAreAcceptable() or something similar.

As a follow-up, given that (I think) we are now wrapping all audience-agnostic authenticators in ones that know how to return the API server audience in the response, I think we should probably drop the len(responseAudiences) == 0 short-circuit.

Copy link
Contributor Author

@immutableT immutableT Mar 1, 2020

Choose a reason for hiding this comment

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

Renamed to audiencesAreAcceptable.

Will follow-up with a PR to remove the len(responseAudiences) == 0 short-circuit.

@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 29, 2020
@tallclair
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 29, 2020
@immutableT
Copy link
Contributor Author

/test pull-kubernetes-kubemark-e2e-gce-big
/test pull-kubernetes-e2e-gce
/test pull-kubernetes-e2e-gce-100-performance

@immutableT
Copy link
Contributor Author

/assign @liggitt

@immutableT
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce-100-performance

successLabel = "success"
failureLabel = "failure"
errorLabel = "error"
audiencesDoNotIntersectLabel = "non-intersecting-audiences"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would not we want to know about such cases?
See, a comment by @liggitt comment here

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we report it as an error and not as a new result type? This is a pretty old metric, so I don't want to break the semantics even if it's alpha. On top of that, "success"/"failure"/"error" seems like a reasonable breakdown for results and I'm not sure that "non-intersecting-audiences" is distinct enough from "error" to warrant introduction of another state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - now classifying non-intersecting audiences as a failure.

@mikedanese mikedanese added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Feb 21, 2020
@k8s-ci-robot k8s-ci-robot removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Feb 21, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 21, 2020
@mikedanese
Copy link
Member

Verify failure looks real.

@immutableT
Copy link
Contributor Author

/test pull-kubernetes-node-e2e-containerd
/test pull-kubernetes-e2e-gce

@mikedanese
Copy link
Member

/lgtm

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

jtslear commented Feb 28, 2020

Hello @RainbowMango
Bug Triage team here for the 1.18 release. This is a friendly reminder that code freeze is scheduled for 5 March. This PR has been identified as a blocker for #85113 Can we get a review completed on this?

@tallclair
Copy link
Member

/milestone v1.18

@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Feb 29, 2020
@RainbowMango
Copy link
Member

@jtslear Seems @mikedanese want @LiGgit take a look.

@liggitt
Copy link
Member

liggitt commented Feb 29, 2020

a couple comments on method name and logging, one follow-up requested, lgtm otherwise

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 1, 2020
@liggitt
Copy link
Member

liggitt commented Mar 1, 2020

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: immutableT, liggitt, mikedanese

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 Mar 1, 2020
@mikedanese
Copy link
Member

/retest

@tallclair
Copy link
Member

Looks like this is good to go.
/hold cancel

@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 Mar 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit 7dccfd6 into kubernetes:master Mar 3, 2020
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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/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.

None yet

10 participants