Skip to content

Commit

Permalink
Don't override the reconcile error on status patching
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Nov 10, 2022
1 parent 9582513 commit 20f3447
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// Finalise the reconciliation and report the results.
defer func() {
retErr = r.finalizeStatus(ctx, obj, patcher)
// Patch finalizers, status and conditions.
if err := r.finalizeStatus(ctx, obj, patcher); err != nil {
retErr = kerrors.NewAggregate([]error{retErr, err})
}

// Record Prometheus metrics.
r.Metrics.RecordReadiness(ctx, obj)
Expand Down
5 changes: 1 addition & 4 deletions controllers/kustomization_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ parameters:

g.Eventually(func() bool {
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), resultK)
return isReconcileRunning(resultK)
return isReconcileRunning(resultK) && conditions.IsUnknown(resultK, kustomizev1.HealthyCondition)
}, timeout, time.Second).Should(BeTrue())
logStatus(t, resultK)

expectedMessage := "Running health checks"
g.Expect(conditions.IsUnknown(resultK, kustomizev1.HealthyCondition)).To(BeTrue())
g.Expect(conditions.IsUnknown(resultK, meta.ReadyCondition)).To(BeTrue())

for _, c := range []string{meta.ReconcilingCondition, kustomizev1.HealthyCondition} {
g.Expect(conditions.GetReason(resultK, c)).To(BeIdenticalTo(meta.ProgressingReason))
g.Expect(conditions.GetMessage(resultK, c)).To(ContainSubstring(expectedMessage))
Expand Down

0 comments on commit 20f3447

Please sign in to comment.