Skip to content

Commit c48adec

Browse files
authored
Set TA and OpAMP status version when upgrading (#4378)
* Set TA OpAMP status version when upgrading Signed-off-by: Pavol Loffay <[email protected]> * Set TA OpAMP status version when upgrading Signed-off-by: Pavol Loffay <[email protected]> * Add if Signed-off-by: Pavol Loffay <[email protected]> --------- Signed-off-by: Pavol Loffay <[email protected]>
1 parent 2584188 commit c48adec

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

.chloggen/fix-version.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: target allocator, opamp
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Fix version not being updated after version upgrade.
9+
10+
# One or more tracking issues related to the change
11+
issues: [4378]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

internal/status/opampbridge/handle.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ func HandleReconcileStatus(ctx context.Context, log logr.Logger, params manifest
3333
}
3434
changed := params.OpAMPBridge.DeepCopy()
3535

36-
if changed.Status.Version == "" {
36+
// If the user provided a custom image we don't set the version.
37+
// There is no guarantee that the custom image version matches the intended version.
38+
if changed.Spec.Image == "" {
3739
changed.Status.Version = version.OperatorOpAMPBridge()
3840
}
41+
3942
statusPatch := client.MergeFrom(&params.OpAMPBridge)
4043
if err := params.Client.Status().Patch(ctx, changed, statusPatch); err != nil {
4144
return ctrl.Result{}, fmt.Errorf("failed to apply status changes to the OpenTelemetry CR: %w", err)

internal/status/targetallocator/handle.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ const (
2626

2727
// HandleReconcileStatus handles updating the status of the CRDs managed by the operator.
2828
func HandleReconcileStatus(ctx context.Context, log logr.Logger, params targetallocator.Params, err error) (ctrl.Result, error) {
29-
log.V(2).Info("updating opampbridge status")
29+
log.V(2).Info("updating target allocator status")
3030
if err != nil {
3131
params.Recorder.Event(&params.TargetAllocator, eventTypeWarning, reasonError, err.Error())
3232
return ctrl.Result{}, err
3333
}
3434
changed := params.TargetAllocator.DeepCopy()
3535

36-
if changed.Status.Version == "" {
36+
// If the user provided a custom image we don't set the version.
37+
// There is no guarantee that the custom image version matches the intended version.
38+
if changed.Spec.Image == "" {
3739
changed.Status.Version = version.TargetAllocator()
3840
}
41+
3942
statusPatch := client.MergeFrom(&params.TargetAllocator)
4043
if err := params.Client.Status().Patch(ctx, changed, statusPatch); err != nil {
4144
return ctrl.Result{}, fmt.Errorf("failed to apply status changes to the OpenTelemetry CR: %w", err)

0 commit comments

Comments
 (0)