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

⚠️ feat: new features about support warning with webhook #2014

Merged
merged 13 commits into from
Apr 19, 2023

Conversation

STRRL
Copy link
Contributor

@STRRL STRRL commented Sep 29, 2022

Signed-off-by: STRRL im@strrl.dev

close #1896

Two new interfaces ValidatorWarn and CustomValidatorWarn, for support warnings in validating webhooks.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 29, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @STRRL. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 29, 2022
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 29, 2022
Copy link
Member

@invidian invidian 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 your PR @STRRL!

I'm not familiar enough with project conventions to provide detailed feedback. From the library user perspective, one e2e test would be nice, with a code example how errors can be created, but I don't know if there are facilities prepared to have something like this and it's perhaps out of scope for this PR.

Overall it looks OK. Unfortunately, I don't have resources to test with with CABPK at the moment to verify e2e that the warnings produced are nicely showed by kubectl.

pkg/webhook/admission/validator_warn.go Outdated Show resolved Hide resolved
@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 1, 2022
@camilamacedo86
Copy link
Member

/test pull-controller-runtime-test-master

@STRRL STRRL force-pushed the webhook-warning branch 2 times, most recently from 6f227af to f246cc3 Compare November 3, 2022 04:24
@STRRL
Copy link
Contributor Author

STRRL commented Nov 3, 2022

happy to see new progress on this PR; I have fixed the test cases and linter :)

PTAL @camilamacedo86

@joelanford
Copy link
Member

Would this implementation effectively supersede the existing high-level validator interfaces? At first glance, it seems like it has identical functionality except that it can also return warnings?

I worry about maintaining both (almost identical) implementations over time.

I commented over on the issue, but I think we could use the existing interfaces and have a custom error type that includes the warnings like you suggest.

@sbueringer
Copy link
Member

sbueringer commented Nov 25, 2022

I worry about maintaining both (almost identical) implementations over time.
I commented over on the issue, but I think we could use the existing interfaces and have a custom error type that includes the warnings like you suggest.

I agree. We should definitely avoid introducing a third set of interfaces. I'll continue on the issue. Let's keep the discussion there for now to avoid concurrent threads.

@STRRL
Copy link
Contributor Author

STRRL commented Dec 5, 2022

just mention the discussion result: we prefer to break the API instead of introducing a new type called ErrorWithWarnings, ref: #1896 (comment)

@STRRL STRRL requested review from invidian and sbueringer and removed request for sbueringer, varshaprasad96 and invidian December 5, 2022 13:12
@STRRL
Copy link
Contributor Author

STRRL commented Dec 5, 2022

Hi! I have updated this PR with these changes:

  • stop using goerrors "errors" in import
  • move error as the last value returned by methods, eg. ValidateCreate() ( err error, warnings []string) -> ValidateCreate() (warnings []string, err error)

@STRRL
Copy link
Contributor Author

STRRL commented Dec 5, 2022

Hi! I have updated this PR with these changes:

  • stop using goerrors "errors" in import
  • move error as the last value returned by methods, eg. ValidateCreate() ( err error, warnings []string) -> ValidateCreate() (warnings []string, err error)

/cc @invidian @sbueringer

@sbueringer
Copy link
Member

Thx sorry for the late response, will review soon

@k8s-ci-robot
Copy link
Contributor

@STRRL: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-controller-runtime-apidiff b2a9552 link false /test pull-controller-runtime-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@sbueringer
Copy link
Member

Looks good thx!

@STRRL can you please squash the commits?

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 17, 2023
@sbueringer
Copy link
Member

/assign @vincepri

@vincepri
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: STRRL, vincepri

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 Apr 19, 2023
@vincepri
Copy link
Member

/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 Apr 19, 2023
@k8s-ci-robot k8s-ci-robot merged commit 1c2a7c9 into kubernetes-sigs:main Apr 19, 2023
ChunyiLyu added a commit to rabbitmq/messaging-topology-operator that referenced this pull request May 30, 2023
- controller runtime v0.15 contains breaking changes where
Validator interfaces have been modified to include warning
in return types: kubernetes-sigs/controller-runtime#2014
other breaking changes do not affect us
ChunyiLyu added a commit to rabbitmq/messaging-topology-operator that referenced this pull request May 31, 2023
- controller runtime v0.15 contains breaking changes where
Validator interfaces have been modified to include warning
in return types: kubernetes-sigs/controller-runtime#2014
other breaking changes do not affect us
lyarwood added a commit to lyarwood/ssp-operator that referenced this pull request Jun 26, 2023
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.15.0

* Make `*http.Client` configurable and use/share the same client by
  default kubernetes-sigs/controller-runtime#2122

* Remove dependency injection functions
  kubernetes-sigs/controller-runtime#2134,
  kubernetes-sigs/controller-runtime#2120

* Add context to EventHandler(s)
  kubernetes-sigs/controller-runtime#2139

* `Validator` and `CustomValidator` interfaces have been modified to
  allow returning warnings
  kubernetes-sigs/controller-runtime#2014

* operator-framework is also pinned to ecb9be48837 until a new release
  is cut supporting controller-runtime v0.15.0

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
ary1992 added a commit to ary1992/gardener that referenced this pull request Jun 28, 2023
lyarwood added a commit to lyarwood/ssp-operator that referenced this pull request Jun 28, 2023
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.15.0

* Make `*http.Client` configurable and use/share the same client by
  default kubernetes-sigs/controller-runtime#2122

* Remove dependency injection functions
  kubernetes-sigs/controller-runtime#2134,
  kubernetes-sigs/controller-runtime#2120

* Add context to EventHandler(s)
  kubernetes-sigs/controller-runtime#2139

* `Validator` and `CustomValidator` interfaces have been modified to
  allow returning warnings
  kubernetes-sigs/controller-runtime#2014

* operator-framework is also pinned to ecb9be48837 until a new release
  is cut supporting controller-runtime v0.15.0

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
lyarwood added a commit to lyarwood/ssp-operator that referenced this pull request Aug 9, 2023
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.15.0

* Make `*http.Client` configurable and use/share the same client by
  default kubernetes-sigs/controller-runtime#2122

* Remove dependency injection functions
  kubernetes-sigs/controller-runtime#2134,
  kubernetes-sigs/controller-runtime#2120

* Add context to EventHandler(s)
  kubernetes-sigs/controller-runtime#2139

* `Validator` and `CustomValidator` interfaces have been modified to
  allow returning warnings
  kubernetes-sigs/controller-runtime#2014

* operator-framework is also pinned to ecb9be48837 until a new release
  is cut supporting controller-runtime v0.15.0

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
@STRRL STRRL deleted the webhook-warning branch October 14, 2024 16:24
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

[Feature Request]: Support "Warning" for Validation Webhook