diff --git a/.chloggen/issue-4481.yaml b/.chloggen/issue-4481.yaml new file mode 100644 index 0000000000..086cd7c533 --- /dev/null +++ b/.chloggen/issue-4481.yaml @@ -0,0 +1,16 @@ +# 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: opamp + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "OpAMP Bridge: collector.DeepCopy() causes full spec updates → DaemonSet mode fails (should patch spec.config only)" + +# One or more tracking issues related to the change +issues: [https://github.com/open-telemetry/opentelemetry-operator/pull/4482] + +# (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: diff --git a/cmd/operator-opamp-bridge/internal/operator/client.go b/cmd/operator-opamp-bridge/internal/operator/client.go index 66a4f15905..d46b2ae53d 100644 --- a/cmd/operator-opamp-bridge/internal/operator/client.go +++ b/cmd/operator-opamp-bridge/internal/operator/client.go @@ -102,9 +102,21 @@ func (c Client) Apply(name string, namespace string, configmap *protobufs.AgentC if instance == nil { return c.create(ctx, name, namespace, updatedCollector) } + + + if instance.Spec.Mode == v1beta1.ModeDaemonSet { + return c.updateConfigOnly(ctx, instance, updatedCollector) + } return c.update(ctx, instance, updatedCollector) } +// patch ONLY spec.config on an existing CR +func (c Client) updateConfigOnly(ctx context.Context, existing *v1beta1.OpenTelemetryCollector, desired *v1beta1.OpenTelemetryCollector) error { + base := existing.DeepCopy() + existing.Spec.Config = desired.Spec.Config // only mutate spec.config + return c.k8sClient.Patch(ctx, existing, client.MergeFrom(base)) +} + func (c Client) validateComponents(collectorConfig *v1beta1.Config) error { if len(c.componentsAllowed) == 0 { return nil