From 8de23cc5ba98a56ecce2b11178418409e832f79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Tue, 15 Oct 2024 14:00:48 +0200 Subject: [PATCH 01/17] Fix flaky target allocator test (#3355) The test involves measuring the rate limit for the Prometheus CR watcher , which is difficult to do given the potential timing differences between hosts. I basically just relaxed a lot of the checks - the test now passes if we take a lot longer than expected, and the tested interval is also larger to begin with. --- cmd/otel-allocator/watcher/promOperator_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/otel-allocator/watcher/promOperator_test.go b/cmd/otel-allocator/watcher/promOperator_test.go index 7bd3f0f443..215579e636 100644 --- a/cmd/otel-allocator/watcher/promOperator_test.go +++ b/cmd/otel-allocator/watcher/promOperator_test.go @@ -973,7 +973,7 @@ func TestRateLimit(t *testing.T) { }, } events := make(chan Event, 1) - eventInterval := 5 * time.Millisecond + eventInterval := 500 * time.Millisecond cfg := allocatorconfig.Config{} w, _ := getTestPrometheusCRWatcher(t, nil, nil, cfg) @@ -1006,10 +1006,10 @@ func TestRateLimit(t *testing.T) { default: return false } - }, eventInterval*2, time.Millisecond) + }, time.Second*5, eventInterval/10) // it's difficult to measure the rate precisely - // what we do, is send two updates, and then assert that the elapsed time is between eventInterval and 3*eventInterval + // what we do, is send two updates, and then assert that the elapsed time is at least eventInterval startTime := time.Now() _, err = w.kubeMonitoringClient.MonitoringV1().ServiceMonitors("test").Update(context.Background(), serviceMonitor, metav1.UpdateOptions{}) require.NoError(t, err) @@ -1020,7 +1020,7 @@ func TestRateLimit(t *testing.T) { default: return false } - }, eventInterval*2, time.Millisecond) + }, time.Second*5, eventInterval/10) _, err = w.kubeMonitoringClient.MonitoringV1().ServiceMonitors("test").Update(context.Background(), serviceMonitor, metav1.UpdateOptions{}) require.NoError(t, err) require.Eventually(t, func() bool { @@ -1030,11 +1030,9 @@ func TestRateLimit(t *testing.T) { default: return false } - }, eventInterval*2, time.Millisecond) + }, time.Second*5, eventInterval/10) elapsedTime := time.Since(startTime) assert.Less(t, eventInterval, elapsedTime) - assert.GreaterOrEqual(t, eventInterval*3, elapsedTime) - } // getTestPrometheusCRWatcher creates a test instance of PrometheusCRWatcher with fake clients From 9a1b585c1ce585125ea7133867e9c9a49621225e Mon Sep 17 00:00:00 2001 From: "Ben B." Date: Wed, 16 Oct 2024 09:44:35 +0200 Subject: [PATCH 02/17] add featuregate for k8s 1.28 native sidecar container (#2801) * add featuregate for k8s 1.28 native sidecar container Signed-off-by: Benedikt Bongartz * use slices methods to deal with sidecars Signed-off-by: Benedikt Bongartz * apply recommendations Signed-off-by: Benedikt Bongartz * test with k8s 1.29 Signed-off-by: Benedikt Bongartz --------- Signed-off-by: Benedikt Bongartz --- .chloggen/native_sidecar.yaml | 21 ++++ .github/workflows/e2e.yaml | 3 + Makefile | 7 ++ pkg/featuregate/featuregate.go | 12 +++ pkg/sidecar/pod.go | 38 +++++-- pkg/sidecar/pod_test.go | 110 ++++++++++++++++++++ tests/e2e-native-sidecar/00-assert.yaml | 22 ++++ tests/e2e-native-sidecar/00-install.yaml | 41 ++++++++ tests/e2e-native-sidecar/chainsaw-test.yaml | 14 +++ 9 files changed, 259 insertions(+), 9 deletions(-) create mode 100755 .chloggen/native_sidecar.yaml create mode 100644 tests/e2e-native-sidecar/00-assert.yaml create mode 100644 tests/e2e-native-sidecar/00-install.yaml create mode 100755 tests/e2e-native-sidecar/chainsaw-test.yaml diff --git a/.chloggen/native_sidecar.yaml b/.chloggen/native_sidecar.yaml new file mode 100755 index 0000000000..1637381020 --- /dev/null +++ b/.chloggen/native_sidecar.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: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add native sidecar injection behind a feature gate which is disabled by default. + +# One or more tracking issues related to the change +issues: [2376] + +# (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: | + 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 adding + the `--feature-gates=operator.sidecarcontainers.native` to the Operator args. + In the future this may will become availabe as deployment mode on the Collector CR. See [#3356](https://github.com/open-telemetry/opentelemetry-operator/issues/3356) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 922467d9b0..b762ef419f 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -46,6 +46,9 @@ jobs: setup: "add-operator-arg OPERATOR_ARG='--feature-gates=operator.targetallocator.mtls' add-certmanager-permissions prepare-e2e" - group: e2e-automatic-rbac setup: "add-rbac-permissions-to-operator prepare-e2e" + - group: e2e-native-sidecar + setup: "add-operator-arg OPERATOR_ARG='--feature-gates=operator.sidecarcontainers.native' prepare-e2e" + kube-version: "1.29" steps: - name: Check out code into the Go module directory uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 2e73d990d9..384a7ea1f7 100644 --- a/Makefile +++ b/Makefile @@ -267,6 +267,13 @@ generate: controller-gen e2e: chainsaw $(CHAINSAW) test --test-dir ./tests/e2e +# e2e-native-sidecar +# NOTE: make sure the k8s featuregate "SidecarContainers" is set to true. +# NOTE: make sure the operator featuregate "operator.sidecarcontainers.native" is enabled. +.PHONY: e2e-native-sidecar +e2e-native-sidecar: chainsaw + $(CHAINSAW) test --test-dir ./tests/e2e-native-sidecar + # end-to-end-test for testing automatic RBAC creation .PHONY: e2e-automatic-rbac e2e-automatic-rbac: chainsaw diff --git a/pkg/featuregate/featuregate.go b/pkg/featuregate/featuregate.go index 5b452da235..0db8286b6e 100644 --- a/pkg/featuregate/featuregate.go +++ b/pkg/featuregate/featuregate.go @@ -25,6 +25,18 @@ const ( ) var ( + // EnableNativeSidecarContainers is the feature gate that controls whether a + // sidecar should be injected as a native sidecar or the classic way. + // Native sidecar containers have been available since kubernetes v1.28 in + // alpha and v1.29 in beta. + // It needs to be enabled with +featureGate=SidecarContainers. + // See: + // https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/#feature-gates-for-alpha-or-beta-features + EnableNativeSidecarContainers = featuregate.GlobalRegistry().MustRegister( + "operator.sidecarcontainers.native", + featuregate.StageAlpha, + featuregate.WithRegisterDescription("controls whether the operator supports sidecar containers as init containers. Should only be enabled on k8s v1.29+"), + ) // PrometheusOperatorIsAvailable is the feature gate that enables features associated to the Prometheus Operator. PrometheusOperatorIsAvailable = featuregate.GlobalRegistry().MustRegister( "operator.observability.prometheus", diff --git a/pkg/sidecar/pod.go b/pkg/sidecar/pod.go index d7db13484c..d7a99918df 100644 --- a/pkg/sidecar/pod.go +++ b/pkg/sidecar/pod.go @@ -17,6 +17,7 @@ package sidecar import ( "fmt" + "slices" "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" @@ -25,6 +26,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) const ( @@ -47,7 +49,17 @@ func add(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTelemetryCol container.Env = append(container.Env, attributes...) } pod.Spec.InitContainers = append(pod.Spec.InitContainers, otelcol.Spec.InitContainers...) - pod.Spec.Containers = append(pod.Spec.Containers, container) + + if featuregate.EnableNativeSidecarContainers.IsEnabled() { + policy := corev1.ContainerRestartPolicyAlways + container.RestartPolicy = &policy + // NOTE: Use ReadinessProbe as startup probe. + // See https://github.com/open-telemetry/opentelemetry-operator/pull/2801#discussion_r1547571121 + container.StartupProbe = container.ReadinessProbe + pod.Spec.InitContainers = append(pod.Spec.InitContainers, container) + } else { + pod.Spec.Containers = append(pod.Spec.Containers, container) + } pod.Spec.Volumes = append(pod.Spec.Volumes, otelcol.Spec.Volumes...) if pod.Labels == nil { @@ -58,26 +70,34 @@ func add(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTelemetryCol return pod, nil } +func isOtelColContainer(c corev1.Container) bool { return c.Name == naming.Container() } + // remove the sidecar container from the given pod. func remove(pod corev1.Pod) corev1.Pod { if !existsIn(pod) { return pod } - var containers []corev1.Container - for _, container := range pod.Spec.Containers { - if container.Name != naming.Container() { - containers = append(containers, container) - } + pod.Spec.Containers = slices.DeleteFunc(pod.Spec.Containers, isOtelColContainer) + + if featuregate.EnableNativeSidecarContainers.IsEnabled() { + // NOTE: we also remove init containers (native sidecars) since k8s 1.28. + // This should have no side effects. + pod.Spec.InitContainers = slices.DeleteFunc(pod.Spec.InitContainers, isOtelColContainer) } - pod.Spec.Containers = containers return pod } // existsIn checks whether a sidecar container exists in the given pod. func existsIn(pod corev1.Pod) bool { - for _, container := range pod.Spec.Containers { - if container.Name == naming.Container() { + if slices.ContainsFunc(pod.Spec.Containers, isOtelColContainer) { + return true + } + + if featuregate.EnableNativeSidecarContainers.IsEnabled() { + // NOTE: we also check init containers (native sidecars) since k8s 1.28. + // This should have no side effects. + if slices.ContainsFunc(pod.Spec.InitContainers, isOtelColContainer) { return true } } diff --git a/pkg/sidecar/pod_test.go b/pkg/sidecar/pod_test.go index c941961181..58c0de9841 100644 --- a/pkg/sidecar/pod_test.go +++ b/pkg/sidecar/pod_test.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + colfeaturegate "go.opentelemetry.io/collector/featuregate" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" logf "sigs.k8s.io/controller-runtime/pkg/log" @@ -26,10 +27,99 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) var logger = logf.Log.WithName("unit-tests") +func enableSidecarFeatureGate(t *testing.T) { + originalVal := featuregate.EnableNativeSidecarContainers.IsEnabled() + t.Logf("original is: %+v", originalVal) + require.NoError(t, colfeaturegate.GlobalRegistry().Set(featuregate.EnableNativeSidecarContainers.ID(), true)) + t.Cleanup(func() { + require.NoError(t, colfeaturegate.GlobalRegistry().Set(featuregate.EnableNativeSidecarContainers.ID(), originalVal)) + }) +} + +func TestAddNativeSidecar(t *testing.T) { + enableSidecarFeatureGate(t) + // prepare + pod := corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + {Name: "my-app"}, + }, + InitContainers: []corev1.Container{ + { + Name: "my-init", + }, + }, + // cross-test: the pod has a volume already, make sure we don't remove it + Volumes: []corev1.Volume{{}}, + }, + } + + otelcol := v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "otelcol-native-sidecar", + Namespace: "some-app", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Mode: v1beta1.ModeSidecar, + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + InitContainers: []corev1.Container{ + { + Name: "test", + }, + }, + }, + }, + } + + otelcolYaml, err := otelcol.Spec.Config.Yaml() + require.NoError(t, err) + cfg := config.New(config.WithCollectorImage("some-default-image")) + + // test + changed, err := add(cfg, logger, otelcol, pod, nil) + + // verify + assert.NoError(t, err) + require.Len(t, changed.Spec.Containers, 1) + require.Len(t, changed.Spec.InitContainers, 3) + require.Len(t, changed.Spec.Volumes, 1) + assert.Equal(t, "some-app.otelcol-native-sidecar", + changed.Labels["sidecar.opentelemetry.io/injected"]) + expectedPolicy := corev1.ContainerRestartPolicyAlways + assert.Equal(t, corev1.Container{ + Name: "otc-container", + Image: "some-default-image", + Args: []string{"--config=env:OTEL_CONFIG"}, + RestartPolicy: &expectedPolicy, + Env: []corev1.EnvVar{ + { + Name: "POD_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.name", + }, + }, + }, + { + Name: "OTEL_CONFIG", + Value: string(otelcolYaml), + }, + }, + Ports: []corev1.ContainerPort{ + { + Name: "metrics", + ContainerPort: 8888, + Protocol: corev1.ProtocolTCP, + }, + }, + }, changed.Spec.InitContainers[2]) +} + func TestAddSidecarWhenNoSidecarExists(t *testing.T) { // prepare pod := corev1.Pod{ @@ -146,6 +236,11 @@ func TestRemoveSidecar(t *testing.T) { {Name: naming.Container()}, {Name: naming.Container()}, // two sidecars! should remove both }, + InitContainers: []corev1.Container{ + {Name: "something"}, + {Name: naming.Container()}, // NOTE: native sidecar since k8s 1.28. + {Name: naming.Container()}, // two sidecars! should remove both + }, }, } @@ -174,6 +269,8 @@ func TestRemoveNonExistingSidecar(t *testing.T) { } func TestExistsIn(t *testing.T) { + enableSidecarFeatureGate(t) + for _, tt := range []struct { desc string pod corev1.Pod @@ -190,6 +287,19 @@ func TestExistsIn(t *testing.T) { }, true}, + {"does-have-native-sidecar", + corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + {Name: "my-app"}, + }, + InitContainers: []corev1.Container{ + {Name: naming.Container()}, + }, + }, + }, + true}, + {"does-not-have-sidecar", corev1.Pod{ Spec: corev1.PodSpec{ diff --git a/tests/e2e-native-sidecar/00-assert.yaml b/tests/e2e-native-sidecar/00-assert.yaml new file mode 100644 index 0000000000..823eaf2ad1 --- /dev/null +++ b/tests/e2e-native-sidecar/00-assert.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + name: myapp +spec: + containers: + - name: myapp + initContainers: + - name: otc-container + restartPolicy: Always +status: + containerStatuses: + - name: myapp + ready: true + started: true + initContainerStatuses: + - name: otc-container + ready: true + started: true diff --git a/tests/e2e-native-sidecar/00-install.yaml b/tests/e2e-native-sidecar/00-install.yaml new file mode 100644 index 0000000000..82c54ffdf8 --- /dev/null +++ b/tests/e2e-native-sidecar/00-install.yaml @@ -0,0 +1,41 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: a-sidecar +spec: + mode: sidecar + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi + + config: + receivers: + otlp: + protocols: + http: {} + exporters: + debug: {} + service: + pipelines: + metrics: + receivers: [otlp] + exporters: [debug] +--- +apiVersion: v1 +kind: Pod +metadata: + name: myapp + annotations: + sidecar.opentelemetry.io/inject: "true" +spec: + containers: + - name: myapp + image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-python:main + ports: + - containerPort: 8080 + protocol: TCP diff --git a/tests/e2e-native-sidecar/chainsaw-test.yaml b/tests/e2e-native-sidecar/chainsaw-test.yaml new file mode 100755 index 0000000000..0d93db6d15 --- /dev/null +++ b/tests/e2e-native-sidecar/chainsaw-test.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: native-sidecar +spec: + steps: + - name: step-00 + try: + - apply: + file: 00-install.yaml + - assert: + file: 00-assert.yaml From 97c8d51d6e04c8a0fca1df2a1e88450057dbf729 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Wed, 16 Oct 2024 13:44:00 +0200 Subject: [PATCH 03/17] Align insrumentation TLS config with collector (#3358) Signed-off-by: Pavol Loffay --- .chloggen/inst-tls.yaml | 6 +++--- apis/v1alpha1/instrumentation_types.go | 6 +++--- .../opentelemetry-operator.clusterserviceversion.yaml | 2 +- .../manifests/opentelemetry.io_instrumentations.yaml | 6 +++--- .../opentelemetry-operator.clusterserviceversion.yaml | 2 +- .../manifests/opentelemetry.io_instrumentations.yaml | 6 +++--- config/crd/bases/opentelemetry.io_instrumentations.yaml | 6 +++--- docs/api.md | 6 +++--- .../00-install-instrumentation.yaml | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.chloggen/inst-tls.yaml b/.chloggen/inst-tls.yaml index 368bb318fe..7347b315ea 100755 --- a/.chloggen/inst-tls.yaml +++ b/.chloggen/inst-tls.yaml @@ -23,11 +23,11 @@ subtext: | secretName: otel-tls-certs configMapName: otel-ca-bundle # otel-ca-bundle - ca: ca.crt + ca_file: ca.crt # present in otel-tls-certs - cert: tls.crt + cert_file: tls.crt # present in otel-tls-certs - key: tls.key + key_file: tls.key ``` * Propagating secrets across namespaces can be done with https://github.com/EmberStack/kubernetes-reflector or https://github.com/zakkg3/ClusterSecret diff --git a/apis/v1alpha1/instrumentation_types.go b/apis/v1alpha1/instrumentation_types.go index c76ab49d8b..e158402223 100644 --- a/apis/v1alpha1/instrumentation_types.go +++ b/apis/v1alpha1/instrumentation_types.go @@ -121,13 +121,13 @@ type TLS struct { // CA defines the key of certificate (e.g. ca.crt) in the configmap map, secret or absolute path to a certificate. // The absolute path can be used when certificate is already present on the workload filesystem e.g. // /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - CA string `json:"ca,omitempty"` + CA string `json:"ca_file,omitempty"` // Cert defines the key (e.g. tls.crt) of the client certificate in the secret or absolute path to a certificate. // The absolute path can be used when certificate is already present on the workload filesystem. - Cert string `json:"cert,omitempty"` + Cert string `json:"cert_file,omitempty"` // Key defines a key (e.g. tls.key) of the private key in the secret or absolute path to a certificate. // The absolute path can be used when certificate is already present on the workload filesystem. - Key string `json:"key,omitempty"` + Key string `json:"key_file,omitempty"` } // Sampler defines sampling configuration. diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index e5b5bafdfc..25cab56e55 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-10-10T15:31:51Z" + createdAt: "2024-10-16T10:10:50Z" 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 4ff96eca41..7e59a81d68 100644 --- a/bundle/community/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/community/manifests/opentelemetry.io_instrumentations.yaml @@ -411,13 +411,13 @@ spec: type: string tls: properties: - ca: + ca_file: type: string - cert: + cert_file: type: string configMapName: type: string - key: + key_file: type: string secretName: type: string diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index bcab54329b..f248186c9a 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-10-10T15:31:51Z" + createdAt: "2024-10-16T10:10:50Z" 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 4ff96eca41..7e59a81d68 100644 --- a/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml @@ -411,13 +411,13 @@ spec: type: string tls: properties: - ca: + ca_file: type: string - cert: + cert_file: type: string configMapName: type: string - key: + key_file: type: string secretName: type: string diff --git a/config/crd/bases/opentelemetry.io_instrumentations.yaml b/config/crd/bases/opentelemetry.io_instrumentations.yaml index 3065e245a1..ac7f54d183 100644 --- a/config/crd/bases/opentelemetry.io_instrumentations.yaml +++ b/config/crd/bases/opentelemetry.io_instrumentations.yaml @@ -409,13 +409,13 @@ spec: type: string tls: properties: - ca: + ca_file: type: string - cert: + cert_file: type: string configMapName: type: string - key: + key_file: type: string secretName: type: string diff --git a/docs/api.md b/docs/api.md index 71b3b7071a..dc327344f8 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1659,7 +1659,7 @@ TLS needs to be enabled by specifying https:// scheme in the Endpoint. - ca + ca_file string CA defines the key of certificate (e.g. ca.crt) in the configmap map, secret or absolute path to a certificate. @@ -1668,7 +1668,7 @@ The absolute path can be used when certificate is already present on the workloa false - cert + cert_file string Cert defines the key (e.g. tls.crt) of the client certificate in the secret or absolute path to a certificate. @@ -1684,7 +1684,7 @@ used from the secret defined in SecretName.
false - key + key_file string Key defines a key (e.g. tls.key) of the private key in the secret or absolute path to a certificate. diff --git a/tests/e2e-instrumentation/instrumentation-java-tls/00-install-instrumentation.yaml b/tests/e2e-instrumentation/instrumentation-java-tls/00-install-instrumentation.yaml index 222a0584a8..7bc75d7107 100644 --- a/tests/e2e-instrumentation/instrumentation-java-tls/00-install-instrumentation.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-tls/00-install-instrumentation.yaml @@ -8,9 +8,9 @@ spec: tls: secretName: client-certs configMapName: ca - ca: ca.crt - cert: tls.crt - key: tls.key + ca_file: ca.crt + cert_file: tls.crt + key_file: tls.key propagators: - tracecontext - baggage From b703b7805d1d079d7742e4411940c5306ff4db98 Mon Sep 17 00:00:00 2001 From: Ishwar Kanse Date: Wed, 16 Oct 2024 18:31:35 +0530 Subject: [PATCH 04/17] Update export-to-cluster-logging-lokistack to detect storageclass (#3357) --- .../chainsaw-test.yaml | 10 ++++++++++ .../install-loki.yaml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/e2e-openshift/export-to-cluster-logging-lokistack/chainsaw-test.yaml b/tests/e2e-openshift/export-to-cluster-logging-lokistack/chainsaw-test.yaml index 15b018f8e2..2678477a1f 100644 --- a/tests/e2e-openshift/export-to-cluster-logging-lokistack/chainsaw-test.yaml +++ b/tests/e2e-openshift/export-to-cluster-logging-lokistack/chainsaw-test.yaml @@ -20,6 +20,16 @@ spec: file: install-minio-assert.yaml - name: Create the LokiStack instance try: + - command: + entrypoint: oc + args: + - get + - storageclass + - -o + - jsonpath={.items[0].metadata.name} + outputs: + - name: STORAGE_CLASS_NAME + value: ($stdout) - apply: file: install-loki.yaml - assert: diff --git a/tests/e2e-openshift/export-to-cluster-logging-lokistack/install-loki.yaml b/tests/e2e-openshift/export-to-cluster-logging-lokistack/install-loki.yaml index 30c5b560e3..e63aa73982 100644 --- a/tests/e2e-openshift/export-to-cluster-logging-lokistack/install-loki.yaml +++ b/tests/e2e-openshift/export-to-cluster-logging-lokistack/install-loki.yaml @@ -12,6 +12,6 @@ spec: secret: name: logging-loki-s3 type: s3 - storageClassName: gp2-csi + storageClassName: ($STORAGE_CLASS_NAME) tenants: mode: openshift-logging From 868a65abe3b47892ff95bd92c37b4303f272767c Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 17 Oct 2024 10:54:59 -0400 Subject: [PATCH 05/17] fix upgrade testing (#3364) --- pkg/collector/upgrade/suite_test.go | 7 +++++++ pkg/collector/upgrade/upgrade.go | 20 ++++++++++++++++++-- pkg/collector/upgrade/v0_104_0_test.go | 7 ++++--- pkg/collector/upgrade/v0_105_0_test.go | 3 +-- pkg/collector/upgrade/v0_15_0_test.go | 3 +-- pkg/collector/upgrade/v0_19_0_test.go | 7 +++---- pkg/collector/upgrade/v0_24_0_test.go | 3 +-- pkg/collector/upgrade/v0_31_0_test.go | 3 +-- pkg/collector/upgrade/v0_36_0_test.go | 3 +-- pkg/collector/upgrade/v0_38_0_test.go | 3 +-- pkg/collector/upgrade/v0_39_0_test.go | 3 +-- pkg/collector/upgrade/v0_41_0_test.go | 3 +-- pkg/collector/upgrade/v0_43_0_test.go | 3 +-- pkg/collector/upgrade/v0_56_0_test.go | 3 +-- pkg/collector/upgrade/v0_57_2_test.go | 3 +-- pkg/collector/upgrade/v0_61_0_test.go | 3 +-- pkg/collector/upgrade/v0_9_0_test.go | 3 +-- 17 files changed, 45 insertions(+), 35 deletions(-) diff --git a/pkg/collector/upgrade/suite_test.go b/pkg/collector/upgrade/suite_test.go index c5e5cdbd23..7a571bc481 100644 --- a/pkg/collector/upgrade/suite_test.go +++ b/pkg/collector/upgrade/suite_test.go @@ -42,6 +42,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/rbac" + "github.com/open-telemetry/opentelemetry-operator/internal/version" ) var ( @@ -160,3 +161,9 @@ func TestMain(m *testing.M) { os.Exit(code) } + +func makeVersion(v string) version.Version { + return version.Version{ + OpenTelemetryCollector: v, + } +} diff --git a/pkg/collector/upgrade/upgrade.go b/pkg/collector/upgrade/upgrade.go index 9a1f426747..610fca140f 100644 --- a/pkg/collector/upgrade/upgrade.go +++ b/pkg/collector/upgrade/upgrade.go @@ -39,6 +39,17 @@ type VersionUpgrade struct { const RecordBufferSize int = 100 +func (u VersionUpgrade) semVer() *semver.Version { + if len(u.Version.OpenTelemetryCollector) == 0 { + return &Latest.Version + } + if v, err := semver.NewVersion(u.Version.OpenTelemetryCollector); err != nil { + return &Latest.Version + } else { + return v + } +} + // ManagedInstances finds all the otelcol instances for the current operator and upgrades them, if necessary. func (u VersionUpgrade) ManagedInstances(ctx context.Context) error { u.Log.Info("looking for managed instances to upgrade") @@ -107,9 +118,9 @@ func (u VersionUpgrade) ManagedInstance(_ context.Context, otelcol v1beta1.OpenT } updated := *(otelcol.DeepCopy()) - if instanceV.GreaterThan(&Latest.Version) { + if instanceV.GreaterThan(u.semVer()) { // Update with the latest known version, which is what we have from versions.txt - u.Log.V(4).Info("no upgrade routines are needed for the OpenTelemetry instance", "name", updated.Name, "namespace", updated.Namespace, "version", updated.Status.Version, "latest", Latest.Version.String()) + u.Log.V(4).Info("no upgrade routines are needed for the OpenTelemetry instance", "name", updated.Name, "namespace", updated.Namespace, "version", updated.Status.Version, "latest", u.semVer().String()) otelColV, err := semver.NewVersion(u.Version.OpenTelemetryCollector) if err != nil { @@ -126,6 +137,11 @@ func (u VersionUpgrade) ManagedInstance(_ context.Context, otelcol v1beta1.OpenT } for _, available := range versions { + // Don't run upgrades for versions after the webhook's set version. + // This is important only for testing. + if available.GreaterThan(u.semVer()) { + continue + } if available.GreaterThan(instanceV) { if available.upgrade != nil { otelcolV1alpha1 := &v1alpha1.OpenTelemetryCollector{} diff --git a/pkg/collector/upgrade/v0_104_0_test.go b/pkg/collector/upgrade/v0_104_0_test.go index bdf88e7c8e..0c5b939479 100644 --- a/pkg/collector/upgrade/v0_104_0_test.go +++ b/pkg/collector/upgrade/v0_104_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -46,7 +45,7 @@ func Test0_104_0Upgrade(t *testing.T) { versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.104.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } @@ -56,7 +55,9 @@ func Test0_104_0Upgrade(t *testing.T) { t.Errorf("expect err: nil but got: %v", err) } assert.EqualValues(t, - map[string]string{}, + map[string]string{ + "feature-gates": "-component.UseLocalHostAsDefaultHost", + }, col.Spec.Args, "missing featuregate") } diff --git a/pkg/collector/upgrade/v0_105_0_test.go b/pkg/collector/upgrade/v0_105_0_test.go index c92880790d..b0af1cd8ea 100644 --- a/pkg/collector/upgrade/v0_105_0_test.go +++ b/pkg/collector/upgrade/v0_105_0_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -59,7 +58,7 @@ func Test0_105_0Upgrade(t *testing.T) { versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.105.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_15_0_test.go b/pkg/collector/upgrade/v0_15_0_test.go index 0a01a3e847..4063f85829 100644 --- a/pkg/collector/upgrade/v0_15_0_test.go +++ b/pkg/collector/upgrade/v0_15_0_test.go @@ -25,7 +25,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -57,7 +56,7 @@ func TestRemoveMetricsTypeFlags(t *testing.T) { // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.15.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_19_0_test.go b/pkg/collector/upgrade/v0_19_0_test.go index 63162e5dce..3c3a5e66d0 100644 --- a/pkg/collector/upgrade/v0_19_0_test.go +++ b/pkg/collector/upgrade/v0_19_0_test.go @@ -26,7 +26,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -74,7 +73,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.19.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } @@ -124,7 +123,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.19.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } @@ -191,7 +190,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.19.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_24_0_test.go b/pkg/collector/upgrade/v0_24_0_test.go index caf53bdfd2..52669150ff 100644 --- a/pkg/collector/upgrade/v0_24_0_test.go +++ b/pkg/collector/upgrade/v0_24_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -64,7 +63,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.24.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_31_0_test.go b/pkg/collector/upgrade/v0_31_0_test.go index 861cdb492d..dd340ed655 100644 --- a/pkg/collector/upgrade/v0_31_0_test.go +++ b/pkg/collector/upgrade/v0_31_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -63,7 +62,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.31.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_36_0_test.go b/pkg/collector/upgrade/v0_36_0_test.go index 7695d39c00..346adb424c 100644 --- a/pkg/collector/upgrade/v0_36_0_test.go +++ b/pkg/collector/upgrade/v0_36_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -79,7 +78,7 @@ service: up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.36.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_38_0_test.go b/pkg/collector/upgrade/v0_38_0_test.go index 26e3d69bbb..efa74d9c6a 100644 --- a/pkg/collector/upgrade/v0_38_0_test.go +++ b/pkg/collector/upgrade/v0_38_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -72,7 +71,7 @@ service: // EXPECTED: drop logging args and configure logging parameters into config from args up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.38.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_39_0_test.go b/pkg/collector/upgrade/v0_39_0_test.go index 204c576c8a..39ffa04436 100644 --- a/pkg/collector/upgrade/v0_39_0_test.go +++ b/pkg/collector/upgrade/v0_39_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -74,7 +73,7 @@ service: // drop processors.memory_limiter field 'ballast_size_mib' up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.39.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_41_0_test.go b/pkg/collector/upgrade/v0_41_0_test.go index 01903044a5..f13047eefa 100644 --- a/pkg/collector/upgrade/v0_41_0_test.go +++ b/pkg/collector/upgrade/v0_41_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -64,7 +63,7 @@ service: // TESTCASE 1: restructure cors for both allowed_origin & allowed_headers up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.41.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_43_0_test.go b/pkg/collector/upgrade/v0_43_0_test.go index 348b1d0b96..957849f941 100644 --- a/pkg/collector/upgrade/v0_43_0_test.go +++ b/pkg/collector/upgrade/v0_43_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -70,7 +69,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.43.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_56_0_test.go b/pkg/collector/upgrade/v0_56_0_test.go index 57ced4b07a..fd29c55aed 100644 --- a/pkg/collector/upgrade/v0_56_0_test.go +++ b/pkg/collector/upgrade/v0_56_0_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -50,7 +49,7 @@ func Test0_56_0Upgrade(t *testing.T) { collectorInstance.Status.Version = "0.55.0" versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.56.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_57_2_test.go b/pkg/collector/upgrade/v0_57_2_test.go index a3ca59919c..c43b869591 100644 --- a/pkg/collector/upgrade/v0_57_2_test.go +++ b/pkg/collector/upgrade/v0_57_2_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -67,7 +66,7 @@ service: //Test to remove port and change endpoint value. versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.57.2"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_61_0_test.go b/pkg/collector/upgrade/v0_61_0_test.go index f702695672..91bfdc447f 100644 --- a/pkg/collector/upgrade/v0_61_0_test.go +++ b/pkg/collector/upgrade/v0_61_0_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -72,7 +71,7 @@ func Test0_61_0Upgrade(t *testing.T) { versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.61.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_9_0_test.go b/pkg/collector/upgrade/v0_9_0_test.go index c428034000..06c5c8cf7f 100644 --- a/pkg/collector/upgrade/v0_9_0_test.go +++ b/pkg/collector/upgrade/v0_9_0_test.go @@ -25,7 +25,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -56,7 +55,7 @@ func TestRemoveConnectionDelay(t *testing.T) { // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.9.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } From eeaa19e7020d3fbf5da968f8efc975fd2af58953 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 17 Oct 2024 11:44:56 -0400 Subject: [PATCH 06/17] add iblancasa to approvers (#3363) --- .github/workflows/reusable-operator-hub-release.yaml | 4 ++-- README.md | 11 ++++++----- RELEASE.md | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reusable-operator-hub-release.yaml b/.github/workflows/reusable-operator-hub-release.yaml index d453b92a93..e9de4190e2 100644 --- a/.github/workflows/reusable-operator-hub-release.yaml +++ b/.github/workflows/reusable-operator-hub-release.yaml @@ -56,7 +56,7 @@ jobs: env: VERSION: ${{ env.version }} run: | - mkdir operators/opentelemetry-operator/${VERSION} + mkdir operators/opentelemetry-operator/${VERSION} cp -R ./tmp/bundle/${{ inputs.folder }}/* operators/opentelemetry-operator/${VERSION} rm -rf ./tmp @@ -73,7 +73,7 @@ jobs: message="Update the opentelemetry to $VERSION" body="Release opentelemetry-operator \`$VERSION\`. - cc @pavolloffay @frzifus @yuriolisa @jaronoff97 @TylerHelmuth @swiatekm + cc @pavolloffay @frzifus @yuriolisa @jaronoff97 @TylerHelmuth @swiatekm @iblancasa " branch="update-opentelemetry-operator-to-${VERSION}" diff --git a/README.md b/README.md index 97b4ed9049..c94bb0670b 100644 --- a/README.md +++ b/README.md @@ -608,7 +608,7 @@ spec: mode: statefulset targetAllocator: enabled: true - config: + config: receivers: prometheus: config: @@ -740,7 +740,7 @@ spec: ### Configure resource attributes with labels -You can also use common labels to set resource attributes. +You can also use common labels to set resource attributes. The following labels are supported: - `app.kubernetes.io/name` becomes `service.name` @@ -782,12 +782,12 @@ The priority for setting resource attributes is as follows (first found wins): 1. Resource attributes set via `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME` environment variables 2. Resource attributes set via annotations (with the `resource.opentelemetry.io/` prefix) -3. Resource attributes set via labels (e.g. `app.kubernetes.io/name`) +3. Resource attributes set via labels (e.g. `app.kubernetes.io/name`) if the `Instrumentation` CR has defaults.useLabelsForResourceAttributes=true (see above) 4. Resource attributes calculated from the pod's metadata (e.g. `k8s.pod.name`) 5. Resource attributes set via the `Instrumentation` CR (in the `spec.resource.resourceAttributes` section) -This priority is applied for each resource attribute separately, so it is possible to set some attributes via +This priority is applied for each resource attribute separately, so it is possible to set some attributes via annotations and others via labels. ## Compatibility matrix @@ -807,7 +807,7 @@ We strive to be compatible with the widest range of Kubernetes versions as possi We use `cert-manager` for some features of this operator and the third column shows the versions of the `cert-manager` that are known to work with this operator's versions. The Target Allocator supports prometheus-operator CRDs like ServiceMonitor, and it does so by using packages imported from prometheus-operator itself. The table shows which version is shipped with a given operator version. -Generally speaking, these are backwards compatible, but specific features require the appropriate package versions. +Generally speaking, these are backwards compatible, but specific features require the appropriate package versions. 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. @@ -849,6 +849,7 @@ Approvers ([@open-telemetry/operator-approvers](https://github.com/orgs/open-tel - [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 Emeritus Approvers: diff --git a/RELEASE.md b/RELEASE.md index 046a05c81c..55570bfa3a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -49,4 +49,5 @@ The operator should be released within a week after the [OpenTelemetry collector | v0.113.0 | @pavolloffay | | v0.114.0 | @TylerHelmuth | | v0.115.0 | @jaronoff97 | -| v0.116.0 | @swiatekm | \ No newline at end of file +| v0.116.0 | @swiatekm | +| v0.117.0 | @iblancasa | From a748078f17e9b47fd9f2a923b64e378f6adffded Mon Sep 17 00:00:00 2001 From: "Ben B." Date: Thu, 17 Oct 2024 17:50:24 +0200 Subject: [PATCH 07/17] upgrade: add test for version 0.110.0 (#3365) Signed-off-by: Benedikt Bongartz --- pkg/collector/upgrade/v0_110_0_test.go | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 pkg/collector/upgrade/v0_110_0_test.go diff --git a/pkg/collector/upgrade/v0_110_0_test.go b/pkg/collector/upgrade/v0_110_0_test.go new file mode 100644 index 0000000000..ec63f004c1 --- /dev/null +++ b/pkg/collector/upgrade/v0_110_0_test.go @@ -0,0 +1,66 @@ +// 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 upgrade_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/record" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" +) + +func Test0_110_0Upgrade(t *testing.T) { + collectorInstance := v1beta1.OpenTelemetryCollector{ + TypeMeta: metav1.TypeMeta{ + Kind: "OpenTelemetryCollector", + APIVersion: "v1beta1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "otel-my-instance", + Namespace: "somewhere", + }, + Status: v1beta1.OpenTelemetryCollectorStatus{ + Version: "0.104.0", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + Args: map[string]string{ + "foo": "bar", + "feature-gates": "+baz,-component.UseLocalHostAsDefaultHost", + }, + }, + Config: v1beta1.Config{}, + }, + } + + versionUpgrade := &upgrade.VersionUpgrade{ + Log: logger, + Version: makeVersion("0.110.0"), + Client: k8sClient, + Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), + } + + col, err := versionUpgrade.ManagedInstance(context.Background(), collectorInstance) + if err != nil { + t.Errorf("expect err: nil but got: %v", err) + } + assert.EqualValues(t, + map[string]string{"foo": "bar", "feature-gates": "+baz"}, col.Spec.Args) +} From c4c5cc85729ffac1c31412fbb5d4e0c701028ac4 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 17 Oct 2024 19:23:04 +0200 Subject: [PATCH 08/17] Set OTEL_LOGS_EXPORTER for python (#3330) * Set OTEL_LOGS_EXPORTER for python * Add changelog * Update e2e tests * Fix some e2e * Fix instrumentation python test * Another e2e fix * Apply suggestions from code review * Update .chloggen/3330-python-otel-logs-exporter.yaml Co-authored-by: Jacob Aronoff --------- Co-authored-by: Jacob Aronoff --- .chloggen/3330-python-otel-logs-exporter.yaml | 16 ++++ pkg/instrumentation/podmutator_test.go | 32 +++++++ pkg/instrumentation/python.go | 14 ++- pkg/instrumentation/python_test.go | 96 +++++++++++++++++++ pkg/instrumentation/sdk_test.go | 4 + .../01-assert.yaml | 4 + .../02-assert.yaml | 2 + .../instrumentation-python/01-assert.yaml | 2 + .../02-assert.yaml | 2 + .../01-assert.yaml | 2 + 10 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 .chloggen/3330-python-otel-logs-exporter.yaml diff --git a/.chloggen/3330-python-otel-logs-exporter.yaml b/.chloggen/3330-python-otel-logs-exporter.yaml new file mode 100644 index 0000000000..021c205811 --- /dev/null +++ b/.chloggen/3330-python-otel-logs-exporter.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: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: set OTEL_LOGS_EXPORTER env var to otlp in python instrumentation + +# One or more tracking issues related to the change +issues: [3330] + +# (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/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 400d44c22b..dd471ad789 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -1258,6 +1258,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1361,6 +1365,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1454,6 +1462,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1562,6 +1574,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1653,6 +1669,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1746,6 +1766,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -4125,6 +4149,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_SERVICE_NAME", Value: "python1", @@ -4200,6 +4228,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_SERVICE_NAME", Value: "python2", diff --git a/pkg/instrumentation/python.go b/pkg/instrumentation/python.go index d3cfc51ca4..c0745cd814 100644 --- a/pkg/instrumentation/python.go +++ b/pkg/instrumentation/python.go @@ -26,6 +26,7 @@ const ( envPythonPath = "PYTHONPATH" envOtelTracesExporter = "OTEL_TRACES_EXPORTER" envOtelMetricsExporter = "OTEL_METRICS_EXPORTER" + envOtelLogsExporter = "OTEL_LOGS_EXPORTER" envOtelExporterOTLPProtocol = "OTEL_EXPORTER_OTLP_PROTOCOL" pythonPathPrefix = "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation" pythonPathSuffix = "/otel-auto-instrumentation-python" @@ -70,7 +71,7 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor }) } - // Set OTEL_TRACES_EXPORTER to HTTP exporter if not set by user because it is what our autoinstrumentation supports. + // Set OTEL_TRACES_EXPORTER to otlp exporter if not set by user because it is what our autoinstrumentation supports. idx = getIndexOfEnv(container.Env, envOtelTracesExporter) if idx == -1 { container.Env = append(container.Env, corev1.EnvVar{ @@ -79,7 +80,7 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor }) } - // Set OTEL_METRICS_EXPORTER to HTTP exporter if not set by user because it is what our autoinstrumentation supports. + // Set OTEL_METRICS_EXPORTER to otlp exporter if not set by user because it is what our autoinstrumentation supports. idx = getIndexOfEnv(container.Env, envOtelMetricsExporter) if idx == -1 { container.Env = append(container.Env, corev1.EnvVar{ @@ -88,6 +89,15 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor }) } + // Set OTEL_LOGS_EXPORTER to otlp exporter if not set by user because it is what our autoinstrumentation supports. + idx = getIndexOfEnv(container.Env, envOtelLogsExporter) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envOtelLogsExporter, + Value: "otlp", + }) + } + container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ Name: pythonVolumeName, MountPath: pythonInstrMountPath, diff --git a/pkg/instrumentation/python_test.go b/pkg/instrumentation/python_test.go index 2ced01bb07..01fe9b1665 100644 --- a/pkg/instrumentation/python_test.go +++ b/pkg/instrumentation/python_test.go @@ -90,6 +90,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -163,6 +167,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -235,6 +243,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -307,6 +319,86 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_TRACES_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, + }, + }, + }, + }, + }, + err: nil, + }, + { + name: "OTEL_LOGS_EXPORTER defined", + Python: v1alpha1.Python{Image: "foo/bar:1"}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: "OTEL_LOGS_EXPORTER", + Value: "somebackend", + }, + }, + }, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + { + Name: "opentelemetry-auto-instrumentation-python", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{ + SizeLimit: &defaultVolumeLimitSize, + }, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Name: "opentelemetry-auto-instrumentation-python", + Image: "foo/bar:1", + Command: []string{"cp", "-r", "/autoinstrumentation/.", "/otel-auto-instrumentation-python"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "opentelemetry-auto-instrumentation-python", + MountPath: "/otel-auto-instrumentation-python", + }}, + }, + }, + Containers: []corev1.Container{ + { + VolumeMounts: []corev1.VolumeMount{ + { + Name: "opentelemetry-auto-instrumentation-python", + MountPath: "/otel-auto-instrumentation-python", + }, + }, + Env: []corev1.EnvVar{ + { + Name: "OTEL_LOGS_EXPORTER", + Value: "somebackend", + }, + { + Name: "PYTHONPATH", + Value: fmt.Sprintf("%s:%s", "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation", "/otel-auto-instrumentation-python"), + }, + { + Name: "OTEL_EXPORTER_OTLP_PROTOCOL", + Value: "http/protobuf", + }, + { + Name: "OTEL_TRACES_EXPORTER", + Value: "otlp", + }, + { + Name: "OTEL_METRICS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -379,6 +471,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index c3abedac04..38013ed3ac 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -1261,6 +1261,10 @@ func TestInjectPython(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_SERVICE_NAME", Value: "app", diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml index d0e8c12567..72f6e7e712 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml @@ -26,6 +26,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://localhost:4317 - name: OTEL_EXPORTER_OTLP_TIMEOUT @@ -74,6 +76,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://localhost:4317 - name: OTEL_EXPORTER_OTLP_TIMEOUT diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml index da7c987e54..5e2cbf06e2 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml @@ -37,6 +37,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://localhost:4317 - name: OTEL_EXPORTER_OTLP_TIMEOUT diff --git a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml index 62cf682ba0..94ff9058d7 100644 --- a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml @@ -29,6 +29,8 @@ spec: value: http/protobuf - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_TIMEOUT value: "20" - name: OTEL_TRACES_SAMPLER diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml index 71d4e05d06..63c9e239e3 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml @@ -43,6 +43,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_TIMEOUT value: "20" - name: OTEL_TRACES_SAMPLER 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 61eabd4e91..b0edc6701f 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -185,6 +185,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG From e9936df2a51f8fb9b3c2f28c6ea7ff6f4fa93d4a Mon Sep 17 00:00:00 2001 From: OpenTelemetry Bot <107717825+opentelemetrybot@users.noreply.github.com> Date: Fri, 18 Oct 2024 02:01:37 -0500 Subject: [PATCH 09/17] Update the OpenTelemetry Java agent version to 2.9.0 (#3366) --- 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 834f262953..c8e38b6140 100644 --- a/autoinstrumentation/java/version.txt +++ b/autoinstrumentation/java/version.txt @@ -1 +1 @@ -2.8.0 +2.9.0 From 12d95da2c83fa02e32ef9a04caeeafe6d847a601 Mon Sep 17 00:00:00 2001 From: Jared Tan Date: Fri, 18 Oct 2024 17:52:33 +0800 Subject: [PATCH 10/17] Update to v0.51.0 (#3367) Co-authored-by: Israel Blancas --- autoinstrumentation/nodejs/package.json | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/autoinstrumentation/nodejs/package.json b/autoinstrumentation/nodejs/package.json index 7e5886a89c..d971d98733 100644 --- a/autoinstrumentation/nodejs/package.json +++ b/autoinstrumentation/nodejs/package.json @@ -10,21 +10,21 @@ }, "devDependencies": { "copyfiles": "^2.4.1", - "rimraf": "^5.0.8", - "typescript": "^5.5.3" + "rimraf": "^6.0.1", + "typescript": "^5.6.3" }, "dependencies": { "@opentelemetry/api": "1.9.0", - "@opentelemetry/auto-instrumentations-node": "0.48.0", - "@opentelemetry/exporter-metrics-otlp-grpc": "0.52.1", - "@opentelemetry/exporter-prometheus": "0.52.1", - "@opentelemetry/exporter-trace-otlp-grpc": "0.52.1", - "@opentelemetry/resource-detector-alibaba-cloud": "0.28.10", - "@opentelemetry/resource-detector-aws": "1.5.2", - "@opentelemetry/resource-detector-container": "0.3.11", - "@opentelemetry/resource-detector-gcp": "0.29.10", - "@opentelemetry/resources": "1.25.1", - "@opentelemetry/sdk-metrics": "1.25.1", - "@opentelemetry/sdk-node": "0.52.1" + "@opentelemetry/auto-instrumentations-node": "0.51.0", + "@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0", + "@opentelemetry/exporter-prometheus": "0.53.0", + "@opentelemetry/exporter-trace-otlp-grpc": "0.53.0", + "@opentelemetry/resource-detector-alibaba-cloud": "0.29.3", + "@opentelemetry/resource-detector-aws": "1.6.2", + "@opentelemetry/resource-detector-container": "0.4.4", + "@opentelemetry/resource-detector-gcp": "0.29.12", + "@opentelemetry/resources": "1.26.0", + "@opentelemetry/sdk-metrics": "1.26.0", + "@opentelemetry/sdk-node": "0.53.0" } } From 01b075535cbbf6c070e8ce6553feb63b41be272f Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Fri, 18 Oct 2024 15:49:56 +0200 Subject: [PATCH 11/17] Update chainsaw in makefile (#3347) Signed-off-by: Pavol Loffay --- .github/workflows/e2e.yaml | 2 -- Makefile | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index b762ef419f..ce4cc811db 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -62,8 +62,6 @@ jobs: with: path: bin key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}-${{ steps.setup-go.outputs.go-version }} - - name: Install chainsaw - uses: kyverno/action-install-chainsaw@v0.2.11 - name: Install tools run: make install-tools - name: Prepare e2e tests diff --git a/Makefile b/Makefile index 384a7ea1f7..183887ec7c 100644 --- a/Makefile +++ b/Makefile @@ -473,7 +473,7 @@ KUSTOMIZE_VERSION ?= v5.0.3 CONTROLLER_TOOLS_VERSION ?= v0.16.1 GOLANGCI_LINT_VERSION ?= v1.57.2 KIND_VERSION ?= v0.20.0 -CHAINSAW_VERSION ?= v0.2.5 +CHAINSAW_VERSION ?= v0.2.8 .PHONY: install-tools install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw From 5a11b480f65ef1d897cc86ef6c039161216f4781 Mon Sep 17 00:00:00 2001 From: "Ben B." Date: Sat, 19 Oct 2024 03:40:06 +0200 Subject: [PATCH 12/17] v1beta1: apply telemetry config defaults in webhook (#3361) Signed-off-by: Benedikt Bongartz Update .chloggen/default_telemetry_settings.yaml add another webhook test Signed-off-by: Benedikt Bongartz avoid using mapstructure Signed-off-by: Benedikt Bongartz test: assert on addr --- .chloggen/default_telemetry_settings.yaml | 19 ++++ apis/v1beta1/collector_webhook_test.go | 9 +- apis/v1beta1/config.go | 50 ++++++++-- apis/v1beta1/config_test.go | 23 ++++- internal/manifests/collector/container.go | 2 +- internal/manifests/collector/service.go | 2 +- pkg/collector/upgrade/upgrade_test.go | 2 +- pkg/collector/upgrade/v0_111_0.go | 23 +++++ pkg/collector/upgrade/v0_111_0_test.go | 98 +++++++++++++++++++ pkg/collector/upgrade/versions.go | 4 + .../02-assert.yaml | 3 + .../01-assert.yaml | 3 + .../ta-collector-mtls/00-assert.yaml | 7 +- .../targetallocator-features/00-assert.yaml | 2 +- .../00-assert.yaml | 5 +- .../00-assert.yaml | 5 +- tests/e2e/managed-reconcile/02-assert.yaml | 5 +- tests/e2e/multiple-configmaps/00-assert.yaml | 2 +- .../e2e/smoke-targetallocator/00-assert.yaml | 5 +- tests/e2e/statefulset-features/00-assert.yaml | 2 +- tests/e2e/statefulset-features/01-assert.yaml | 2 +- tests/e2e/versioned-configmaps/00-assert.yaml | 4 +- tests/e2e/versioned-configmaps/01-assert.yaml | 6 +- 23 files changed, 253 insertions(+), 30 deletions(-) create mode 100755 .chloggen/default_telemetry_settings.yaml create mode 100644 pkg/collector/upgrade/v0_111_0.go create mode 100644 pkg/collector/upgrade/v0_111_0_test.go diff --git a/.chloggen/default_telemetry_settings.yaml b/.chloggen/default_telemetry_settings.yaml new file mode 100755 index 0000000000..cd2f0f31d8 --- /dev/null +++ b/.chloggen/default_telemetry_settings.yaml @@ -0,0 +1,19 @@ +# 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: Expose the Collector telemetry endpoint by default. + +# One or more tracking issues related to the change +issues: [3361] + +# (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: | + The collector v0.111.0 changes the default binding of the telemetry metrics endpoint from `0.0.0.0` to `localhost`. + To avoid any disruption we fallback to "0.0.0.0:{PORT}" as default address. + Details can be found here: [opentelemetry-collector#11251](https://github.com/open-telemetry/opentelemetry-collector/pull/11251) diff --git a/apis/v1beta1/collector_webhook_test.go b/apis/v1beta1/collector_webhook_test.go index d6145543f3..a30d74a66c 100644 --- a/apis/v1beta1/collector_webhook_test.go +++ b/apis/v1beta1/collector_webhook_test.go @@ -169,7 +169,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) { Mode: v1beta1.ModeDeployment, UpgradeStrategy: v1beta1.UpgradeStrategyAutomatic, Config: func() v1beta1.Config { - const input = `{"receivers":{"otlp":{"protocols":{"grpc":{"endpoint":"0.0.0.0:4317"},"http":{"endpoint":"0.0.0.0:4318"}}}},"exporters":{"debug":null},"service":{"pipelines":{"traces":{"receivers":["otlp"],"exporters":["debug"]}}}}` + const input = `{"receivers":{"otlp":{"protocols":{"grpc":{"endpoint":"0.0.0.0:4317"},"http":{"endpoint":"0.0.0.0:4318"}}}},"exporters":{"debug":null},"service":{"telemetry":{"metrics":{"address":"0.0.0.0:8888"}},"pipelines":{"traces":{"receivers":["otlp"],"exporters":["debug"]}}}}` var cfg v1beta1.Config require.NoError(t, yaml.Unmarshal([]byte(input), &cfg)) return cfg @@ -182,7 +182,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) { otelcol: v1beta1.OpenTelemetryCollector{ Spec: v1beta1.OpenTelemetryCollectorSpec{ Config: func() v1beta1.Config { - const input = `{"receivers":{"otlp":{"protocols":{"grpc":{"headers":{"example":"another"}},"http":{"endpoint":"0.0.0.0:4000"}}}},"exporters":{"debug":null},"service":{"pipelines":{"traces":{"receivers":["otlp"],"exporters":["debug"]}}}}` + const input = `{"receivers":{"otlp":{"protocols":{"grpc":{"headers":{"example":"another"}},"http":{"endpoint":"0.0.0.0:4000"}}}},"exporters":{"debug":null},"service":{"telemetry":{"metrics":{"address":"1.2.3.4:7654"}},"pipelines":{"traces":{"receivers":["otlp"],"exporters":["debug"]}}}}` var cfg v1beta1.Config require.NoError(t, yaml.Unmarshal([]byte(input), &cfg)) return cfg @@ -201,7 +201,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) { Mode: v1beta1.ModeDeployment, UpgradeStrategy: v1beta1.UpgradeStrategyAutomatic, Config: func() v1beta1.Config { - const input = `{"receivers":{"otlp":{"protocols":{"grpc":{"endpoint":"0.0.0.0:4317","headers":{"example":"another"}},"http":{"endpoint":"0.0.0.0:4000"}}}},"exporters":{"debug":null},"service":{"pipelines":{"traces":{"receivers":["otlp"],"exporters":["debug"]}}}}` + const input = `{"receivers":{"otlp":{"protocols":{"grpc":{"endpoint":"0.0.0.0:4317","headers":{"example":"another"}},"http":{"endpoint":"0.0.0.0:4000"}}}},"exporters":{"debug":null},"service":{"telemetry":{"metrics":{"address":"1.2.3.4:7654"}},"pipelines":{"traces":{"receivers":["otlp"],"exporters":["debug"]}}}}` var cfg v1beta1.Config require.NoError(t, yaml.Unmarshal([]byte(input), &cfg)) return cfg @@ -554,6 +554,9 @@ 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, err) assert.Equal(t, test.expected, test.otelcol) }) diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 2d88c7617e..549aff9815 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -228,6 +228,9 @@ func (c *Config) getPortsForComponentKinds(logger logr.Logger, componentKinds .. // 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 { + return err + } enabledComponents := c.GetEnabledComponents() for _, componentKind := range componentKinds { var retriever components.ParserRetriever @@ -371,24 +374,55 @@ type Service struct { Pipelines map[string]*Pipeline `json:"pipelines" yaml:"pipelines"` } -// MetricsPort gets the port number for the metrics endpoint from the collector config if it has been set. -func (s *Service) MetricsPort() (int32, error) { +// 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 8888, nil + return defaultAddr, 8888, nil } - _, port, netErr := net.SplitHostPort(s.GetTelemetry().Metrics.Address) + host, port, netErr := net.SplitHostPort(s.GetTelemetry().Metrics.Address) if netErr != nil && strings.Contains(netErr.Error(), "missing port in address") { - return 8888, nil + return defaultAddr, 8888, nil } else if netErr != nil { - return 0, netErr + return "", 0, netErr } i64, err := strconv.ParseInt(port, 10, 32) if err != nil { - return 0, err + return "", 0, err + } + + if host == "" { + host = defaultAddr + } + + return host, int32(i64), nil +} + +// ApplyDefaults inserts configuration defaults if it has not been set. +func (s *Service) ApplyDefaults() error { + telemetryAddr, telemetryPort, err := s.MetricsEndpoint() + if err != nil { + return err + } + tm := &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": fmt.Sprintf("%s:%d", telemetryAddr, telemetryPort), + }, + }, } - return int32(i64), nil + if s.Telemetry == nil { + s.Telemetry = tm + return nil + } + // NOTE: Merge without overwrite. If a telemetry endpoint is specified, the defaulting + // respects the configuration and returns an equal value. + if err := mergo.Merge(s.Telemetry, tm); err != nil { + return fmt.Errorf("telemetry config merge failed: %w", err) + } + return nil } // MetricsConfig comes from the collector. diff --git a/apis/v1beta1/config_test.go b/apis/v1beta1/config_test.go index 31895b3252..44828d043b 100644 --- a/apis/v1beta1/config_test.go +++ b/apis/v1beta1/config_test.go @@ -220,11 +220,13 @@ func TestConfigToMetricsPort(t *testing.T) { for _, tt := range []struct { desc string + expectedAddr string expectedPort int32 config Service }{ { "custom port", + "0.0.0.0", 9090, Service{ Telemetry: &AnyConfig{ @@ -238,6 +240,7 @@ func TestConfigToMetricsPort(t *testing.T) { }, { "bad address", + "0.0.0.0", 8888, Service{ Telemetry: &AnyConfig{ @@ -251,6 +254,7 @@ func TestConfigToMetricsPort(t *testing.T) { }, { "missing address", + "0.0.0.0", 8888, Service{ Telemetry: &AnyConfig{ @@ -264,6 +268,7 @@ func TestConfigToMetricsPort(t *testing.T) { }, { "missing metrics", + "0.0.0.0", 8888, Service{ Telemetry: &AnyConfig{}, @@ -271,14 +276,30 @@ func TestConfigToMetricsPort(t *testing.T) { }, { "missing telemetry", + "0.0.0.0", 8888, Service{}, }, + { + "configured telemetry", + "1.2.3.4", + 4567, + Service{ + Telemetry: &AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "1.2.3.4:4567", + }, + }, + }, + }, + }, } { t.Run(tt.desc, func(t *testing.T) { // these are acceptable failures, we return to the collector's default metric port - port, err := tt.config.MetricsPort() + addr, port, err := tt.config.MetricsEndpoint() 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 9be69c2234..69afc65416 100644 --- a/internal/manifests/collector/container.go +++ b/internal/manifests/collector/container.go @@ -223,7 +223,7 @@ func getConfigContainerPorts(logger logr.Logger, conf v1beta1.Config) (map[strin } } - metricsPort, err := conf.Service.MetricsPort() + _, metricsPort, err := conf.Service.MetricsEndpoint() if err != nil { logger.Info("couldn't determine metrics port from configuration, using 8888 default value", "error", err) metricsPort = 8888 diff --git a/internal/manifests/collector/service.go b/internal/manifests/collector/service.go index e5d4c65ead..a7b8813f94 100644 --- a/internal/manifests/collector/service.go +++ b/internal/manifests/collector/service.go @@ -83,7 +83,7 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) { return nil, err } - metricsPort, err := params.OtelCol.Spec.Config.Service.MetricsPort() + _, metricsPort, err := params.OtelCol.Spec.Config.Service.MetricsEndpoint() if err != nil { return nil, err } diff --git a/pkg/collector/upgrade/upgrade_test.go b/pkg/collector/upgrade/upgrade_test.go index 616b58daa8..49d23af8bb 100644 --- a/pkg/collector/upgrade/upgrade_test.go +++ b/pkg/collector/upgrade/upgrade_test.go @@ -141,7 +141,7 @@ func TestEnvVarUpdates(t *testing.T) { require.Equal(t, collectorInstance.Status.Version, persisted.Status.Version) currentV := version.Get() - currentV.OpenTelemetryCollector = "0.110.0" + currentV.OpenTelemetryCollector = "0.111.0" up := &upgrade.VersionUpgrade{ Log: logger, Version: currentV, diff --git a/pkg/collector/upgrade/v0_111_0.go b/pkg/collector/upgrade/v0_111_0.go new file mode 100644 index 0000000000..5ba22efea0 --- /dev/null +++ b/pkg/collector/upgrade/v0_111_0.go @@ -0,0 +1,23 @@ +// 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 upgrade + +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() +} diff --git a/pkg/collector/upgrade/v0_111_0_test.go b/pkg/collector/upgrade/v0_111_0_test.go new file mode 100644 index 0000000000..d8b0907e13 --- /dev/null +++ b/pkg/collector/upgrade/v0_111_0_test.go @@ -0,0 +1,98 @@ +// 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 upgrade_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/record" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" +) + +func Test0_111_0Upgrade(t *testing.T) { + + defaultCollector := v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "otel-my-instance", + Namespace: "somewhere", + }, + Status: v1beta1.OpenTelemetryCollectorStatus{ + Version: "0.110.0", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{}, + Config: v1beta1.Config{}, + }, + } + + defaultCollectorWithConfig := defaultCollector.DeepCopy() + + defaultCollectorWithConfig.Spec.Config.Service.Telemetry = &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "1.2.3.4:8888", + }, + }, + } + + tt := []struct { + name string + input v1beta1.OpenTelemetryCollector + expected v1beta1.OpenTelemetryCollector + }{ + { + name: "telemetry settings exist", + input: *defaultCollectorWithConfig, + expected: *defaultCollectorWithConfig, + }, + { + name: "telemetry settings do not exist", + input: *defaultCollector.DeepCopy(), + expected: func() v1beta1.OpenTelemetryCollector { + col := defaultCollector.DeepCopy() + col.Spec.Config.Service.Telemetry = &v1beta1.AnyConfig{ + Object: map[string]interface{}{ + "metrics": map[string]interface{}{ + "address": "0.0.0.0:8888", + }, + }, + } + return *col + }(), + }, + } + + versionUpgrade := &upgrade.VersionUpgrade{ + Log: logger, + Version: makeVersion("0.111.0"), + Client: k8sClient, + Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + col, err := versionUpgrade.ManagedInstance(context.Background(), tc.input) + if err != nil { + t.Errorf("expect err: nil but got: %v", err) + } + assert.Equal(t, tc.expected.Spec.Config.Service.Telemetry, col.Spec.Config.Service.Telemetry) + }) + } +} diff --git a/pkg/collector/upgrade/versions.go b/pkg/collector/upgrade/versions.go index 2d856c4a1f..d493583478 100644 --- a/pkg/collector/upgrade/versions.go +++ b/pkg/collector/upgrade/versions.go @@ -106,6 +106,10 @@ var ( Version: *semver.MustParse("0.110.0"), upgradeV1beta1: upgrade0_110_0, }, + { + Version: *semver.MustParse("0.111.0"), + upgradeV1beta1: upgrade0_111_0, + }, } // Latest represents the latest version that we need to upgrade. This is not necessarily the latest known version. diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml index 63c9e239e3..6fd04f5d65 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml @@ -92,6 +92,9 @@ spec: exporters: debug: null service: + telemetry: + metrics: + address: 0.0.0.0:8888 pipelines: traces: exporters: 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 b0edc6701f..3ba921ada1 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -331,6 +331,9 @@ spec: exporters: debug: null service: + telemetry: + metrics: + address: 0.0.0.0:8888 pipelines: traces: exporters: diff --git a/tests/e2e-ta-collector-mtls/ta-collector-mtls/00-assert.yaml b/tests/e2e-ta-collector-mtls/ta-collector-mtls/00-assert.yaml index 08aacf33b6..db11c838bd 100644 --- a/tests/e2e-ta-collector-mtls/ta-collector-mtls/00-assert.yaml +++ b/tests/e2e-ta-collector-mtls/ta-collector-mtls/00-assert.yaml @@ -59,9 +59,12 @@ data: - prometheus receivers: - prometheus + telemetry: + metrics: + address: 0.0.0.0:8888 kind: ConfigMap metadata: - name: prometheus-cr-collector-52e1d2ae + name: prometheus-cr-collector-19c94a81 --- apiVersion: v1 kind: Pod @@ -83,4 +86,4 @@ kind: Job metadata: name: check-ta-serving-over-https status: - succeeded: 1 \ No newline at end of file + succeeded: 1 diff --git a/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml index fb1aaebc23..e89f3f31eb 100644 --- a/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector-85dbe673 + name: stateful-collector-c055e8e3 name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml index 93f7e176a2..1a5b0b9dab 100644 --- a/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml @@ -15,7 +15,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: prometheus-kubernetessd-collector-699cdaa1 + name: prometheus-kubernetessd-collector-9c184e3a data: collector.yaml: | exporters: @@ -35,6 +35,9 @@ data: - prometheus receivers: - prometheus + telemetry: + metrics: + address: 0.0.0.0:8888 --- apiVersion: apps/v1 kind: DaemonSet diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml index dd705e927b..5185c911cb 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml @@ -40,6 +40,9 @@ data: - prometheus receivers: - prometheus + telemetry: + metrics: + address: 0.0.0.0:8888 kind: ConfigMap metadata: - name: prometheus-cr-collector-52e1d2ae + name: prometheus-cr-collector-19c94a81 diff --git a/tests/e2e/managed-reconcile/02-assert.yaml b/tests/e2e/managed-reconcile/02-assert.yaml index 0a8f5c29bf..e9bb69b67d 100644 --- a/tests/e2e/managed-reconcile/02-assert.yaml +++ b/tests/e2e/managed-reconcile/02-assert.yaml @@ -52,7 +52,7 @@ spec: apiVersion: v1 kind: ConfigMap metadata: - name: simplest-collector-a85e451c + name: simplest-collector-aec5aa11 data: collector.yaml: | receivers: @@ -65,6 +65,9 @@ data: exporters: debug: null service: + telemetry: + metrics: + address: 0.0.0.0:8888 pipelines: traces: exporters: diff --git a/tests/e2e/multiple-configmaps/00-assert.yaml b/tests/e2e/multiple-configmaps/00-assert.yaml index 54fca05399..8ff6b44ab5 100644 --- a/tests/e2e/multiple-configmaps/00-assert.yaml +++ b/tests/e2e/multiple-configmaps/00-assert.yaml @@ -25,7 +25,7 @@ spec: volumes: - name: otc-internal configMap: - name: simplest-with-configmaps-collector-a85e451c + name: simplest-with-configmaps-collector-aec5aa11 items: - key: collector.yaml path: collector.yaml diff --git a/tests/e2e/smoke-targetallocator/00-assert.yaml b/tests/e2e/smoke-targetallocator/00-assert.yaml index aa86ab8094..1ba3d195e3 100644 --- a/tests/e2e/smoke-targetallocator/00-assert.yaml +++ b/tests/e2e/smoke-targetallocator/00-assert.yaml @@ -50,6 +50,9 @@ data: - debug receivers: - jaeger + telemetry: + metrics: + address: 0.0.0.0:8888 kind: ConfigMap metadata: - name: stateful-collector-57180221 + name: stateful-collector-7a42612e diff --git a/tests/e2e/statefulset-features/00-assert.yaml b/tests/e2e/statefulset-features/00-assert.yaml index b80a130bf6..b4e2d060b8 100644 --- a/tests/e2e/statefulset-features/00-assert.yaml +++ b/tests/e2e/statefulset-features/00-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector-4b08af22 + name: stateful-collector-52b86f05 name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e/statefulset-features/01-assert.yaml b/tests/e2e/statefulset-features/01-assert.yaml index 45584c25f3..9630e500d6 100644 --- a/tests/e2e/statefulset-features/01-assert.yaml +++ b/tests/e2e/statefulset-features/01-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector-4b08af22 + name: stateful-collector-52b86f05 name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e/versioned-configmaps/00-assert.yaml b/tests/e2e/versioned-configmaps/00-assert.yaml index a1b499db1f..d0fcfd2a28 100644 --- a/tests/e2e/versioned-configmaps/00-assert.yaml +++ b/tests/e2e/versioned-configmaps/00-assert.yaml @@ -9,11 +9,11 @@ spec: volumes: - name: otc-internal configMap: - name: simple-collector-bf36603a + name: simple-collector-de9b8847 status: readyReplicas: 1 --- apiVersion: v1 kind: ConfigMap metadata: - name: simple-collector-bf36603a + name: simple-collector-de9b8847 diff --git a/tests/e2e/versioned-configmaps/01-assert.yaml b/tests/e2e/versioned-configmaps/01-assert.yaml index 169568e53a..1e291a0cb2 100644 --- a/tests/e2e/versioned-configmaps/01-assert.yaml +++ b/tests/e2e/versioned-configmaps/01-assert.yaml @@ -9,16 +9,16 @@ spec: volumes: - name: otc-internal configMap: - name: simple-collector-024c6417 + name: simple-collector-3f453d89 status: readyReplicas: 1 --- apiVersion: v1 kind: ConfigMap metadata: - name: simple-collector-024c6417 + name: simple-collector-3f453d89 --- apiVersion: v1 kind: ConfigMap metadata: - name: simple-collector-bf36603a + name: simple-collector-de9b8847 From b17f7dab2bc351016f4062eaab3dbe6c8bbcadbb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:10:47 +0200 Subject: [PATCH 13/17] Bump github.com/prometheus/client_golang from 1.20.4 to 1.20.5 (#3374) Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.20.4 to 1.20.5. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.20.4...v1.20.5) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... 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 1246d868d7..dfc431a316 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/prometheus-operator/prometheus-operator v0.76.0 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.4 + github.com/prometheus/client_golang v1.20.5 github.com/prometheus/common v0.60.0 github.com/prometheus/prometheus v0.54.1 github.com/shirou/gopsutil v3.21.11+incompatible diff --git a/go.sum b/go.sum index 67a6e88500..d840db88c3 100644 --- a/go.sum +++ b/go.sum @@ -551,8 +551,8 @@ github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3O github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= -github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= From fec94c805e1c9be09a91e289b40e4948ce2e75cb Mon Sep 17 00:00:00 2001 From: "Ben B." Date: Mon, 21 Oct 2024 16:37:55 +0200 Subject: [PATCH 14/17] prepare release v0.111.0 (#3351) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * prepare release v0.111.0 Signed-off-by: Benedikt Bongartz * Apply suggestions from code review Co-authored-by: Mikołaj Świątek Signed-off-by: Benedikt Bongartz --------- Signed-off-by: Benedikt Bongartz Co-authored-by: Mikołaj Świątek --- .chloggen/3330-python-otel-logs-exporter.yaml | 16 ----- .../TA-update-configs-to-enable-mtls.yaml | 18 ----- .chloggen/default_telemetry_settings.yaml | 19 ------ ...validation-stabilizationWindowSeconds.yaml | 18 ----- .chloggen/inst-tls.yaml | 34 ---------- .chloggen/native_sidecar.yaml | 21 ------ CHANGELOG.md | 67 +++++++++++++++++++ README.md | 2 +- RELEASE.md | 2 +- ...emetry-operator.clusterserviceversion.yaml | 6 +- ...emetry-operator.clusterserviceversion.yaml | 6 +- config/manager/kustomization.yaml | 1 + versions.txt | 12 ++-- 13 files changed, 82 insertions(+), 140 deletions(-) delete mode 100644 .chloggen/3330-python-otel-logs-exporter.yaml delete mode 100755 .chloggen/TA-update-configs-to-enable-mtls.yaml delete mode 100755 .chloggen/default_telemetry_settings.yaml delete mode 100755 .chloggen/fix_validation-stabilizationWindowSeconds.yaml delete mode 100755 .chloggen/inst-tls.yaml delete mode 100755 .chloggen/native_sidecar.yaml diff --git a/.chloggen/3330-python-otel-logs-exporter.yaml b/.chloggen/3330-python-otel-logs-exporter.yaml deleted file mode 100644 index 021c205811..0000000000 --- a/.chloggen/3330-python-otel-logs-exporter.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: auto-instrumentation - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: set OTEL_LOGS_EXPORTER env var to otlp in python instrumentation - -# One or more tracking issues related to the change -issues: [3330] - -# (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/TA-update-configs-to-enable-mtls.yaml b/.chloggen/TA-update-configs-to-enable-mtls.yaml deleted file mode 100755 index 64f318ad01..0000000000 --- a/.chloggen/TA-update-configs-to-enable-mtls.yaml +++ /dev/null @@ -1,18 +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, collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: "Enable mTLS between the TA and collector for passing secrets in the scrape_config securely" - -# One or more tracking issues related to the change -issues: [1669] - -# (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 mTLS between the collector and the target allocator (requires cert-manager). - This is necessary for passing secrets securely from the TA to the collector for scraping endpoints that have authentication. diff --git a/.chloggen/default_telemetry_settings.yaml b/.chloggen/default_telemetry_settings.yaml deleted file mode 100755 index cd2f0f31d8..0000000000 --- a/.chloggen/default_telemetry_settings.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: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Expose the Collector telemetry endpoint by default. - -# One or more tracking issues related to the change -issues: [3361] - -# (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: | - The collector v0.111.0 changes the default binding of the telemetry metrics endpoint from `0.0.0.0` to `localhost`. - To avoid any disruption we fallback to "0.0.0.0:{PORT}" as default address. - Details can be found here: [opentelemetry-collector#11251](https://github.com/open-telemetry/opentelemetry-collector/pull/11251) diff --git a/.chloggen/fix_validation-stabilizationWindowSeconds.yaml b/.chloggen/fix_validation-stabilizationWindowSeconds.yaml deleted file mode 100755 index b90f0ecbd9..0000000000 --- a/.chloggen/fix_validation-stabilizationWindowSeconds.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: collector-webhook - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: "Fixed validation of `stabilizationWindowSeconds` in autoscaler behaviour" - -# One or more tracking issues related to the change -issues: [3345] - -# (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: | - 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. diff --git a/.chloggen/inst-tls.yaml b/.chloggen/inst-tls.yaml deleted file mode 100755 index 7347b315ea..0000000000 --- a/.chloggen/inst-tls.yaml +++ /dev/null @@ -1,34 +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: Add support for specifying exporter TLS certificates in auto-instrumentation. - -# One or more tracking issues related to the change -issues: [3338] - -# (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: | - Now Instrumentation CR supports specifying TLS certificates for exporter: - ```yaml - spec: - exporter: - endpoint: https://otel-collector:4317 - tls: - secretName: otel-tls-certs - configMapName: otel-ca-bundle - # otel-ca-bundle - ca_file: ca.crt - # present in otel-tls-certs - cert_file: tls.crt - # present in otel-tls-certs - key_file: tls.key - ``` - - * Propagating secrets across namespaces can be done with https://github.com/EmberStack/kubernetes-reflector or https://github.com/zakkg3/ClusterSecret - * Restarting workloads on certificate renewal can be done with https://github.com/stakater/Reloader or https://github.com/wave-k8s/wave diff --git a/.chloggen/native_sidecar.yaml b/.chloggen/native_sidecar.yaml deleted file mode 100755 index 1637381020..0000000000 --- a/.chloggen/native_sidecar.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: collector - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add native sidecar injection behind a feature gate which is disabled by default. - -# One or more tracking issues related to the change -issues: [2376] - -# (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: | - 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 adding - the `--feature-gates=operator.sidecarcontainers.native` to the Operator args. - In the future this may will become availabe as deployment mode on the Collector CR. See [#3356](https://github.com/open-telemetry/opentelemetry-operator/issues/3356) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72fca56e33..06b21f27df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,73 @@ +## 0.111.0 + +### 💡 Enhancements 💡 + +- `auto-instrumentation`: set OTEL_LOGS_EXPORTER env var to otlp in python instrumentation (#3330) + +- `collector`: Expose the Collector telemetry endpoint by default. (#3361) + + The collector v0.111.0 changes the default binding of the telemetry metrics endpoint from `0.0.0.0` to `localhost`. + To avoid any disruption we fallback to `0.0.0.0:{PORT}` as default address. + Details can be found here: [opentelemetry-collector#11251](https://github.com/open-telemetry/opentelemetry-collector/pull/11251) + + +- `auto-instrumentation`: Add support for specifying exporter TLS certificates in auto-instrumentation. (#3338) + + Now Instrumentation CR supports specifying TLS certificates for exporter: + ```yaml + spec: + exporter: + endpoint: https://otel-collector:4317 + tls: + secretName: otel-tls-certs + configMapName: otel-ca-bundle + # otel-ca-bundle + ca_file: ca.crt + # present in otel-tls-certs + cert_file: tls.crt + # present in otel-tls-certs + key_file: tls.key + ``` + + * Propagating secrets across namespaces can be done with https://github.com/EmberStack/kubernetes-reflector or https://github.com/zakkg3/ClusterSecret + * 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 + the `--feature-gates=operator.sidecarcontainers.native` to the Operator args. + In the future this may will become availabe as deployment mode on the Collector CR. See [#3356](https://github.com/open-telemetry/opentelemetry-operator/issues/3356) + +- `target allocator, collector`: Enable mTLS between the TA and collector for passing secrets in the scrape_config securely (#1669) + + This change enables mTLS between the collector and the target allocator (requires cert-manager). + This is necessary for passing secrets securely from the TA to the collector for scraping endpoints that have authentication. Use the `operator.targetallocator.mtls` to enable this feature. See the target allocator [documentation](https://github.com/open-telemetry/opentelemetry-operator/tree/main/cmd/otel-allocator#service--pod-monitor-endpoint-credentials) for more details. + +### 🧰 Bug fixes 🧰 + +- `collector-webhook`: Fixed validation of `stabilizationWindowSeconds` in autoscaler behaviour (#3345) + + 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) +* [OpenTelemetry Contrib - v0.111.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.111.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.15.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.15.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.110.0 ### 🛑 Breaking changes 🛑 diff --git a/README.md b/README.md index c94bb0670b..cfc2867391 100644 --- a/README.md +++ b/README.md @@ -813,6 +813,7 @@ The OpenTelemetry Operator _might_ work on versions outside of the given range, | OpenTelemetry Operator | Kubernetes | Cert-Manager | Prometheus-Operator | |------------------------|----------------| ------------ |---------------------| +| v0.111.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.110.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.109.0 | v1.23 to v1.31 | v1 | v0.76.0 | | v0.108.0 | v1.23 to v1.31 | v1 | v0.76.0 | @@ -836,7 +837,6 @@ The OpenTelemetry Operator _might_ work on versions outside of the given range, | v0.90.0 | v1.23 to v1.28 | v1 | v0.69.1 | | v0.89.0 | v1.23 to v1.28 | v1 | v0.69.1 | | v0.88.0 | v1.23 to v1.28 | v1 | v0.68.0 | -| v0.87.0 | v1.23 to v1.28 | v1 | v0.68.0 | ## Contributing and Developing diff --git a/RELEASE.md b/RELEASE.md index 55570bfa3a..e44500421c 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.111.0 | @frzifus | | v0.112.0 | @yuriolisa | | v0.113.0 | @pavolloffay | | v0.114.0 | @TylerHelmuth | | v0.115.0 | @jaronoff97 | | v0.116.0 | @swiatekm | | v0.117.0 | @iblancasa | +| v0.118.0 | @frzifus | diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index 25cab56e55..cf2f802a05 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -105,7 +105,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.110.0 + name: opentelemetry-operator.v0.111.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -481,7 +481,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.110.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.111.0 livenessProbe: httpGet: path: /healthz @@ -589,7 +589,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.110.0 + version: 0.111.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index f248186c9a..8ab2219366 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -105,7 +105,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.110.0 + name: opentelemetry-operator.v0.111.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -485,7 +485,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.serviceAccountName - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.110.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.111.0 livenessProbe: httpGet: path: /healthz @@ -593,7 +593,7 @@ spec: minKubeVersion: 1.23.0 provider: name: OpenTelemetry Community - version: 0.110.0 + version: 0.111.0 webhookdefinitions: - admissionReviewVersions: - v1alpha1 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/versions.txt b/versions.txt index 1cc74d1487..2c7f385168 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.110.0 +opentelemetry-collector=0.111.0 # Represents the current release of the OpenTelemetry Operator. -operator=0.110.0 +operator=0.111.0 # Represents the current release of the Target Allocator. -targetallocator=0.110.0 +targetallocator=0.111.0 # Represents the current release of the Operator OpAMP Bridge. -operator-opamp-bridge=0.110.0 +operator-opamp-bridge=0.111.0 # Represents the current release of Java instrumentation. # Should match autoinstrumentation/java/version.txt @@ -19,7 +19,7 @@ autoinstrumentation-java=1.33.5 # Represents the current release of NodeJS instrumentation. # Should match value in autoinstrumentation/nodejs/package.json -autoinstrumentation-nodejs=0.52.1 +autoinstrumentation-nodejs=0.53.0 # Represents the current release of Python instrumentation. # Should match value in autoinstrumentation/python/requirements.txt @@ -30,7 +30,7 @@ autoinstrumentation-python=0.48b0 autoinstrumentation-dotnet=1.2.0 # Represents the current release of Go instrumentation. -autoinstrumentation-go=v0.14.0-alpha +autoinstrumentation-go=v0.15.0-alpha # Represents the current release of Apache HTTPD instrumentation. # Should match autoinstrumentation/apache-httpd/version.txt From 31ee21eedf038623eaddd99b3d0b3a9a60a8fa36 Mon Sep 17 00:00:00 2001 From: David Haja Date: Mon, 21 Oct 2024 16:40:24 +0200 Subject: [PATCH 15/17] Add support for persistentVolumeClaimRetentionPolicy field (#3354) * Add support for persistentVolumeClaimRetentionPolicy field * Removed persistentVolumeClaimRetentionPolicy field from v1alpha1 * Added separate persistentVolumeClaimRetentionPolicy e2e test * Renamed persistentVolumeClaimRetentionPolicy e2e test * Removed unnecessary PersistentVolumeClaimRetentionPolicy function * removed persistentVolumeClaimRetentionPolicy e2e test due to version difficulty and low added value * Update apis/v1beta1/common.go Co-authored-by: Jacob Aronoff * Updating api doc with typo fix --------- Co-authored-by: Jacob Aronoff Co-authored-by: Israel Blancas --- ...-persistentVolumeClaimRetentionPolicy.yaml | 16 ++++++ apis/v1beta1/collector_webhook.go | 5 ++ apis/v1beta1/collector_webhook_test.go | 15 ++++++ apis/v1beta1/common.go | 6 +++ apis/v1beta1/zz_generated.deepcopy.go | 6 +++ ...ntelemetry.io_opentelemetrycollectors.yaml | 7 +++ ...ntelemetry.io_opentelemetrycollectors.yaml | 7 +++ ...ntelemetry.io_opentelemetrycollectors.yaml | 7 +++ docs/api.md | 52 +++++++++++++++++++ internal/manifests/collector/statefulset.go | 7 +-- .../manifests/collector/statefulset_test.go | 39 ++++++++++++++ 11 files changed, 164 insertions(+), 3 deletions(-) create mode 100755 .chloggen/3305-persistentVolumeClaimRetentionPolicy.yaml diff --git a/.chloggen/3305-persistentVolumeClaimRetentionPolicy.yaml b/.chloggen/3305-persistentVolumeClaimRetentionPolicy.yaml new file mode 100755 index 0000000000..93ca955f4c --- /dev/null +++ b/.chloggen/3305-persistentVolumeClaimRetentionPolicy.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: "Add support for persistentVolumeClaimRetentionPolicy field" + +# One or more tracking issues related to the change +issues: [3305] + +# (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/collector_webhook.go b/apis/v1beta1/collector_webhook.go index 5a6b80a3b9..68b572b8c1 100644 --- a/apis/v1beta1/collector_webhook.go +++ b/apis/v1beta1/collector_webhook.go @@ -188,6 +188,11 @@ func (c CollectorWebhook) Validate(ctx context.Context, r *OpenTelemetryCollecto return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'volumeClaimTemplates'", r.Spec.Mode) } + // validate persistentVolumeClaimRetentionPolicy + if r.Spec.Mode != ModeStatefulSet && r.Spec.PersistentVolumeClaimRetentionPolicy != nil { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'persistentVolumeClaimRetentionPolicy'", r.Spec.Mode) + } + // validate tolerations if r.Spec.Mode == ModeSidecar && len(r.Spec.Tolerations) > 0 { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'tolerations'", r.Spec.Mode) diff --git a/apis/v1beta1/collector_webhook_test.go b/apis/v1beta1/collector_webhook_test.go index a30d74a66c..72ab56aab0 100644 --- a/apis/v1beta1/collector_webhook_test.go +++ b/apis/v1beta1/collector_webhook_test.go @@ -763,6 +763,21 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, expectedErr: "does not support the attribute 'volumeClaimTemplates'", }, + { + name: "invalid mode with persistentVolumeClaimRetentionPolicy", + otelcol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Mode: v1beta1.ModeSidecar, + StatefulSetCommonFields: v1beta1.StatefulSetCommonFields{ + PersistentVolumeClaimRetentionPolicy: &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ + WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, + WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType, + }, + }, + }, + }, + expectedErr: "does not support the attribute 'persistentVolumeClaimRetentionPolicy'", + }, { name: "invalid mode with tolerations", otelcol: v1beta1.OpenTelemetryCollector{ diff --git a/apis/v1beta1/common.go b/apis/v1beta1/common.go index cf31de5118..77044771a5 100644 --- a/apis/v1beta1/common.go +++ b/apis/v1beta1/common.go @@ -15,6 +15,7 @@ package v1beta1 import ( + appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -243,4 +244,9 @@ type StatefulSetCommonFields struct { // +optional // +listType=atomic VolumeClaimTemplates []v1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` + // PersistentVolumeClaimRetentionPolicy describes the lifecycle of persistent volume claims + // created from volumeClaimTemplates. + // This only works with the following OpenTelemetryCollector modes: statefulset. + // +optional + PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"` } diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index eaf24ed0ba..b508f0be76 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -19,6 +19,7 @@ package v1beta1 import ( + appsv1 "k8s.io/api/apps/v1" "k8s.io/api/autoscaling/v2" "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" @@ -680,6 +681,11 @@ func (in *StatefulSetCommonFields) DeepCopyInto(out *StatefulSetCommonFields) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.PersistentVolumeClaimRetentionPolicy != nil { + in, out := &in.PersistentVolumeClaimRetentionPolicy, &out.PersistentVolumeClaimRetentionPolicy + *out = new(appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatefulSetCommonFields. diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 594e0f4aea..6ccb1c9e5f 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -6963,6 +6963,13 @@ spec: type: boolean type: object type: object + persistentVolumeClaimRetentionPolicy: + properties: + whenDeleted: + type: string + whenScaled: + type: string + type: object podAnnotations: additionalProperties: type: string diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 594e0f4aea..6ccb1c9e5f 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -6963,6 +6963,13 @@ spec: type: boolean type: object type: object + persistentVolumeClaimRetentionPolicy: + properties: + whenDeleted: + type: string + whenScaled: + type: string + type: object podAnnotations: additionalProperties: type: string diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 05baaaa5df..fc36f4deb5 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -6949,6 +6949,13 @@ spec: type: boolean type: object type: object + persistentVolumeClaimRetentionPolicy: + properties: + whenDeleted: + type: string + whenScaled: + type: string + type: object podAnnotations: additionalProperties: type: string diff --git a/docs/api.md b/docs/api.md index dc327344f8..d921a01256 100644 --- a/docs/api.md +++ b/docs/api.md @@ -31176,6 +31176,15 @@ This only works with the following OpenTelemetryCollector mode's: daemonset, sta ObservabilitySpec defines how telemetry data gets handled.
false + + persistentVolumeClaimRetentionPolicy + object + + PersistentVolumeClaimRetentionPolicy describes the lifecycle of persistent volume claims +created from volumeClaimTemplates. +This only works with the following OpenTelemetryCollector modes: statefulset.
+ + false podAnnotations map[string]string @@ -40936,6 +40945,49 @@ The operator.observability.prometheus feature gate must be enabled to use this f +### OpenTelemetryCollector.spec.persistentVolumeClaimRetentionPolicy +[↩ Parent](#opentelemetrycollectorspec-1) + + + +PersistentVolumeClaimRetentionPolicy describes the lifecycle of persistent volume claims +created from volumeClaimTemplates. +This only works with the following OpenTelemetryCollector modes: statefulset. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
whenDeletedstring + WhenDeleted specifies what happens to PVCs created from StatefulSet +VolumeClaimTemplates when the StatefulSet is deleted. The default policy +of `Retain` causes PVCs to not be affected by StatefulSet deletion. The +`Delete` policy causes those PVCs to be deleted.
+
false
whenScaledstring + WhenScaled specifies what happens to PVCs created from StatefulSet +VolumeClaimTemplates when the StatefulSet is scaled down. The default +policy of `Retain` causes PVCs to not be affected by a scaledown. The +`Delete` policy causes the associated PVCs for any excess pods above +the replica count to be deleted.
+
false
+ + ### OpenTelemetryCollector.spec.podDisruptionBudget [↩ Parent](#opentelemetrycollectorspec-1) diff --git a/internal/manifests/collector/statefulset.go b/internal/manifests/collector/statefulset.go index 6b7e92ec05..3a98611c4e 100644 --- a/internal/manifests/collector/statefulset.go +++ b/internal/manifests/collector/statefulset.go @@ -73,9 +73,10 @@ func StatefulSet(params manifests.Params) (*appsv1.StatefulSet, error) { TopologySpreadConstraints: params.OtelCol.Spec.TopologySpreadConstraints, }, }, - Replicas: params.OtelCol.Spec.Replicas, - PodManagementPolicy: "Parallel", - VolumeClaimTemplates: VolumeClaimTemplates(params.OtelCol), + Replicas: params.OtelCol.Spec.Replicas, + PodManagementPolicy: "Parallel", + VolumeClaimTemplates: VolumeClaimTemplates(params.OtelCol), + PersistentVolumeClaimRetentionPolicy: params.OtelCol.Spec.PersistentVolumeClaimRetentionPolicy, }, }, nil } diff --git a/internal/manifests/collector/statefulset_test.go b/internal/manifests/collector/statefulset_test.go index 916e25e4bb..1963afe131 100644 --- a/internal/manifests/collector/statefulset_test.go +++ b/internal/manifests/collector/statefulset_test.go @@ -178,6 +178,45 @@ func TestStatefulSetVolumeClaimTemplates(t *testing.T) { assert.Equal(t, resource.MustParse("1Gi"), ss.Spec.VolumeClaimTemplates[0].Spec.Resources.Requests["storage"]) } +func TestStatefulSetPeristentVolumeRetentionPolicy(t *testing.T) { + // prepare + otelcol := v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "my-instance", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Mode: "statefulset", + StatefulSetCommonFields: v1beta1.StatefulSetCommonFields{ + PersistentVolumeClaimRetentionPolicy: &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ + WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, + WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType, + }, + }, + }, + } + cfg := config.New() + + params := manifests.Params{ + OtelCol: otelcol, + Config: cfg, + Log: logger, + } + + // test + ss, err := StatefulSet(params) + require.NoError(t, err) + + // assert PersistentVolumeClaimRetentionPolicy added + assert.NotNil(t, ss.Spec.PersistentVolumeClaimRetentionPolicy) + + // assert correct WhenDeleted value + assert.Equal(t, ss.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted, appsv1.RetainPersistentVolumeClaimRetentionPolicyType) + + // assert correct WhenScaled value + assert.Equal(t, ss.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled, appsv1.DeletePersistentVolumeClaimRetentionPolicyType) + +} + func TestStatefulSetPodAnnotations(t *testing.T) { // prepare testPodAnnotationValues := map[string]string{"annotation-key": "annotation-value"} From 698b0787447f60088ef7bf4ca144d011c534cd88 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 22 Oct 2024 09:49:41 +0200 Subject: [PATCH 16/17] Add nodejs auto-instrumentation support for linux/s390x,linux/ppc64le (#3362) Signed-off-by: Pavol Loffay Co-authored-by: Israel Blancas --- .chloggen/nodejs-ibm-platforms.yaml | 16 ++++++++++++++++ .../publish-autoinstrumentation-nodejs.yaml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 .chloggen/nodejs-ibm-platforms.yaml diff --git a/.chloggen/nodejs-ibm-platforms.yaml b/.chloggen/nodejs-ibm-platforms.yaml new file mode 100755 index 0000000000..50d44d5a78 --- /dev/null +++ b/.chloggen/nodejs-ibm-platforms.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: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add Nodejs auto-instrumentation image builds for linux/s390x,linux/ppc64le. + +# One or more tracking issues related to the change +issues: [3322] + +# (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/publish-autoinstrumentation-nodejs.yaml b/.github/workflows/publish-autoinstrumentation-nodejs.yaml index 45b368fbf6..083b7306ae 100644 --- a/.github/workflows/publish-autoinstrumentation-nodejs.yaml +++ b/.github/workflows/publish-autoinstrumentation-nodejs.yaml @@ -71,7 +71,7 @@ jobs: uses: docker/build-push-action@v6 with: context: autoinstrumentation/nodejs - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le push: ${{ github.event_name == 'push' }} build-args: version=${{ env.VERSION }} tags: ${{ steps.meta.outputs.tags }} From 70dff6948ad00a971840b1dce71e8c4d3a52e02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Tue, 22 Oct 2024 12:11:27 +0200 Subject: [PATCH 17/17] Install all tools using the same macro (#3376) controller-tools and envtest were installed in a different way than other tools for no good reason. Fix this. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 183887ec7c..6652b06b86 100644 --- a/Makefile +++ b/Makefile @@ -493,12 +493,12 @@ kind: ## Download kind locally if necessary. .PHONY: controller-gen controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. $(CONTROLLER_GEN): $(LOCALBIN) - @test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) + $(call go-get-tool,$(CONTROLLER_GEN), sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION)) .PHONY: envtest envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) - @test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + $(call go-get-tool,$(ENVTEST), sigs.k8s.io/controller-runtime/tools/setup-envtest,latest) CRDOC = $(shell pwd)/bin/crdoc .PHONY: crdoc