Skip to content

Commit

Permalink
fix loss of Status subresource information
Browse files Browse the repository at this point in the history
Signed-off-by: hendrikKahl <hendrik.kahl@sap.com>
  • Loading branch information
hendrikKahl committed Aug 26, 2022
1 parent db57188 commit 9b83ae7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/testmachinery/controller/reconciler/testrun_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ func (r *TestmachineryReconciler) createWorkflow(ctx context.Context, rCtx *reco
rCtx.tr.Status.Workflow = rCtx.wf.Name
rCtx.tr.Status.Phase = tmv1beta1.RunPhaseRunning

// update status first because otherwise it would be lost during the patch call
rCtx.tr.Status.ObservedGeneration = rCtx.tr.Generation
if err := r.Status().Update(ctx, rCtx.tr); err != nil {
log.Error(err, "unable to update testrun status")
return reconcile.Result{}, err
}

beforePatch := rCtx.tr.DeepCopy()
patch := client.MergeFrom(beforePatch)

// add finalizers for testrun
trFinalizers := sets.NewString(rCtx.tr.Finalizers...)
if !trFinalizers.Has(tmv1beta1.SchemeGroupVersion.Group) {
Expand All @@ -170,8 +180,7 @@ func (r *TestmachineryReconciler) createWorkflow(ctx context.Context, rCtx *reco
}
rCtx.tr.Finalizers = trFinalizers.UnsortedList()

// update here to add finalizers
if err := r.Update(ctx, rCtx.tr); err != nil {
if err := r.Patch(ctx, rCtx.tr, patch); err != nil {
return reconcile.Result{}, nil
}

Expand Down

0 comments on commit 9b83ae7

Please sign in to comment.