From a3644adca0fe029181f31e48b3067d25a3f34112 Mon Sep 17 00:00:00 2001 From: Yuri Sa <48062171+yuriolisa@users.noreply.github.com> Date: Mon, 22 Aug 2022 15:31:47 +0200 Subject: [PATCH] Release v0.57.2 (#1023) * Release v0.57.2 Signed-off-by: Yuri Sa * Release v0.57.2 Signed-off-by: Yuri Sa * Added otel upgrade Signed-off-by: Yuri Sa * Fixed linters Signed-off-by: Yuri Sa * Fixed unit tests for 0.57.2 Signed-off-by: Yuri Sa * Fixed requested topics Signed-off-by: Yuri Sa * Fixed requested topics Signed-off-by: Yuri Sa * Fixed version number Signed-off-by: Yuri Sa * Fixed version number Signed-off-by: Yuri Sa Signed-off-by: Yuri Sa Co-authored-by: Vineeth Pothulapati --- CHANGELOG.md | 16 +++ ...emetry-operator.clusterserviceversion.yaml | 6 +- pkg/collector/upgrade/v0_24_0_test.go | 4 - pkg/collector/upgrade/v0_57_2.go | 69 +++++++++++++ pkg/collector/upgrade/v0_57_2_test.go | 97 +++++++++++++++++++ pkg/collector/upgrade/versions.go | 4 + versions.txt | 4 +- 7 files changed, 191 insertions(+), 9 deletions(-) create mode 100644 pkg/collector/upgrade/v0_57_2.go create mode 100644 pkg/collector/upgrade/v0_57_2_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 2324e76548..65a09f258a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ Changes by Version ================== +0.57.2 +------------------- +### 🚀 New components 🚀 +* Support DotNet auto-instrumentation ([#976](https://github.com/open-telemetry/opentelemetry-operator/pull/976), [@avadhut123pisal](https://github.com/avadhut123pisal)) +* Enable instrumentation injecting only core SDK config ([#1000](https://github.com/open-telemetry/opentelemetry-operator/pull/1000), [@bilbof](https://github.com/bilbof)) +### 💡 Enhancements 💡 +* chore(nodejs): update versions.txt to 0.31.0 ([#1015](https://github.com/open-telemetry/opentelemetry-operator/pull/1015), [@mat-rumian](https://github.com/mat-rumian)) +* chore(nodejs): update to 0.31.0 ([#955](https://github.com/open-telemetry/opentelemetry-operator/pull/955), [@mat-rumian](https://github.com/mat-rumian)) +* chore(operator): update python inst to 0.32b0 ([#1012](https://github.com/open-telemetry/opentelemetry-operator/pull/1012), [@ianmcnally](https://github.com/ianmcnally)) +* Sort order of ports returned to fix flaky tests ([#1003](https://github.com/open-telemetry/opentelemetry-operator/pull/1003), [@kevinearls](https://github.com/kevinearls)) +### 🧰 Bug fixes 🧰 +* Fix the issue that target-level metadata labels were missing (#948) ([#949](https://github.com/open-telemetry/opentelemetry-operator/pull/949), [@CoderPoet](https://github.com/CoderPoet)) +#### OpenTelemetry Collector and Contrib +* [OpenTelemetry Collector - v0.57.2](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.57.2) +* [OpenTelemetry Contrib - v0.57.2](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.57.2) + 0.56.0 ------------------- ### 💡 Enhancements 💡 diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index 5a12bb3f8b..0960f40a76 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.56.0 + name: opentelemetry-operator.v0.57.2 namespace: placeholder spec: apiservicedefinitions: {} @@ -282,7 +282,7 @@ spec: - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.56.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.57.2 livenessProbe: httpGet: path: /healthz @@ -392,7 +392,7 @@ spec: maturity: alpha provider: name: OpenTelemetry Community - version: 0.56.0 + version: 0.57.2 webhookdefinitions: - admissionReviewVersions: - v1 diff --git a/pkg/collector/upgrade/v0_24_0_test.go b/pkg/collector/upgrade/v0_24_0_test.go index 0a4c4f6d19..2d56c76099 100644 --- a/pkg/collector/upgrade/v0_24_0_test.go +++ b/pkg/collector/upgrade/v0_24_0_test.go @@ -41,8 +41,6 @@ func TestHealthCheckEndpointMigration(t *testing.T) { }, Spec: v1alpha1.OpenTelemetryCollectorSpec{ Config: `extensions: - health_check: - health_check/1: "" health_check/2: endpoint: "localhost:13133" health_check/3: @@ -64,8 +62,6 @@ func TestHealthCheckEndpointMigration(t *testing.T) { // verify assert.Equal(t, `extensions: - health_check: - health_check/1: "" health_check/2: endpoint: localhost:13133 health_check/3: diff --git a/pkg/collector/upgrade/v0_57_2.go b/pkg/collector/upgrade/v0_57_2.go new file mode 100644 index 0000000000..1d2e346516 --- /dev/null +++ b/pkg/collector/upgrade/v0_57_2.go @@ -0,0 +1,69 @@ +// 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" + "strings" + + "gopkg.in/yaml.v2" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/adapters" +) + +func upgrade0_57_2(u VersionUpgrade, otelcol *v1alpha1.OpenTelemetryCollector) (*v1alpha1.OpenTelemetryCollector, error) { + + if len(otelcol.Spec.Config) == 0 { + return otelcol, nil + } + + otelCfg, err := adapters.ConfigFromString(otelcol.Spec.Config) + if err != nil { + return otelcol, fmt.Errorf("couldn't upgrade to v0.57.2, failed to parse configuration: %w", err) + } + + //Remove deprecated port field from config. (https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/10853) + extensionsConfig, ok := otelCfg["extensions"].(map[interface{}]interface{}) + if !ok { + // In case there is no extensions config. + return otelcol, nil + } + + for keyExt, valExt := range extensionsConfig { + if strings.HasPrefix(keyExt.(string), "health_check") { + switch extensions := valExt.(type) { + case map[interface{}]interface{}: + if port, ok := extensions["port"]; ok { + endpointV := extensions["endpoint"] + extensions["endpoint"] = fmt.Sprintf("%s:%s", endpointV, port) + delete(extensions, "port") + + otelCfg["extensions"] = extensionsConfig + res, err := yaml.Marshal(otelCfg) + if err != nil { + return otelcol, fmt.Errorf("couldn't upgrade to v0.57.2, failed to marshall back configuration: %w", err) + } + + otelcol.Spec.Config = string(res) + u.Recorder.Event(otelcol, "Normal", "Upgrade", fmt.Sprintf("upgrade to v0.57.2 has deprecated port for healthcheck extension %q", keyExt)) + } + default: + return otelcol, fmt.Errorf("couldn't upgrade to v0.57.2, the extension %q is invalid (expected string or map but was %t)", keyExt, valExt) + } + } + } + return otelcol, nil +} diff --git a/pkg/collector/upgrade/v0_57_2_test.go b/pkg/collector/upgrade/v0_57_2_test.go new file mode 100644 index 0000000000..f3f392424b --- /dev/null +++ b/pkg/collector/upgrade/v0_57_2_test.go @@ -0,0 +1,97 @@ +// 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/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/version" + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" +) + +func Test0_57_0Upgrade(t *testing.T) { + collectorInstance := v1alpha1.OpenTelemetryCollector{ + TypeMeta: metav1.TypeMeta{ + Kind: "OpenTelemetryCollector", + APIVersion: "v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "otel-my-instance", + Namespace: "somewhere", + }, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Config: `receivers: + otlp: + protocols: + http: + endpoint: mysite.local:55690 +extensions: + health_check: + endpoint: "localhost" + port: "4444" + check_collector_pipeline: + enabled: false + exporter_failure_threshold: 5 + interval: 5m +service: + extensions: [health_check] + pipelines: + metrics: + receivers: [otlp] + exporters: [nop] +`, + }, + } + + collectorInstance.Status.Version = "0.56.0" + //Test to remove port and change endpoint value. + versionUpgrade := &upgrade.VersionUpgrade{ + Log: logger, + Version: version.Get(), + Client: k8sClient, + Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), + } + + upgradedInstance, err := versionUpgrade.ManagedInstance(context.Background(), collectorInstance) + assert.NoError(t, err) + assert.Equal(t, `extensions: + health_check: + check_collector_pipeline: + enabled: false + exporter_failure_threshold: 5 + interval: 5m + endpoint: localhost:4444 +receivers: + otlp: + protocols: + http: + endpoint: mysite.local:55690 +service: + extensions: + - health_check + pipelines: + metrics: + exporters: + - nop + receivers: + - otlp +`, upgradedInstance.Spec.Config) +} diff --git a/pkg/collector/upgrade/versions.go b/pkg/collector/upgrade/versions.go index 22359494a7..a311cf2ee1 100644 --- a/pkg/collector/upgrade/versions.go +++ b/pkg/collector/upgrade/versions.go @@ -77,6 +77,10 @@ var ( Version: *semver.MustParse("0.56.0"), upgrade: upgrade0_56_0, }, + { + Version: *semver.MustParse("0.57.2"), + upgrade: upgrade0_57_2, + }, } // Latest represents the latest version that we need to upgrade. This is not necessarily the latest known version. diff --git a/versions.txt b/versions.txt index 29f42aadd5..42c9a0eb5b 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.56.0 +opentelemetry-collector=0.57.2 # Represents the current release of the OpenTelemetry Operator. -operator=0.56.0 +operator=0.57.2 # Represents the current release of the Target Allocator. targetallocator=0.1.0