Skip to content

Commit

Permalink
Merge branch 'main' of github.com:jaronoff97/opentelemetry-operator i…
Browse files Browse the repository at this point in the history
…nto fix-allocation-problems
  • Loading branch information
jaronoff97 committed Aug 22, 2022
2 parents 981d439 + a3644ad commit 31c7da3
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 9 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 💡
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -392,7 +392,7 @@ spec:
maturity: alpha
provider:
name: OpenTelemetry Community
version: 0.56.0
version: 0.57.2
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
4 changes: 0 additions & 4 deletions pkg/collector/upgrade/v0_24_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
69 changes: 69 additions & 0 deletions pkg/collector/upgrade/v0_57_2.go
Original file line number Diff line number Diff line change
@@ -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
}
97 changes: 97 additions & 0 deletions pkg/collector/upgrade/v0_57_2_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 4 additions & 0 deletions pkg/collector/upgrade/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 31c7da3

Please sign in to comment.