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

Add version label to target allocator resources #2455

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

swiatekm
Copy link
Contributor

@swiatekm swiatekm commented Dec 18, 2023

Description:
Add app.kubernetes.io/version label to all target allocator resources. Where the label was present, it now uses the target allocator version instead of the collector version. Use manifestutils.Labels as the implementation.

I've also used manifestutils.SelectorLabels where it makes sense.

Link to tracking Issue: #2454

Testing:
Modified existing tests.

@swiatekm swiatekm force-pushed the chore/targetallocator-labels branch 3 times, most recently from b8bf5b6 to 10352fe Compare December 18, 2023 18:40
@swiatekm swiatekm marked this pull request as ready for review December 18, 2023 18:52
@swiatekm swiatekm requested a review from a team as a code owner December 18, 2023 18:52
if _, ok := base["app.kubernetes.io/name"]; !ok {
base["app.kubernetes.io/name"] = name
}
return manifestutils.Labels(instance.ObjectMeta, name, instance.Spec.TargetAllocator.Image, ComponentOpenTelemetryTargetAllocator, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is awesome

@@ -44,7 +44,7 @@ func Deployment(params manifests.Params) (*appsv1.Deployment, error) {
Spec: appsv1.DeploymentSpec{
Replicas: params.OtelCol.Spec.TargetAllocator.Replicas,
Selector: &metav1.LabelSelector{
MatchLabels: labels,
MatchLabels: SelectorLabels(params.OtelCol),
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this immutable field? https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#label-selector-updates

Can you confirm that this will not break during the upgrade?

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'll test it. If there's a problem with that, then it's probably for the best to leave the selector as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pavolloffay we do have logic in our reconciler to just delete and recreate when it sees this immutable change, so it should just work (with a small blip for the reconciler logic)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting and recreating resources is a bit heavyhanded though, and I'm not sure if we want to do it just to have uniform selector labels between the collector and target allocator.

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 brought this label back. I don't think it makes the code substantially messier - check it our for yourselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough! Maybe lets keep it as it is then, and leave a comment explaining the divergence between the two.

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

looks good to me, thanks for leaving the comment as well :)

@jaronoff97 jaronoff97 merged commit c2b3ece into open-telemetry:main Dec 21, 2023
27 checks passed
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
* Add version label to target allocator resources

* Use manifestutils.SelectorLabels for target allocator resources
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.

None yet

3 participants