diff --git a/CHANGELOG.md b/CHANGELOG.md index a689ed081d..11a912080d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ Changes by Version ================== +0.43.0 +------------------- +* Bumped OpenTelemetry Collector to v0.43.0 +* Upgrade to 0.43.0 will move the metrics CLI arguments into the config, in response to ([#680](https://github.com/open-telemetry/opentelemetry-operator/pull/680), [@yuriolisa](https://github.com/yuriolisa)) +* Add unique label and selector for operator objects ([#697](https://github.com/open-telemetry/opentelemetry-operator/pull/697), [@pavolloffay](https://github.com/pavolloffay)) +* Bump operator-sdk to 1.17 ([#692](https://github.com/open-telemetry/opentelemetry-operator/pull/692), [@pavolloffay](https://github.com/pavolloffay)) +* Update java instrumentation to 1.10.1 ([#688](https://github.com/open-telemetry/opentelemetry-operator/pull/688), [@anuraaga](https://github.com/anuraaga)) +* Update nodejs instrumentation to 0.27.0 ([#687](https://github.com/open-telemetry/opentelemetry-operator/pull/687), [@anuraaga](https://github.com/anuraaga)) +* Update python instrumentation to 0.28b1 ([#686](https://github.com/open-telemetry/opentelemetry-operator/pull/686), [@anuraaga](https://github.com/anuraaga)) +* Add b3, jaeger, ottrace propagators to python instrumentation ([#684](https://github.com/open-telemetry/opentelemetry-operator/pull/684), [@anuraaga](https://github.com/anuraaga)) +* Add env support to instrumentation kind ([#674](https://github.com/open-telemetry/opentelemetry-operator/pull/674), [@Duncan-tree-zhou](https://github.com/Duncan-tree-zhou)) +* Fix collector config update ([#670](https://github.com/open-telemetry/opentelemetry-operator/pull/670), [@mcariapas](https://github.com/mcariapas)) + 0.42.0 ------------------- * Bumped OpenTelemetry Collector to v0.42.0 diff --git a/README.md b/README.md index 6a10a962f3..ecdf1e7e1c 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,7 @@ The OpenTelemetry Operator *might* work on versions outside of the given range, | OpenTelemetry Operator | Kubernetes | Cert-Manager | |------------------------|----------------------|----------------------| +| v0.43.0 | v1.21 to v1.23 | 1.6.1 | | v0.42.0 | v1.21 to v1.23 | 1.6.1 | | v0.41.1 | v1.21 to v1.23 | 1.6.1 | | v0.41.0 | v1.20 to v1.22 | 1.6.1 | diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index 2882f81592..0a4302dee7 100644 --- a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -37,7 +37,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.42.0 + name: opentelemetry-operator.v0.43.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -265,7 +265,7 @@ spec: - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:v0.42.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:v0.43.0 livenessProbe: httpGet: path: /healthz @@ -369,7 +369,7 @@ spec: maturity: alpha provider: name: OpenTelemetry Community - version: 0.42.0 + version: 0.43.0 webhookdefinitions: - admissionReviewVersions: - v1 diff --git a/pkg/collector/upgrade/v0_43_0.go b/pkg/collector/upgrade/v0_43_0.go new file mode 100644 index 0000000000..5548d61476 --- /dev/null +++ b/pkg/collector/upgrade/v0_43_0.go @@ -0,0 +1,91 @@ +// 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 ( + "fmt" + "sort" + + "gopkg.in/yaml.v2" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/adapters" +) + +func upgrade0_43_0(cl client.Client, otelcol *v1alpha1.OpenTelemetryCollector) (*v1alpha1.OpenTelemetryCollector, error) { + // return if args exist + if len(otelcol.Spec.Args) == 0 { + return otelcol, nil + } + + //Removing deprecated Spec.Args (--metrics-addr and --metrics-level) based on + // https://github.com/open-telemetry/opentelemetry-collector/pull/4695 + //Both args can be used now on the Spec.Config + foundMetricsArgs := make(map[string]string) + for argKey, argValue := range otelcol.Spec.Args { + if argKey == "--metrics-addr" || argKey == "--metrics-level" { + foundMetricsArgs[argKey] = argValue + delete(otelcol.Spec.Args, argKey) + } + } + + // If we find metrics being used on Spec.Args we'll move to the syntax on Spec.Config + if len(foundMetricsArgs) > 0 { + cfg, err := adapters.ConfigFromString(otelcol.Spec.Config) + if err != nil { + return otelcol, fmt.Errorf("couldn't upgrade to v0.43.0, failed to parse configuration: %w", err) + } + serviceConfig, ok := cfg["service"].(map[interface{}]interface{}) + if !ok { + cfg["service"] = make(map[interface{}]interface{}) + serviceConfig, _ = cfg["service"].(map[interface{}]interface{}) + } + telemetryConfig, ok := serviceConfig["telemetry"].(map[interface{}]interface{}) + if !ok { + serviceConfig["telemetry"] = make(map[interface{}]interface{}) + telemetryConfig, _ = serviceConfig["telemetry"].(map[interface{}]interface{}) + } + metricsConfig, ok := telemetryConfig["metrics"].(map[interface{}]interface{}) + if !ok { + telemetryConfig["metrics"] = make(map[interface{}]interface{}) + metricsConfig, _ = telemetryConfig["metrics"].(map[interface{}]interface{}) + } + + // if there are already those Args under Spec.Config + // then we won't override them. + if len(metricsConfig) == 0 { + if val, ok := foundMetricsArgs["--metrics-addr"]; ok { + metricsConfig["address"] = val + } + if val, ok := foundMetricsArgs["--metrics-level"]; ok { + metricsConfig["level"] = val + } + } + cfg["service"] = serviceConfig + res, err := yaml.Marshal(cfg) + if err != nil { + return otelcol, fmt.Errorf("couldn't upgrade to v0.43.0, failed to marshall back configuration: %w", err) + } + otelcol.Spec.Config = string(res) + keys := make([]string, 0, len(foundMetricsArgs)) + for k := range foundMetricsArgs { + keys = append(keys, k) + } + sort.Strings(keys) + otelcol.Status.Messages = append(otelcol.Status.Messages, fmt.Sprintf("upgrade to v0.43.0 dropped the deprecated metrics arguments "+"i.e. %v from otelcol custom resource otelcol.spec.args and adding them to otelcol.spec.config.service.telemetry.metrics, if no metrics arguments are configured already.", keys)) + } + return otelcol, nil +} diff --git a/pkg/collector/upgrade/v0_43_0_test.go b/pkg/collector/upgrade/v0_43_0_test.go new file mode 100644 index 0000000000..e259261de5 --- /dev/null +++ b/pkg/collector/upgrade/v0_43_0_test.go @@ -0,0 +1,141 @@ +// 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/apimachinery/pkg/types" + + "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" +) + +func Test0_43_0Upgrade(t *testing.T) { + // prepare + nsn := types.NamespacedName{Name: "my-instance", Namespace: "default"} + existing := v1alpha1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: nsn.Name, + Namespace: nsn.Namespace, + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "opentelemetry-operator", + }, + }, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Args: map[string]string{ + "--metrics-addr": ":8988", + "--metrics-level": "detailed", + "--test-upgrade43": "true", + "--test-arg1": "otel", + }, + Config: ` +receivers: + otlp/mtls: + protocols: + http: + endpoint: mysite.local:55690 + +exporters: + otlp: + endpoint: "example.com" + +service: + pipelines: + traces: + receivers: [otlp/mtls] + exporters: [otlp] +`, + }, + } + existing.Status.Version = "0.42.0" + + // test + res, err := upgrade.ManagedInstance(context.Background(), logger, version.Get(), nil, existing) + assert.NoError(t, err) + + // verify + assert.Equal(t, map[string]string{ + "--test-upgrade43": "true", + "--test-arg1": "otel", + }, res.Spec.Args) + + // verify + assert.Equal(t, `exporters: + otlp: + endpoint: example.com +receivers: + otlp/mtls: + protocols: + http: + endpoint: mysite.local:55690 +service: + pipelines: + traces: + exporters: + - otlp + receivers: + - otlp/mtls + telemetry: + metrics: + address: :8988 + level: detailed +`, res.Spec.Config) + + assert.Equal(t, "upgrade to v0.43.0 dropped the deprecated metrics arguments "+"i.e. [--metrics-addr --metrics-level] from otelcol custom resource otelcol.spec.args and "+"adding them to otelcol.spec.config.service.telemetry.metrics, if no metrics arguments are configured already.", res.Status.Messages[0]) + + configWithMetrics := `exporters: + otlp: + endpoint: example.com +receivers: + otlp/mtls: + protocols: + http: + endpoint: mysite.local:55690 +service: + pipelines: + traces: + exporters: + - otlp + receivers: + - otlp/mtls + telemetry: + metrics: + address: :8988 + level: detailed +` + existing.Spec.Config = configWithMetrics + existing.Spec.Args = map[string]string{ + "--metrics-addr": ":8988", + "--metrics-level": "detailed", + "--test-upgrade43": "true", + "--test-arg1": "otel", + } + res, err = upgrade.ManagedInstance(context.Background(), logger, version.Get(), nil, existing) + assert.NoError(t, err) + + // verify + assert.Equal(t, configWithMetrics, res.Spec.Config) + assert.Equal(t, map[string]string{ + "--test-upgrade43": "true", + "--test-arg1": "otel", + }, res.Spec.Args) + + assert.Equal(t, "upgrade to v0.43.0 dropped the deprecated metrics arguments "+"i.e. [--metrics-addr --metrics-level] from otelcol custom resource otelcol.spec.args and "+"adding them to otelcol.spec.config.service.telemetry.metrics, if no metrics arguments are configured already.", res.Status.Messages[0]) +} diff --git a/pkg/collector/upgrade/versions.go b/pkg/collector/upgrade/versions.go index 067686330d..641b75510a 100644 --- a/pkg/collector/upgrade/versions.go +++ b/pkg/collector/upgrade/versions.go @@ -70,6 +70,10 @@ var ( Version: *semver.MustParse("0.41.0"), upgrade: upgrade0_41_0, }, + { + Version: *semver.MustParse("0.43.0"), + upgrade: upgrade0_43_0, + }, } // Latest represents the latest version that we need to upgrade. This is not necessarily the latest known version. diff --git a/tests/e2e/instrumentation-java/00-install-collector.yaml b/tests/e2e/instrumentation-java/00-install-collector.yaml index b823086361..f8e1e98e07 100644 --- a/tests/e2e/instrumentation-java/00-install-collector.yaml +++ b/tests/e2e/instrumentation-java/00-install-collector.yaml @@ -4,8 +4,6 @@ metadata: name: sidecar spec: mode: sidecar - args: - metrics-level: detailed config: | receivers: otlp: diff --git a/tests/e2e/instrumentation-nodejs/00-install-collector.yaml b/tests/e2e/instrumentation-nodejs/00-install-collector.yaml index b823086361..f8e1e98e07 100644 --- a/tests/e2e/instrumentation-nodejs/00-install-collector.yaml +++ b/tests/e2e/instrumentation-nodejs/00-install-collector.yaml @@ -4,8 +4,6 @@ metadata: name: sidecar spec: mode: sidecar - args: - metrics-level: detailed config: | receivers: otlp: diff --git a/tests/e2e/instrumentation-python/00-install-collector.yaml b/tests/e2e/instrumentation-python/00-install-collector.yaml index b823086361..f8e1e98e07 100644 --- a/tests/e2e/instrumentation-python/00-install-collector.yaml +++ b/tests/e2e/instrumentation-python/00-install-collector.yaml @@ -4,8 +4,6 @@ metadata: name: sidecar spec: mode: sidecar - args: - metrics-level: detailed config: | receivers: otlp: diff --git a/tests/e2e/smoke-pod-annotations/00-install.yaml b/tests/e2e/smoke-pod-annotations/00-install.yaml index ee3dac5484..cce1909fa0 100644 --- a/tests/e2e/smoke-pod-annotations/00-install.yaml +++ b/tests/e2e/smoke-pod-annotations/00-install.yaml @@ -24,5 +24,3 @@ spec: receivers: [jaeger] processors: [] exporters: [logging] - args: - metrics-level: detailed diff --git a/tests/e2e/smoke-restarting-deployment/00-install.yaml b/tests/e2e/smoke-restarting-deployment/00-install.yaml index fbc93e109b..7ff13711ee 100644 --- a/tests/e2e/smoke-restarting-deployment/00-install.yaml +++ b/tests/e2e/smoke-restarting-deployment/00-install.yaml @@ -17,5 +17,3 @@ spec: receivers: [jaeger] processors: [] exporters: [logging] - args: - metrics-level: detailed diff --git a/tests/e2e/smoke-restarting-deployment/01-install-second-config.yaml b/tests/e2e/smoke-restarting-deployment/01-install-second-config.yaml index bc9362af97..78f90878bb 100644 --- a/tests/e2e/smoke-restarting-deployment/01-install-second-config.yaml +++ b/tests/e2e/smoke-restarting-deployment/01-install-second-config.yaml @@ -20,5 +20,4 @@ spec: receivers: [jaeger, otlp] processors: [] exporters: [logging] - args: - metrics-level: detailed + diff --git a/tests/e2e/smoke-sidecar/00-install.yaml b/tests/e2e/smoke-sidecar/00-install.yaml index 33d0805210..1d498c6268 100644 --- a/tests/e2e/smoke-sidecar/00-install.yaml +++ b/tests/e2e/smoke-sidecar/00-install.yaml @@ -4,8 +4,6 @@ metadata: name: sidecar-for-my-app spec: mode: sidecar - args: - metrics-level: detailed config: | receivers: jaeger: diff --git a/tests/e2e/smoke-simplest/00-install.yaml b/tests/e2e/smoke-simplest/00-install.yaml index 205c59226e..a1a6120f7c 100644 --- a/tests/e2e/smoke-simplest/00-install.yaml +++ b/tests/e2e/smoke-simplest/00-install.yaml @@ -18,6 +18,4 @@ spec: traces: receivers: [jaeger] processors: [] - exporters: [logging] - args: - metrics-level: detailed \ No newline at end of file + exporters: [logging] \ No newline at end of file diff --git a/versions.txt b/versions.txt index 6e90ed47ce..b973f60265 100644 --- a/versions.txt +++ b/versions.txt @@ -2,10 +2,10 @@ # 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.42.0 +opentelemetry-collector=0.43.0 # Represents the current release of the OpenTelemetry Operator. -operator=0.42.0 +operator=0.43.0 # Represents the current release of the Target Allocator. targetallocator=0.1.0