From 146a9d5d72615548ddce8c83746ccea061ef5fca Mon Sep 17 00:00:00 2001 From: Rohan Vernekar Date: Wed, 25 Oct 2023 06:51:02 -0400 Subject: [PATCH] PR comments --- internal/manifests/manifestutils/labels.go | 2 +- internal/manifests/targetallocator/labels.go | 2 +- internal/naming/main.go | 5 ----- pkg/sidecar/pod.go | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/manifests/manifestutils/labels.go b/internal/manifests/manifestutils/labels.go index fa5d279ff0..cfcf3d2430 100644 --- a/internal/manifests/manifestutils/labels.go +++ b/internal/manifests/manifestutils/labels.go @@ -76,7 +76,7 @@ func Labels(instance metav1.ObjectMeta, name string, image string, component str func SelectorLabels(instance metav1.ObjectMeta, component string) map[string]string { return map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", - "app.kubernetes.io/instance": naming.PodInstanceLabel(instance.Namespace, instance.Name), + "app.kubernetes.io/instance": naming.Truncate("%s.%s", 63, instance.Namespace, instance.Name), "app.kubernetes.io/part-of": "opentelemetry", "app.kubernetes.io/component": component, } diff --git a/internal/manifests/targetallocator/labels.go b/internal/manifests/targetallocator/labels.go index b3c0346d5d..3c9ae4dae4 100644 --- a/internal/manifests/targetallocator/labels.go +++ b/internal/manifests/targetallocator/labels.go @@ -30,7 +30,7 @@ func Labels(instance v1alpha1.OpenTelemetryCollector, name string) map[string]st } base["app.kubernetes.io/managed-by"] = "opentelemetry-operator" - base["app.kubernetes.io/instance"] = naming.PodInstanceLabel(instance.Namespace, instance.Name) + base["app.kubernetes.io/instance"] = naming.Truncate("%s.%s", 63, instance.Namespace, instance.Name) base["app.kubernetes.io/part-of"] = "opentelemetry" base["app.kubernetes.io/component"] = "opentelemetry-targetallocator" diff --git a/internal/naming/main.go b/internal/naming/main.go index 4dc6627bb4..1df0bc2f67 100644 --- a/internal/naming/main.go +++ b/internal/naming/main.go @@ -124,8 +124,3 @@ func ServiceMonitor(otelcol string) string { func TargetAllocatorServiceAccount(otelcol string) string { return DNSName(Truncate("%s-targetallocator", 63, otelcol)) } - -// PodInstanceLabel returns a label value containing the namespace and instance name. -func PodInstanceLabel(namespace string, otelcol string) string { - return Truncate("%s.%s", 63, namespace, otelcol) -} diff --git a/pkg/sidecar/pod.go b/pkg/sidecar/pod.go index 569cf9d123..6c119fc59c 100644 --- a/pkg/sidecar/pod.go +++ b/pkg/sidecar/pod.go @@ -53,7 +53,7 @@ func add(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetryCo if pod.Labels == nil { pod.Labels = map[string]string{} } - pod.Labels[injectedLabel] = naming.PodInstanceLabel(otelcol.Namespace, otelcol.Name) + pod.Labels[injectedLabel] = naming.Truncate("%s.%s", 63, otelcol.Namespace, otelcol.Name) return pod, nil }