From 8614fa9ee6a4136bac0b9747c615dada9f5e6be5 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 23 Sep 2025 14:55:36 +0200 Subject: [PATCH 1/3] Set TA OpAMP status version when upgrading Signed-off-by: Pavol Loffay --- internal/status/opampbridge/handle.go | 4 +--- internal/status/targetallocator/handle.go | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/status/opampbridge/handle.go b/internal/status/opampbridge/handle.go index b060299ee3..68ef5419fa 100644 --- a/internal/status/opampbridge/handle.go +++ b/internal/status/opampbridge/handle.go @@ -32,10 +32,8 @@ func HandleReconcileStatus(ctx context.Context, log logr.Logger, params manifest return ctrl.Result{}, err } changed := params.OpAMPBridge.DeepCopy() + changed.Status.Version = version.OperatorOpAMPBridge() - if changed.Status.Version == "" { - changed.Status.Version = version.OperatorOpAMPBridge() - } statusPatch := client.MergeFrom(¶ms.OpAMPBridge) if err := params.Client.Status().Patch(ctx, changed, statusPatch); err != nil { return ctrl.Result{}, fmt.Errorf("failed to apply status changes to the OpenTelemetry CR: %w", err) diff --git a/internal/status/targetallocator/handle.go b/internal/status/targetallocator/handle.go index 243b6ae138..10c4c7abe1 100644 --- a/internal/status/targetallocator/handle.go +++ b/internal/status/targetallocator/handle.go @@ -26,16 +26,14 @@ const ( // HandleReconcileStatus handles updating the status of the CRDs managed by the operator. func HandleReconcileStatus(ctx context.Context, log logr.Logger, params targetallocator.Params, err error) (ctrl.Result, error) { - log.V(2).Info("updating opampbridge status") + log.V(2).Info("updating target allocator status") if err != nil { params.Recorder.Event(¶ms.TargetAllocator, eventTypeWarning, reasonError, err.Error()) return ctrl.Result{}, err } changed := params.TargetAllocator.DeepCopy() + changed.Status.Version = version.TargetAllocator() - if changed.Status.Version == "" { - changed.Status.Version = version.TargetAllocator() - } statusPatch := client.MergeFrom(¶ms.TargetAllocator) if err := params.Client.Status().Patch(ctx, changed, statusPatch); err != nil { return ctrl.Result{}, fmt.Errorf("failed to apply status changes to the OpenTelemetry CR: %w", err) From 4a1fb731e2aded6e58eb3591c6f126febdc0ebd0 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 23 Sep 2025 15:00:13 +0200 Subject: [PATCH 2/3] Set TA OpAMP status version when upgrading Signed-off-by: Pavol Loffay --- .chloggen/fix-version.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .chloggen/fix-version.yaml diff --git a/.chloggen/fix-version.yaml b/.chloggen/fix-version.yaml new file mode 100644 index 0000000000..59b6724674 --- /dev/null +++ b/.chloggen/fix-version.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: target allocator, opamp + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix version not being updated after version upgrade. + +# One or more tracking issues related to the change +issues: [4378] + +# (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: From 4e99b36f39228ed535dd2950a939ca215435ac02 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Wed, 1 Oct 2025 15:07:37 +0200 Subject: [PATCH 3/3] Add if Signed-off-by: Pavol Loffay --- internal/status/opampbridge/handle.go | 7 ++++++- internal/status/targetallocator/handle.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/status/opampbridge/handle.go b/internal/status/opampbridge/handle.go index 68ef5419fa..27d150b4b2 100644 --- a/internal/status/opampbridge/handle.go +++ b/internal/status/opampbridge/handle.go @@ -32,7 +32,12 @@ func HandleReconcileStatus(ctx context.Context, log logr.Logger, params manifest return ctrl.Result{}, err } changed := params.OpAMPBridge.DeepCopy() - changed.Status.Version = version.OperatorOpAMPBridge() + + // If the user provided a custom image we don't set the version. + // There is no guarantee that the custom image version matches the intended version. + if changed.Spec.Image == "" { + changed.Status.Version = version.OperatorOpAMPBridge() + } statusPatch := client.MergeFrom(¶ms.OpAMPBridge) if err := params.Client.Status().Patch(ctx, changed, statusPatch); err != nil { diff --git a/internal/status/targetallocator/handle.go b/internal/status/targetallocator/handle.go index 10c4c7abe1..f01a56b3f4 100644 --- a/internal/status/targetallocator/handle.go +++ b/internal/status/targetallocator/handle.go @@ -32,7 +32,12 @@ func HandleReconcileStatus(ctx context.Context, log logr.Logger, params targetal return ctrl.Result{}, err } changed := params.TargetAllocator.DeepCopy() - changed.Status.Version = version.TargetAllocator() + + // If the user provided a custom image we don't set the version. + // There is no guarantee that the custom image version matches the intended version. + if changed.Spec.Image == "" { + changed.Status.Version = version.TargetAllocator() + } statusPatch := client.MergeFrom(¶ms.TargetAllocator) if err := params.Client.Status().Patch(ctx, changed, statusPatch); err != nil {