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

[chore] Refactor Webhooks to their own packages #2210

Merged
merged 18 commits into from
Oct 17, 2023

Conversation

jaronoff97
Copy link
Contributor

Description:
This PR updates how webhooks are created and managed by the operator by moving them out of types and into an internal package. In the future this will let us add more complex logic to the webhooks, but for now this mostly is a no-op. One benefit for instrumentation webhooks is that we no longer need to add the annotations to the resource for defaulting because we can add a config field to the instrumentation webhook. All tests have been moved over and replaced with the actual webhooks.

Link to tracking Issue: n/a

Testing: tested locally.

Documentation: n/a

@jaronoff97 jaronoff97 requested a review from a team October 11, 2023 16:48
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The order of these is reversing, but is a noop AFAICT

if inst.Spec.Nginx.Image == autoInstNginx {
inst.Spec.Nginx.Image = u.DefaultAutoInstNginx
inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNginx] = u.DefaultAutoInstNginx
func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instrumentation) *v1alpha1.Instrumentation {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the previous way was really annoying me. If anyone has problems with this, i am happy to revert it.

Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -10,9 +10,9 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /mutate-opentelemetry-io-v1alpha1-instrumentation
path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector
Copy link
Member

Choose a reason for hiding this comment

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

why are these changes here?

I am concerned that this will cause issues for the upgrade (also the upgrade test was changed )

@jaronoff97
Copy link
Contributor Author

@pavolloffay should be good to go now!

// Package webhookhandler contains the webhook that injects sidecars into pods.
package webhookhandler
// Package sidecar contains the webhook that injects sidecars into pods.
package sidecar
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should call this package sidecar

The package exposes a mutator API that allows mutating pod objects. It is used for instrumentation and sidecar

@pavolloffay pavolloffay merged commit f2b5e3c into open-telemetry:main Oct 17, 2023
24 checks passed
@jaronoff97 jaronoff97 deleted the refactor-webhooks-pt1 branch October 17, 2023 14:49
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
* lots of moving things around and simplifcation

* moves webhook manifest

* rename

* generate

* Add back annotations

* Fix tests, simplify code

* naming

* fix borked test

* FIX TESTS

* oops

* move things back

* update manifests

* fix a miss

* fix tests

* Rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants