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 reported name field to Source, deprecate the odigos.io/reported-name annotation #2298

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

RonFed
Copy link
Collaborator

@RonFed RonFed commented Jan 23, 2025

This PR deprecates the odigos.io/reported-name annotation, as part of the effort the reduce the changes we do to workload objects.

  • Adding an optional reportedName field to the Source spec. This field is only valid for workloads Sources and not for Namesoace Sources. This is enforced by the Source validation webhook.
  • Remove the workload reconcilers under instrumentor/instrumentationconfig which were responsible for updating the instrumentationConfig if the annotation changes.
  • Add Source controller which updates InstrumentationConfigs if sources contain a reported name. This can be unified with the startlangdetection controller which already has a reconciler for Sources but is currently left out of this PR to keep this one dedicated to deprecating the annotation.
  • Pods mutating webhook is updated to grab the service name based on the Sources.
  • Added a migration to update the Source reported name field from the deprecated annotation if one exits and the reported name is not populated in the Source.
  • Update the sources and workload-lifecycle e2e tests. These tests made use of the annotation to differ between the instrumented service during different phases of the tests. Both are updated to use the Sources to achieve that.

// ReportedName determines "service.name" resource attribute which will be reported by the instrumentations of this source.
// If not set, the workload name will be used.
// It is not valid for namespace sources.
ReportedName string `json:"reportedName,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

needs // +kubebuilder:validation:Optional (generated docs show it as required)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It looks like we have Required for all of our fields and // +kubebuilder:validation:Optional is not doing anything.
Adding // +optional did the trick, which seems to be what the genref looks for

I can do a follow up PR adding it to all our fields. (and maybe remove // +kubebuilder:validation:Optional which seems to not do anything?)

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, weird. I think that's a bug in the genref, they should definitely be parsing +kubebuilder tags too

A follow up to add // +optional would be good. I think it will only affect the docs, because the controller-gen scripts should be respecting either tag. Meaning, I think our CRDs are accurate

@RonFed RonFed marked this pull request as ready for review January 24, 2025 13:10
@RonFed RonFed requested review from damemi, edeNFed and blumamir January 24, 2025 13:11
// any more changes to the annotation will not be reflected in the source.
// This is valid, since the annotation is deprecated and we want to encourage users to use Source CR.
if kind != workload.WorkloadKindNamespace && source.Spec.ReportedName == "" {
source.Spec.ReportedName = reportedName
Copy link
Contributor

Choose a reason for hiding this comment

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

could this update the Source even if one is already set? So someone could update the label and the migration updates the Source for them.

allErrs = append(allErrs, field.Invalid(
field.NewPath("spec").Child("reportedName"),
source.Spec.ReportedName,
"Namespace Source must not have a reportedName, to configure a reported name for a workload edit its Source",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Namespace Source must not have a reportedName, to configure a reported name for a workload edit its Source",
"Reported name is not valid for Namespace sources, only valid for Workload Sources",

just a little clearer imo

# Using the deprecated way of instrumenting a namespace,
# after v1.0.144, use ../../common/apply/instrument-default-ns.yaml
- script:
content: kubectl label namespace default odigos-instrumentation=enabled
Copy link
Contributor

@damemi damemi Jan 24, 2025

Choose a reason for hiding this comment

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

I actually like this for now as another way to test the label migration in v1.0.144. Agree with removing it after that though

@@ -1,44 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "4"
generation: 5 # Note new generation after annotating service.name, but not new revision
Copy link
Contributor

Choose a reason for hiding this comment

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

huge +1 to not having to keep track of the annotation/generation skew anymore!

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.

2 participants