Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Otel Operator release 0.43.0 #680

Merged
merged 21 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 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
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
-------------------
* Bumped OpenTelemetry Collector to v0.43.0
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved
* Upgrade to 0.43.0 will move the metrics CLI arguments into the config, in response to ([#4695](https://github.com/open-telemetry/opentelemetry-collector/pull/4695), [@codebote](https://github.com/codeboten))
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
* Add unique label and selector for operator objects ([#697](https://github.com/open-telemetry/opentelemetry-operator/pull/697), [@pavolloffay](https://github.com/pavolloffay))
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
* 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 All @@ -9,6 +22,7 @@ Changes by Version
* Remove publishing operator image to quay.io ([#661](https://github.com/open-telemetry/opentelemetry-operator/pull/661), [@pavolloffay](https://github.com/pavolloffay))
* Use target allocator from GHCR ([#660](https://github.com/open-telemetry/opentelemetry-operator/pull/660), [@pavolloffay](https://github.com/pavolloffay))


yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
0.41.1
-------------------
* Add support for nodejs and python image defaulting and upgrade ([#607](https://github.com/open-telemetry/opentelemetry-operator/pull/607), [@pavolloffay](https://github.com/pavolloffay))
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 @@ -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
Expand Down Expand Up @@ -369,7 +369,7 @@ spec:
maturity: alpha
provider:
name: OpenTelemetry Community
version: 0.42.0
version: 0.43.0
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
96 changes: 96 additions & 0 deletions pkg/collector/upgrade/v0_43_0.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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"
"reflect"
"sort"
"strings"

"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) {
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
// return if args exist
if len(otelcol.Spec.Args) == 0 {
return otelcol, nil
}

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 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 {

yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
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 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)

yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
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 := reflect.ValueOf(foundMetricsArgs).MapKeys()

sort.Slice(keys, func(i, j int) bool {
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
return strings.Compare(keys[i].String(), keys[j].String()) <= 0
})

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 settings are configured already.", keys))
}

return otelcol, nil
}
61 changes: 61 additions & 0 deletions pkg/collector/upgrade/v0_43_0_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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"
"github.com/stretchr/testify/require"
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 TestRemoveMetricsArgs(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",
},
},
}
existing.Status.Version = "0.42.0"

require.Contains(t, existing.Spec.Args, "--metrics-addr")
require.Contains(t, existing.Spec.Args, "--metrics-level")

// test
res, err := upgrade.ManagedInstance(context.Background(), logger, version.Get(), nil, existing)
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
assert.NoError(t, err)

// verify
assert.NotContains(t, res.Spec.Args, "--metrics-addr")
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
assert.NotContains(t, res.Spec.Args, "--metrics-level")
}
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:
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
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:
yuriolisa marked this conversation as resolved.
Show resolved Hide resolved
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