Skip to content

Commit

Permalink
Copy version from instance before updating it (jaegertracing#1885)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 authored May 13, 2022
1 parent 6099e4e commit f85df5b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/controller/jaeger/jaeger_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ func (r *ReconcileJaeger) Reconcile(request reconcile.Request) (reconcile.Result
return reconcile.Result{}, tracing.HandleError(err, span)
}
instance = &updated
// Need to copy the version from status because the Update will populate the status field with empty strings.
instanceVersion := instance.Status.Version

if !reflect.DeepEqual(originalInstance, *instance) {
// we store back the changed CR, so that what is stored reflects what is being used
Expand All @@ -170,9 +172,9 @@ func (r *ReconcileJaeger) Reconcile(request reconcile.Request) (reconcile.Result
}

// set the status version to the updated instance version if versions doesn't match
if updated.Status.Version != originalInstance.Status.Version || instance.Status.Phase != v1.JaegerPhaseRunning {
if instanceVersion != originalInstance.Status.Version || instance.Status.Phase != v1.JaegerPhaseRunning {
instance.Status.Phase = v1.JaegerPhaseRunning
instance.Status.Version = updated.Status.Version
instance.Status.Version = instanceVersion
if err := r.client.Status().Update(ctx, instance); err != nil {
logFields.WithError(err).Error("failed to store the running status into the current CustomResource")
return reconcile.Result{}, tracing.HandleError(err, span)
Expand Down

0 comments on commit f85df5b

Please sign in to comment.