diff --git a/.chloggen/3281-marshal-config.yaml b/.chloggen/3281-marshal-config.yaml new file mode 100755 index 0000000000..50b55927cc --- /dev/null +++ b/.chloggen/3281-marshal-config.yaml @@ -0,0 +1,38 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix Configuration marshalling for v1beta1 OpenTelemetryCollector instances. + +# One or more tracking issues related to the change +issues: [3281] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + Previously, the v1beta1 OpenTelemetryCollector CR's config field was incorrectly + marshalled, potentially causing issues when storing in etcd or retrieving via kubectl. + This fix ensures that the config is properly marshalled, maintaining the correct + structure and data types. For example, a config with nested maps and arrays will now + be correctly preserved when stored and retrieved, instead of being flattened or + losing structure. + + As an example, configuration like this: + + receivers: + otlp: + protocols: + grpc: + http: + + Would be retrieved from the Kubernetes cluster as: + + receivers: + otlp: + protocols: + + The specified protocols were not there anymore before this fix. \ No newline at end of file diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 2d88c7617e..adc1f13d5f 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -91,10 +91,11 @@ func (c *AnyConfig) UnmarshalJSON(b []byte) error { } // MarshalJSON specifies how to convert this object into JSON. -func (c *AnyConfig) MarshalJSON() ([]byte, error) { - if c == nil { +func (c AnyConfig) MarshalJSON() ([]byte, error) { + if c.Object == nil { return []byte("{}"), nil } + return json.Marshal(c.Object) } @@ -334,6 +335,27 @@ func (c *Config) Yaml() (string, error) { return buf.String(), nil } +// MarshalJSON marshalls the Config field. +func (c Config) MarshalJSON() ([]byte, error) { + // When you marshal a struct that embeds itself or a type that directly or indirectly refers back to itself, + // Go's JSON marshaling can lead to infinite recursion. To avoid this, we create an alias of the struct + // (Config), so Go no longer considers it the same type. + // This allows you to embed the struct safely within itself without triggering that infinite loop. + type Alias Config + // Ensure we call the custom marshaller for AnyConfig for the Receivers + receiversJSON, err := json.Marshal(c.Receivers) + if err != nil { + return nil, err + } + return json.Marshal(&struct { + *Alias + Receivers json.RawMessage `json:"receivers,omitempty"` + }{ + Alias: (*Alias)(&c), + Receivers: receiversJSON, + }) +} + // Returns null objects in the config. func (c *Config) nullObjects() []string { var nullKeys []string diff --git a/apis/v1beta1/config_test.go b/apis/v1beta1/config_test.go index 31895b3252..f63cca138a 100644 --- a/apis/v1beta1/config_test.go +++ b/apis/v1beta1/config_test.go @@ -15,9 +15,13 @@ package v1beta1 import ( + "context" "encoding/json" + "fmt" + "log" "os" "path" + "path/filepath" "strings" "testing" @@ -26,11 +30,227 @@ import ( "github.com/stretchr/testify/require" go_yaml "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/client-go/kubernetes/scheme" "k8s.io/utils/ptr" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/yaml" ) +func TestCreateConfigInKubernetesEmptyValues(t *testing.T) { + testScheme := scheme.Scheme + err := AddToScheme(testScheme) + require.NoError(t, err) + + testEnv := &envtest.Environment{ + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + } + + cfg, err := testEnv.Start() + require.NoError(t, err) + defer func() { + errStop := testEnv.Stop() + require.NoError(t, errStop) + }() + + k8sClient, err := client.New(cfg, client.Options{Scheme: testScheme}) + if err != nil { + fmt.Printf("failed to setup a Kubernetes client: %v", err) + os.Exit(1) + } + + newCollector := &OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "my-collector", + Namespace: "default", + }, + Spec: OpenTelemetryCollectorSpec{ + UpgradeStrategy: UpgradeStrategyNone, + Config: Config{ + Exporters: AnyConfig{ + Object: map[string]interface{}{ + "logging": map[string]interface{}{}, + }, + }, + Receivers: AnyConfig{ + Object: map[string]interface{}{ + "otlp": map[string]interface{}{ + "protocols": map[string]interface{}{ + "grpc": map[string]interface{}{}, + "http": map[string]interface{}{}, + }, + }, + }, + }, + Processors: &AnyConfig{ + Object: map[string]interface{}{ + "resourcedetection": map[string]interface{}{}, + }, + }, + Service: Service{ + Pipelines: map[string]*Pipeline{ + "traces": { + Receivers: []string{"otlp"}, + Exporters: []string{"logging"}, + }, + }, + }, + }, + }, + } + + err = k8sClient.Create(context.TODO(), newCollector) + if err != nil { + log.Fatal(err) + } + + // Fetch the created OpenTelemetryCollector + otelCollector := &OpenTelemetryCollector{} + err = k8sClient.Get(context.TODO(), types.NamespacedName{ + Name: "my-collector", + Namespace: "default", + }, otelCollector) + + if err != nil { + log.Fatal(err) + } + + jsonData, err := json.Marshal(otelCollector.Spec) + if err != nil { + log.Fatal(err) + } + + require.Contains(t, string(jsonData), "{\"grpc\":{},\"http\":{}}") + require.Contains(t, string(jsonData), "\"resourcedetection\":{}") + + unmarshalledCollector := &OpenTelemetryCollector{} + err = json.Unmarshal(jsonData, &unmarshalledCollector.Spec) + require.NoError(t, err) + + require.NotNil(t, unmarshalledCollector.Spec.Config.Receivers.Object["otlp"]) + + otlpReceiver, ok := unmarshalledCollector.Spec.Config.Receivers.Object["otlp"].(map[string]interface{}) + require.True(t, ok, "otlp receiver should be a map") + protocols, ok := otlpReceiver["protocols"].(map[string]interface{}) + require.True(t, ok, "protocols should be a map") + + grpc, ok := protocols["grpc"] + require.True(t, ok, "grpc protocol should exist") + require.NotNil(t, grpc, "grpc protocol should be nil") + + http, ok := protocols["http"] + require.True(t, ok, "http protocol should exist") + require.NotNil(t, http, "http protocol should be nil") + + require.NotNil(t, unmarshalledCollector.Spec.Config.Receivers.Object["otlp"]) + + _, ok = unmarshalledCollector.Spec.Config.Processors.Object["resourcedetection"].(map[string]interface{}) + require.True(t, ok, "resourcedetector processor should be a map") +} + +func TestCreateConfigInKubernetesNullValues(t *testing.T) { + testScheme := scheme.Scheme + err := AddToScheme(testScheme) + require.NoError(t, err) + + testEnv := &envtest.Environment{ + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + } + + cfg, err := testEnv.Start() + require.NoError(t, err) + defer func() { + errStop := testEnv.Stop() + require.NoError(t, errStop) + }() + + k8sClient, err := client.New(cfg, client.Options{Scheme: testScheme}) + if err != nil { + fmt.Printf("failed to setup a Kubernetes client: %v", err) + os.Exit(1) + } + + newCollector := &OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "my-collector", + Namespace: "default", + }, + Spec: OpenTelemetryCollectorSpec{ + UpgradeStrategy: UpgradeStrategyNone, + Config: Config{ + Exporters: AnyConfig{ + Object: map[string]interface{}{ + "logging": map[string]interface{}{}, + }, + }, + Receivers: AnyConfig{ + Object: map[string]interface{}{ + "otlp": map[string]interface{}{ + "protocols": map[string]interface{}{ + "grpc": nil, + "http": nil, + }, + }, + }, + }, + Service: Service{ + Pipelines: map[string]*Pipeline{ + "traces": { + Receivers: []string{"otlp"}, + Exporters: []string{"logging"}, + }, + }, + }, + }, + }, + } + + err = k8sClient.Create(context.TODO(), newCollector) + if err != nil { + log.Fatal(err) + } + + // Fetch the created OpenTelemetryCollector + otelCollector := &OpenTelemetryCollector{} + err = k8sClient.Get(context.TODO(), types.NamespacedName{ + Name: "my-collector", + Namespace: "default", + }, otelCollector) + + if err != nil { + log.Fatal(err) + } + + jsonData, err := json.Marshal(otelCollector.Spec) + if err != nil { + log.Fatal(err) + } + + require.Contains(t, string(jsonData), "{\"grpc\":null,\"http\":null") + + unmarshalledCollector := &OpenTelemetryCollector{} + err = json.Unmarshal(jsonData, &unmarshalledCollector.Spec) + require.NoError(t, err) + + require.NotNil(t, unmarshalledCollector.Spec.Config.Receivers.Object["otlp"]) + + otlpReceiver, ok := unmarshalledCollector.Spec.Config.Receivers.Object["otlp"].(map[string]interface{}) + require.True(t, ok, "otlp receiver should be a map") + protocols, ok := otlpReceiver["protocols"].(map[string]interface{}) + require.True(t, ok, "protocols should be a map") + + grpc, ok := protocols["grpc"] + require.True(t, ok, "grpc protocol should exist") + require.Nil(t, grpc, "grpc protocol should be nil") + + http, ok := protocols["http"] + require.True(t, ok, "http protocol should exist") + require.Nil(t, http, "http protocol should be nil") +} + func TestConfigFiles(t *testing.T) { files, err := os.ReadDir("./testdata") require.NoError(t, err) @@ -558,3 +778,70 @@ func TestConfig_GetExporterPorts(t *testing.T) { }) } } + +func TestAnyConfig_MarshalJSON(t *testing.T) { + tests := []struct { + name string + config AnyConfig + want string + wantErr bool + }{ + { + name: "nil Object", + config: AnyConfig{}, + want: "{}", + }, + { + name: "empty Object", + config: AnyConfig{ + Object: map[string]interface{}{}, + }, + want: "{}", + }, + { + name: "Object with nil value", + config: AnyConfig{ + Object: map[string]interface{}{ + "key": nil, + }, + }, + want: `{"key":null}`, + }, + { + name: "Object with empty map value", + config: AnyConfig{ + Object: map[string]interface{}{ + "key": map[string]interface{}{}, + }, + }, + want: `{"key":{}}`, + }, + { + name: "Object with non-empty values", + config: AnyConfig{ + Object: map[string]interface{}{ + "string": "value", + "number": 42, + "bool": true, + "map": map[string]interface{}{ + "nested": "data", + }, + }, + }, + want: `{"bool":true,"map":{"nested":"data"},"number":42,"string":"value"}`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := tt.config.MarshalJSON() + if (err != nil) != tt.wantErr { + t.Errorf("AnyConfig.MarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + return + } + if string(got) != tt.want { + t.Errorf("AnyConfig.MarshalJSON() = %v, want %v", string(got), tt.want) + } + }) + } +} diff --git a/apis/v1beta1/opentelemetrycollector_types.go b/apis/v1beta1/opentelemetrycollector_types.go index dd20af943d..170e117177 100644 --- a/apis/v1beta1/opentelemetrycollector_types.go +++ b/apis/v1beta1/opentelemetrycollector_types.go @@ -15,6 +15,8 @@ package v1beta1 import ( + "encoding/json" + appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -52,6 +54,27 @@ type OpenTelemetryCollector struct { // Hub exists to allow for conversion. func (*OpenTelemetryCollector) Hub() {} +// MarshalJSON marshalls the OpenTelemetry Collector to JSON. +func (o *OpenTelemetryCollector) MarshalJSON() ([]byte, error) { + // When you marshal a struct that embeds itself or a type that directly or indirectly refers back to itself, + // Go's JSON marshaling can lead to infinite recursion. To avoid this, we create an alias of the struct + // (Config), so Go no longer considers it the same type. + // This allows you to embed the struct safely within itself without triggering that infinite loop. + type Alias OpenTelemetryCollector + // Ensure we call the custom marshaller for Spec + specJSON, err := json.Marshal(&o.Spec) + if err != nil { + return nil, err + } + return json.Marshal(&struct { + *Alias + Spec json.RawMessage `json:"spec,omitempty"` + }{ + Alias: (*Alias)(o), + Spec: specJSON, + }) +} + //+kubebuilder:object:root=true // OpenTelemetryCollectorList contains a list of OpenTelemetryCollector. @@ -143,6 +166,27 @@ type OpenTelemetryCollectorSpec struct { DeploymentUpdateStrategy appsv1.DeploymentStrategy `json:"deploymentUpdateStrategy,omitempty"` } +// MarshalJSON marshalls the OpenTelemetryCollectorSpec field. +func (s *OpenTelemetryCollectorSpec) MarshalJSON() ([]byte, error) { + // When you marshal a struct that embeds itself or a type that directly or indirectly refers back to itself, + // Go's JSON marshaling can lead to infinite recursion. To avoid this, we create an alias of the struct + // (Config), so Go no longer considers it the same type. + // This allows you to embed the struct safely within itself without triggering that infinite loop. + type Alias OpenTelemetryCollectorSpec + // Ensure we call the custom marshaller for Config + configJSON, err := json.Marshal(s.Config) + if err != nil { + return nil, err + } + return json.Marshal(&struct { + *Alias + Config json.RawMessage `json:"config,omitempty"` + }{ + Alias: (*Alias)(s), + Config: configJSON, + }) +} + // TargetAllocatorEmbedded defines the configuration for the Prometheus target allocator, embedded in the // OpenTelemetryCollector spec. type TargetAllocatorEmbedded struct { diff --git a/apis/v1beta1/opentelemetrycollector_types_test.go b/apis/v1beta1/opentelemetrycollector_types_test.go new file mode 100644 index 0000000000..feaa07c012 --- /dev/null +++ b/apis/v1beta1/opentelemetrycollector_types_test.go @@ -0,0 +1,147 @@ +// 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 v1beta1 + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestOpenTelemetryCollector_MarshalJSON(t *testing.T) { + collector := &OpenTelemetryCollector{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "opentelemetry.io/v1beta1", + Kind: "OpenTelemetryCollector", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-collector", + Namespace: "default", + }, + Spec: OpenTelemetryCollectorSpec{ + Config: Config{ + Receivers: AnyConfig{ + Object: map[string]interface{}{ + "otlp": map[string]interface{}{ + "protocols": map[string]interface{}{ + "grpc": nil, + }, + }, + }, + }, + Processors: &AnyConfig{ + Object: map[string]interface{}{ + "batch": nil, + }, + }, + Exporters: AnyConfig{ + Object: map[string]interface{}{ + "otlp": map[string]interface{}{ + "endpoint": "otelcol:4317", + }, + }, + }, + Service: Service{ + Pipelines: map[string]*Pipeline{ + "traces": { + Receivers: []string{"otlp"}, + Processors: []string{"batch"}, + Exporters: []string{"otlp"}, + }, + }, + }, + }, + }, + } + marshaledJSON, err := json.Marshal(collector) + assert.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(marshaledJSON, &result) + assert.NoError(t, err) + + spec, ok := result["spec"].(map[string]interface{}) + assert.True(t, ok, "spec should be a JSON object") + + config, ok := spec["config"].(map[string]interface{}) + assert.True(t, ok, "config should be a JSON object") + + receivers, ok := config["receivers"].(map[string]interface{}) + assert.True(t, ok, "receivers should be present in config") + assert.Contains(t, receivers, "otlp") + + service, ok := config["service"].(map[string]interface{}) + assert.True(t, ok, "service should be present in config") + assert.Contains(t, service, "pipelines") +} + +func TestOpenTelemetryCollectorSpec_MarshalJSON(t *testing.T) { + spec := &OpenTelemetryCollectorSpec{ + Mode: "deployment", + Config: Config{ + Receivers: AnyConfig{ + Object: map[string]interface{}{ + "otlp": map[string]interface{}{ + "protocols": map[string]interface{}{ + "grpc": map[string]interface{}{}, + }, + }, + }, + }, + }, + } + + jsonData, err := json.Marshal(spec) + if err != nil { + t.Fatalf("Failed to marshal OpenTelemetryCollectorSpec: %v", err) + } + + var result map[string]interface{} + err = json.Unmarshal(jsonData, &result) + if err != nil { + t.Fatalf("Failed to unmarshal JSON data: %v", err) + } + + if mode, ok := result["mode"].(string); !ok || mode != "deployment" { + t.Errorf("Expected mode to be 'deployment', got %v", result["mode"]) + } + + config, ok := result["config"].(map[string]interface{}) + if !ok { + t.Fatalf("Expected config to be a map[string]interface{}, got %T", result["config"]) + } + + receivers, ok := config["receivers"].(map[string]interface{}) + if !ok { + t.Fatalf("Expected receivers to be a map[string]interface{}, got %T", config["receivers"]) + } + + otlp, ok := receivers["otlp"].(map[string]interface{}) + if !ok { + t.Fatalf("Expected otlp to be a map[string]interface{}, got %T", receivers["otlp"]) + } + + protocols, ok := otlp["protocols"].(map[string]interface{}) + if !ok { + t.Fatalf("Expected protocols to be a map[string]interface{}, got %T", otlp["protocols"]) + } + + _, ok = protocols["grpc"].(map[string]interface{}) + if !ok { + t.Fatalf("Expected grpc to be a map[string]interface{}, got %T", protocols["grpc"]) + } +} diff --git a/controllers/builder_test.go b/controllers/builder_test.go index e3b495e00a..8c4583aee3 100644 --- a/controllers/builder_test.go +++ b/controllers/builder_test.go @@ -152,7 +152,7 @@ service: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-operator-config/sha256": "2d266e55025628659355f1271b689d6fb53648ef6cd5595831f5835d18e59a25", + "opentelemetry-operator-config/sha256": "0e4f000d343bffbb2720617c6f76215a5cbb53ade9032e29372bdf7f22b52225", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -430,7 +430,7 @@ service: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-operator-config/sha256": "2d266e55025628659355f1271b689d6fb53648ef6cd5595831f5835d18e59a25", + "opentelemetry-operator-config/sha256": "0e4f000d343bffbb2720617c6f76215a5cbb53ade9032e29372bdf7f22b52225", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -744,7 +744,7 @@ service: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-operator-config/sha256": "2d266e55025628659355f1271b689d6fb53648ef6cd5595831f5835d18e59a25", + "opentelemetry-operator-config/sha256": "0e4f000d343bffbb2720617c6f76215a5cbb53ade9032e29372bdf7f22b52225", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -1303,7 +1303,7 @@ service: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-operator-config/sha256": "42773025f65feaf30df59a306a9e38f1aaabe94c8310983beaddb7f648d699b0", + "opentelemetry-operator-config/sha256": "451c0c2de4a1081f7c4c636174a00b45a0df08a75968f657bcfa06b8fd98e0c6", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -1760,7 +1760,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-operator-config/sha256": "42773025f65feaf30df59a306a9e38f1aaabe94c8310983beaddb7f648d699b0", + "opentelemetry-operator-config/sha256": "451c0c2de4a1081f7c4c636174a00b45a0df08a75968f657bcfa06b8fd98e0c6", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", diff --git a/internal/manifests/collector/daemonset_test.go b/internal/manifests/collector/daemonset_test.go index 7b52066224..2a8ecbf16e 100644 --- a/internal/manifests/collector/daemonset_test.go +++ b/internal/manifests/collector/daemonset_test.go @@ -61,7 +61,7 @@ func TestDaemonSetNewDefault(t *testing.T) { // verify sha256 podAnnotation expectedAnnotations := map[string]string{ - "opentelemetry-operator-config/sha256": "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", + "opentelemetry-operator-config/sha256": "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -158,11 +158,11 @@ func TestDaemonsetPodAnnotations(t *testing.T) { require.NoError(t, err) // Add sha256 podAnnotation - testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d" + testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f" expectedAnnotations := map[string]string{ "annotation-key": "annotation-value", - "opentelemetry-operator-config/sha256": "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", + "opentelemetry-operator-config/sha256": "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", diff --git a/internal/manifests/collector/deployment_test.go b/internal/manifests/collector/deployment_test.go index c36ec5852e..dff3488cf1 100644 --- a/internal/manifests/collector/deployment_test.go +++ b/internal/manifests/collector/deployment_test.go @@ -103,7 +103,7 @@ func TestDeploymentNewDefault(t *testing.T) { // verify sha256 podAnnotation expectedAnnotations := map[string]string{ - "opentelemetry-operator-config/sha256": "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", + "opentelemetry-operator-config/sha256": "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -160,11 +160,11 @@ func TestDeploymentPodAnnotations(t *testing.T) { require.NoError(t, err) // Add sha256 podAnnotation - testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d" + testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f" expectedPodAnnotationValues := map[string]string{ "annotation-key": "annotation-value", - "opentelemetry-operator-config/sha256": "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", + "opentelemetry-operator-config/sha256": "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", diff --git a/internal/manifests/collector/statefulset_test.go b/internal/manifests/collector/statefulset_test.go index 916e25e4bb..cb4b7e8ab0 100644 --- a/internal/manifests/collector/statefulset_test.go +++ b/internal/manifests/collector/statefulset_test.go @@ -66,7 +66,7 @@ func TestStatefulSetNewDefault(t *testing.T) { // verify sha256 podAnnotation expectedAnnotations := map[string]string{ - "opentelemetry-operator-config/sha256": "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", + "opentelemetry-operator-config/sha256": "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", @@ -204,11 +204,11 @@ func TestStatefulSetPodAnnotations(t *testing.T) { require.NoError(t, err) // Add sha256 podAnnotation - testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d" + testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f" expectedAnnotations := map[string]string{ "annotation-key": "annotation-value", - "opentelemetry-operator-config/sha256": "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", + "opentelemetry-operator-config/sha256": "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", "prometheus.io/path": "/metrics", "prometheus.io/port": "8888", "prometheus.io/scrape": "true", diff --git a/internal/manifests/manifestutils/annotations_test.go b/internal/manifests/manifestutils/annotations_test.go index 7ae4673a8e..e17c0dc5f1 100644 --- a/internal/manifests/manifestutils/annotations_test.go +++ b/internal/manifests/manifestutils/annotations_test.go @@ -48,7 +48,7 @@ func TestDefaultAnnotations(t *testing.T) { assert.Equal(t, "true", podAnnotations["prometheus.io/scrape"]) assert.Equal(t, "8888", podAnnotations["prometheus.io/port"]) assert.Equal(t, "/metrics", podAnnotations["prometheus.io/path"]) - assert.Equal(t, "5b3b62aa5e0a3c7250084c2b49190e30b72fc2ad352ffbaa699224e1aa900834", podAnnotations["opentelemetry-operator-config/sha256"]) + assert.Equal(t, "da678471a1bebed4dc643526ec1ea20572b787f5b37da985adc6e50de30ddd3e", podAnnotations["opentelemetry-operator-config/sha256"]) } func TestNonDefaultPodAnnotation(t *testing.T) { @@ -81,7 +81,7 @@ func TestNonDefaultPodAnnotation(t *testing.T) { assert.NotContains(t, podAnnotations, "prometheus.io/scrape", "Prometheus scrape annotation should not exist in pod annotations") assert.NotContains(t, podAnnotations, "prometheus.io/port", "Prometheus port annotation should not exist in pod annotations") assert.NotContains(t, podAnnotations, "prometheus.io/path", "Prometheus path annotation should not exist in pod annotations") - assert.Equal(t, "fbcdae6a02b2115cd5ca4f34298202ab041d1dfe62edebfaadb48b1ee178231d", podAnnotations["opentelemetry-operator-config/sha256"]) + assert.Equal(t, "6207c0917232f2b3514cc175299e1639adcec9fa4e14f54e6e95ba035d3a0e4f", podAnnotations["opentelemetry-operator-config/sha256"]) } func TestUserAnnotations(t *testing.T) { @@ -114,7 +114,7 @@ func TestUserAnnotations(t *testing.T) { assert.Equal(t, "false", annotations["prometheus.io/scrape"]) assert.Equal(t, "1234", annotations["prometheus.io/port"]) assert.Equal(t, "/test", annotations["prometheus.io/path"]) - assert.Equal(t, "29cb15a4b87f8c6284e7c3377f6b6c5c74519f5aee8ca39a90b3cf3ca2043c4d", podAnnotations["opentelemetry-operator-config/sha256"]) + assert.Equal(t, "aa48219365373b529e2b506136fe65214b821b6616b9fa84bc9ea1c0e6f85f75", podAnnotations["opentelemetry-operator-config/sha256"]) } func TestAnnotationsPropagateDown(t *testing.T) { diff --git a/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml index fb1aaebc23..eff9152652 100644 --- a/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-features/00-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector-85dbe673 + name: stateful-collector-57be076a name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml index 93f7e176a2..b5e3fa770b 100644 --- a/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml @@ -15,7 +15,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: prometheus-kubernetessd-collector-699cdaa1 + name: prometheus-kubernetessd-collector-8dccf5a4 data: collector.yaml: | exporters: diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml index dd705e927b..99c546b073 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml @@ -42,4 +42,4 @@ data: - prometheus kind: ConfigMap metadata: - name: prometheus-cr-collector-52e1d2ae + name: prometheus-cr-collector-7c62d362 diff --git a/tests/e2e/managed-reconcile/02-assert.yaml b/tests/e2e/managed-reconcile/02-assert.yaml index 0a8f5c29bf..f9e7e1a445 100644 --- a/tests/e2e/managed-reconcile/02-assert.yaml +++ b/tests/e2e/managed-reconcile/02-assert.yaml @@ -52,7 +52,7 @@ spec: apiVersion: v1 kind: ConfigMap metadata: - name: simplest-collector-a85e451c + name: simplest-collector-01c314f8 data: collector.yaml: | receivers: diff --git a/tests/e2e/multiple-configmaps/00-assert.yaml b/tests/e2e/multiple-configmaps/00-assert.yaml index 54fca05399..9a82cf977d 100644 --- a/tests/e2e/multiple-configmaps/00-assert.yaml +++ b/tests/e2e/multiple-configmaps/00-assert.yaml @@ -25,7 +25,7 @@ spec: volumes: - name: otc-internal configMap: - name: simplest-with-configmaps-collector-a85e451c + name: simplest-with-configmaps-collector-01c314f8 items: - key: collector.yaml path: collector.yaml diff --git a/tests/e2e/smoke-targetallocator/00-assert.yaml b/tests/e2e/smoke-targetallocator/00-assert.yaml index aa86ab8094..c22fa82a86 100644 --- a/tests/e2e/smoke-targetallocator/00-assert.yaml +++ b/tests/e2e/smoke-targetallocator/00-assert.yaml @@ -52,4 +52,4 @@ data: - jaeger kind: ConfigMap metadata: - name: stateful-collector-57180221 + name: stateful-collector-1ba72234 diff --git a/tests/e2e/statefulset-features/00-assert.yaml b/tests/e2e/statefulset-features/00-assert.yaml index b80a130bf6..2ae47eaaae 100644 --- a/tests/e2e/statefulset-features/00-assert.yaml +++ b/tests/e2e/statefulset-features/00-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector-4b08af22 + name: stateful-collector-dabfd914 name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e/statefulset-features/01-assert.yaml b/tests/e2e/statefulset-features/01-assert.yaml index 45584c25f3..0945333b49 100644 --- a/tests/e2e/statefulset-features/01-assert.yaml +++ b/tests/e2e/statefulset-features/01-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector-4b08af22 + name: stateful-collector-dabfd914 name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e/versioned-configmaps/00-assert.yaml b/tests/e2e/versioned-configmaps/00-assert.yaml index a1b499db1f..6157543dd0 100644 --- a/tests/e2e/versioned-configmaps/00-assert.yaml +++ b/tests/e2e/versioned-configmaps/00-assert.yaml @@ -9,11 +9,11 @@ spec: volumes: - name: otc-internal configMap: - name: simple-collector-bf36603a + name: simple-collector-e6f9fffe status: readyReplicas: 1 --- apiVersion: v1 kind: ConfigMap metadata: - name: simple-collector-bf36603a + name: simple-collector-e6f9fffe diff --git a/tests/e2e/versioned-configmaps/01-assert.yaml b/tests/e2e/versioned-configmaps/01-assert.yaml index 169568e53a..5f02b611f7 100644 --- a/tests/e2e/versioned-configmaps/01-assert.yaml +++ b/tests/e2e/versioned-configmaps/01-assert.yaml @@ -9,16 +9,16 @@ spec: volumes: - name: otc-internal configMap: - name: simple-collector-024c6417 + name: simple-collector-9e04e315 status: readyReplicas: 1 --- apiVersion: v1 kind: ConfigMap metadata: - name: simple-collector-024c6417 + name: simple-collector-9e04e315 --- apiVersion: v1 kind: ConfigMap metadata: - name: simple-collector-bf36603a + name: simple-collector-e6f9fffe