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: diff --git a/internal/status/opampbridge/handle.go b/internal/status/opampbridge/handle.go index b060299ee3..27d150b4b2 100644 --- a/internal/status/opampbridge/handle.go +++ b/internal/status/opampbridge/handle.go @@ -33,9 +33,12 @@ func HandleReconcileStatus(ctx context.Context, log logr.Logger, params manifest } changed := params.OpAMPBridge.DeepCopy() - if changed.Status.Version == "" { + // 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 { 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..f01a56b3f4 100644 --- a/internal/status/targetallocator/handle.go +++ b/internal/status/targetallocator/handle.go @@ -26,16 +26,19 @@ 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() - if changed.Status.Version == "" { + // 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 { return ctrl.Result{}, fmt.Errorf("failed to apply status changes to the OpenTelemetry CR: %w", err)