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

Label "sidecar.opentelemetry.io/injected" value sometimes longer than 63 characters #1031

Closed
KevinSnyderCodes opened this issue Aug 11, 2022 · 1 comment · Fixed by #2250
Closed
Labels
area:collector Issues for deploying collector

Comments

@KevinSnyderCodes
Copy link

KevinSnyderCodes commented Aug 11, 2022

With an OpenTelemetryCollector in sidecar mode, the sidecar.opentelemetry.io/injected label gets added to the pod using the format [otc_namespace].[otc_name]

pod.Labels[label] = fmt.Sprintf("%s.%s", otelcol.Namespace, otelcol.Name)

Under the right conditions, the label value can exceed 63 characters, which causes Kubernetes controllers to produce the following error:

Error creating: Pod "[name]-59ff54b4c6-9mh4g" is invalid: metadata.labels: Invalid value: "[otc_namespace].[otc_name]": must be no more than 63 characters

(Replace brackets with sufficiently long values.)

If the name of the OpenTelemetryCollector does not identify it as such, this error message is particularly cryptic as it is not obvious what is producing the invalid label. (Took me a while to dig through various controllers and mutating webhooks to find the culprit. Though arguably this is more an issue with how Kubernetes reports such errors.)

Possible solutions:

  1. Move sidecar.opentelemetry.io/injected to annotations
    • Annotations do not have the same restrictions on values as labels
  2. Allow user to disable addition of sidecar.opentelemetry.io/injected label
    • Presumably this would be an option in the OpenTelemetryCollector resource
  3. Split the [otc_namespace] and [otc_name] across multiple labels
    • This is how I've seen other projects handle such cases. Since Kubernetes object names and label values have the same restrictions, you can safely put the [otc_namespace] in one label and the [otc_name] in another, guaranteeing that they will never exceed the character limit.

Would be happy to open a PR with your preferred solution. Thanks 🙂

@KevinSnyderCodes KevinSnyderCodes changed the title Label "sidecar.opentelemetry.io/injected" value longer than 63 characters Label "sidecar.opentelemetry.io/injected" value longer than 63 characters in some cases Aug 11, 2022
@KevinSnyderCodes KevinSnyderCodes changed the title Label "sidecar.opentelemetry.io/injected" value longer than 63 characters in some cases Label "sidecar.opentelemetry.io/injected" value sometimes longer than 63 characters Aug 11, 2022
@KevinSnyderCodes
Copy link
Author

An implementation of solution 3, which also maintains backwards compatibility, can be found here: #1032

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:collector Issues for deploying collector
Projects
None yet
2 participants