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

Webhook warnings #3936

Merged
merged 5 commits into from
May 11, 2021
Merged

Webhook warnings #3936

merged 5 commits into from
May 11, 2021

Conversation

irbekrm
Copy link
Contributor

@irbekrm irbekrm commented Apr 29, 2021

This PR:

See #3220 for additional context.

This is what the warning added by this PR looks like:

Screenshot from 2021-04-29 10-01-47

(The warning text was written with the assumption that we will not actually remove the key algorithm field in cert-manager v1. Else the warning should have included in which version we intend to remove it.)

Validating webhook returns a warning if the legacy ACME issuer EAB key algorithm is set.

@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Apr 29, 2021
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irbekrm

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

@jetstack-bot jetstack-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 29, 2021
@irbekrm
Copy link
Contributor Author

irbekrm commented Apr 29, 2021

These commits used to be a part of #3850 that was later split into smaller PRs.
There was already a review on this bit of functionality from @SgtCoDFish here. I've addressed that by creating a WarningList type rather than just using []string

irbekrm added 3 commits April 29, 2021 11:45
Adds warnings to the top level validating functions' signatures

Signed-off-by: irbekrm <irbekrm@gmail.com>
… is set

Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
@irbekrm
Copy link
Contributor Author

irbekrm commented Apr 29, 2021

/kind cleanup

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Apr 29, 2021
@irbekrm
Copy link
Contributor Author

irbekrm commented Apr 29, 2021

/test pull-cert-manager-e2e-v1-20

@irbekrm
Copy link
Contributor Author

irbekrm commented Apr 29, 2021

The e2e test failures appear to be flakes, it works for me locally

/test pull-cert-manager-e2e-v1-20

@irbekrm irbekrm requested review from wallrj and SgtCoDFish April 29, 2021 13:13
Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

Overall looks good, only a couple of fairly unimportant bits from me.

There could be a case for maybe having ValidateFunc and ValidateUpdateFunc return, say, a ValidationResponse struct. I think that could make a lot of the testing logic cleaner.

That said I really don't think it's necessary - especially since it'd need so many changes and this PR looks like it'll work totally fine as-is.

pkg/api/util/warnings.go Outdated Show resolved Hide resolved
Signed-off-by: irbekrm <irbekrm@gmail.com>
@irbekrm
Copy link
Contributor Author

irbekrm commented Apr 29, 2021

http: TLS handshake error from 127.0.0.1:44286: read tcp 127.0.0.1:44145->127.0.0.1:44286: read: connection reset by peer

test timeout

/test pull-cert-manager-bazel

@irbekrm irbekrm mentioned this pull request Apr 30, 2021
4 tasks
// https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/
const (
// DeprecatedACMEEABKeyAlgorithmField is raised when the deprecated keyAlgorithm field for an ACME issuer's external account binding (EAB) is set.
DeprecatedACMEEABKeyAlgorithmField = "ACME issuer spec field 'externalAccount.keyAlgorithm' is deprecated. The value of this field will be ignored."
Copy link
Member

Choose a reason for hiding this comment

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

This const isn't referenced outside of the pkg/internal/apis/certmanager/validation package. I think it should live in there as an un-exported const (or alternatively just hardcoded as the message in the call-site, which has the side effect of forcing us to write it out explicitly in test cases too, so we know if the message has been changed unintentionally)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that in this case there is no harm in exporting this const and having all the future warnings in the same place would help us with consistency of the wording and naming + make it easier to change the warning text (i.e if we later want to add a version at which this field would be removed).
If anyone was actually parsing these warnings, I'd rather them use the const, then hardcode strings.

Copy link
Member

Choose a reason for hiding this comment

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

My concern is that if we start treating this as an API surface, it makes minor re-wording/edits harder in future (e.g. if we ever want to change this text).

I don't think we'd want to encourage people to parse this text, and it seems like it is harder for us to read the code that's actually emitting these warnings if there's a cross-package reference.

If this is to be exported and parseable, what's the versioning story here?

Copy link
Member

Choose a reason for hiding this comment

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

If this were more akin to the reason field on a condition (i.e. short, all one word, etc) then I'd definitely agree that there's value in having them exported. This seems more akin to the 'message' field on a condition, which is explicitly designed to be human readable.

As far as I'm aware, k8s itself doesn't treat warning messages as part of its API surface and does not advise building automation on top of parsing these strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point about versioning, I didn't think about that.

I guess because these warnings would be returned to whoever applies the yaml (rather than just apearing in the logs), I thought it'd be nice to have them consistently worded, which might be easier achievable if they are all in the same place vs a bunch of hardcoded strings across the codebase.

Copy link
Member

Choose a reason for hiding this comment

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

👍 re consistency - what do you think about just moving them to where they are actually used (unexported to convey they shouldn't be depended upon/parsed), but keeping them as consts for consistencies sake? I just think being in an 'api/' package insinuates it forms part of our API (and thus can be depended upon in a similar manner to other parts of our API)

Copy link
Member

Choose a reason for hiding this comment

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

I think I agree that this could be unexported. There's no reason we couldn't make it exported later if we felt a need for it.

I also think it makes sense to move it to where it's used and remove the new file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments!
I've made the warning value unexported.
I did still put it into a file of its own in the internal validation package because I felt like this might help with the consistency of any future validation warnings that we might want to add- happy to be convinced otherwise.

@SgtCoDFish
Copy link
Member

I think aside from #3936 (comment) this looks good to go. I'm happy to merge after that's been addressed.

Signed-off-by: irbekrm <irbekrm@gmail.com>
@SgtCoDFish
Copy link
Member

/lgtm (pending test completion)

@irbekrm
Copy link
Contributor Author

irbekrm commented May 11, 2021

/lgtm (pending test completion)

Thanks for the review @SgtCoDFish ! I think Prow dislikes any additional characters after /lgtm 😅

@SgtCoDFish
Copy link
Member

/lgtm (pending test completion)

Thanks for the review @SgtCoDFish ! I think Prow dislikes any additional characters after /lgtm sweat_smile

😭 well, I think I dislike prow 😂

/lgtm

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. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants