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

⚠️ Remove pkg/inject #2134

Merged

Conversation

vincepri
Copy link
Member

This changeset brings in a few more breaking changes to remove the rest of the dependency injection code.

The webhook code is now a bit simplified and more explicit in accepting a *runtime.Scheme. The logger is now also not configured in the Standalone mode. We should revisit in a future PR the webhook standalone configuration, and potentially always require a manager. From a quick look in GitHub projects, it seems most folks don't actually use these standalone webhooks, which makes sense because the Manager makes things easier, although there might be private code that's using them.

The config loader was using InjectScheme before, although it really didn't need to.

Signed-off-by: Vince Prignano [email protected]

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 18, 2023
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 18, 2023
@vincepri
Copy link
Member Author

/assign @alvaroaleman @sbueringer

@sbueringer
Copy link
Member

sbueringer commented Jan 19, 2023

We should revisit in a future PR the webhook standalone configuration, and potentially always require a manager. From a quick look in GitHub projects, it seems most folks don't actually use these standalone webhooks, which makes sense because the Manager makes things easier, although there might be private code that's using them.

We are using a standalone webhook server at the moment in CAPI Runtime Extensions: https://github.com/kubernetes-sigs/cluster-api/blob/b6e824c92c4c0d85050b9dc09ba99ca23b238f7a/test/extension/main.go#L141

But we probably should switch to using a manager anyway as it gives us a few more useful features.
(cc @fabriziopandini @killianmuldoon)

EDIT: Hm looks like we would probably (?) not actually be affected. We are not using the handlers with StandaloneWebhook, just the webhook.Server standalone without a manager.

@vincepri vincepri force-pushed the remove-webhook-config-depinject branch 9 times, most recently from 2493b39 to 6a9b719 Compare January 20, 2023 17:38
examples/builtins/mutatingwebhook.go Show resolved Hide resolved
examples/tokenreview/tokenreview.go Outdated Show resolved Hide resolved
pkg/builder/example_test.go Show resolved Hide resolved
pkg/webhook/conversion/decoder.go Show resolved Hide resolved
// Note that this assumes and requires a valid TLS
// cert and key at the default locations
// tls.crt and tls.key.
func ExampleServer_StartStandalone() {
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for removing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

StandaloneServer here makes it more difficult to support the Webhook code long term, looking at grep.app this code is not used on publicly available code at least. The Standalone seems it was added to use webhooks outside of a Manager, but really lots of things from the manager are then required (like scheme, or client).

Going forward, we should try to make the Manager as slim as possible, and require it explicitly

Copy link
Member

Choose a reason for hiding this comment

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

grep.app only indexes the N most popluar repos, so it is somewhat useless when finding usages in potentially non-popular repos. Trough cs.github.com I can find for example these usages:

So it does seem to be used.

but really lots of things from the manager are then required (like scheme, or client).

Both of these can be constructed just fine without a manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted, thanks!

Copy link
Member

Choose a reason for hiding this comment

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

You commented that you reverted this but its still being removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

The StartStandalone part isn't necessary now, the scheme is neither used or injected, webhook.Start should work here

@vincepri vincepri force-pushed the remove-webhook-config-depinject branch 6 times, most recently from 9c26a1d to 0d72871 Compare January 20, 2023 20:18
examples/builtins/main.go Show resolved Hide resolved
// Note that this assumes and requires a valid TLS
// cert and key at the default locations
// tls.crt and tls.key.
func ExampleServer_StartStandalone() {
Copy link
Member

Choose a reason for hiding this comment

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

You commented that you reverted this but its still being removed?

Signed-off-by: Vince Prignano <[email protected]>
@vincepri vincepri force-pushed the remove-webhook-config-depinject branch from 0d72871 to 927c09e Compare January 20, 2023 21:38
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 20, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, 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:
  • OWNERS [alvaroaleman,vincepri]

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 merged commit 35b47fc into kubernetes-sigs:master Jan 20, 2023
@terinjokes
Copy link
Contributor

It seems like this will be a breaking change for implementers of Reconciler without a deprecation window. The documentation previously stated the injection package was deprecated, not the injection mechanism.

@vincepri
Copy link
Member Author

@terinjokes These packages have been deprecated since 0.10 and should have been removed but never did. The release notes will reflect these changes.

@terinjokes
Copy link
Contributor

Just providing feedback that deprecation notices in the future should be very clear about what they apply to. The packages are deprecated with a notice, sure, but that could have been intepreted as "don't import this package for these interfaces, just implement them" rather then "the entire documented injection system is going away".

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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
diranged added a commit to diranged/oz that referenced this pull request Aug 16, 2023
Closes #167.

In #151 we updated some libraries and
we missed the fact that
kubernetes-sigs/controller-runtime#2134 removed
the `InjectDecoder` call entirely. This PR implements a live test of the
`CONNECT` functionality, as well as fixes for the decoder.
aleskandro added a commit to aleskandro/multiarch-operator that referenced this pull request Sep 7, 2023
The InjectDecoder method is now deprecated and the dependency injection is not performed anymore to inject the decoder. This commit setup the decoder during the first call to the Handle method.

See kubernetes-sigs/controller-runtime#2134
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants