Skip to content

Commit

Permalink
Otel Operator release 0.43.0 (#680)
Browse files Browse the repository at this point in the history
* Otel Operator release 0.43.0

* Fixing typo

* Upgrade script to version 0.43.0

* Including versions reference

* Fixing Lint tests

* Adding metrics changes into CHANGELOG

* Removed comment and fixed changelog

* Added new PR on Changelog and added lint fixes

* Added missing header

* Fixing upgrade routine

* Adding missing operator-sdk PR

* Change method of sorting args and fixing test

* fixing test logic

* Change method of sorting args and fixing test

* Fixed Changelog links

* Fixed Changelog links

* Change lint format on version tests

* Fixed typos on test

* Fixed typos on test

* Fixed Changelog and added description in test file

* Removed empty lines
  • Loading branch information
yuriolisa authored Feb 10, 2022
1 parent 371cc30 commit 6787b10
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 22 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
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.42.0
name: opentelemetry-operator.v0.43.0
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -285,7 +285,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
Expand Down Expand Up @@ -377,7 +377,7 @@ spec:
maturity: alpha
provider:
name: OpenTelemetry Community
version: 0.42.0
version: 0.43.0
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
91 changes: 91 additions & 0 deletions pkg/collector/upgrade/v0_43_0.go
Original file line number Diff line number Diff line change
@@ -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
}
141 changes: 141 additions & 0 deletions pkg/collector/upgrade/v0_43_0_test.go
Original file line number Diff line number Diff line change
@@ -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])
}
4 changes: 4 additions & 0 deletions pkg/collector/upgrade/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/instrumentation-java/00-install-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ metadata:
name: sidecar
spec:
mode: sidecar
args:
metrics-level: detailed
config: |
receivers:
otlp:
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/instrumentation-nodejs/00-install-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ metadata:
name: sidecar
spec:
mode: sidecar
args:
metrics-level: detailed
config: |
receivers:
otlp:
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/instrumentation-python/00-install-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ metadata:
name: sidecar
spec:
mode: sidecar
args:
metrics-level: detailed
config: |
receivers:
otlp:
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/smoke-pod-annotations/00-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ spec:
receivers: [jaeger]
processors: []
exporters: [logging]
args:
metrics-level: detailed
2 changes: 0 additions & 2 deletions tests/e2e/smoke-restarting-deployment/00-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ spec:
receivers: [jaeger]
processors: []
exporters: [logging]
args:
metrics-level: detailed
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ spec:
receivers: [jaeger, otlp]
processors: []
exporters: [logging]
args:
metrics-level: detailed
2 changes: 0 additions & 2 deletions tests/e2e/smoke-sidecar/00-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ metadata:
name: sidecar-for-my-app
spec:
mode: sidecar
args:
metrics-level: detailed
config: |
receivers:
jaeger:
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/smoke-simplest/00-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ spec:
traces:
receivers: [jaeger]
processors: []
exporters: [logging]
args:
metrics-level: detailed
exporters: [logging]
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.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
Expand Down

0 comments on commit 6787b10

Please sign in to comment.