diff --git a/runtime/reconcile/result.go b/runtime/reconcile/result.go index 82fc3518..49ff5d74 100644 --- a/runtime/reconcile/result.go +++ b/runtime/reconcile/result.go @@ -134,7 +134,7 @@ func (rs ResultFinalizer) Finalize(obj conditions.Setter, res ctrl.Result, recEr // Ready=False with the reconcile error. If Ready is already False with a // reason, preserve the value. if recErr != nil { - if conditions.IsUnknown(obj, meta.ReadyCondition) || conditions.IsReady(obj) { + if conditions.IsUnknown(obj, meta.ReadyCondition) || conditions.IsTrue(obj, meta.ReadyCondition) { conditions.MarkFalse(obj, meta.ReadyCondition, meta.FailedReason, recErr.Error()) } } diff --git a/runtime/reconcile/result_test.go b/runtime/reconcile/result_test.go index b3697b05..66d9d9a4 100644 --- a/runtime/reconcile/result_test.go +++ b/runtime/reconcile/result_test.go @@ -170,6 +170,20 @@ func TestResultFinalizer(t *testing.T) { *conditions.TrueCondition(meta.ReconcilingCondition, "SomeReasonX", "some msg X"), }, }, + { + name: "result with error, ready and reconciling, change to not ready", + beforeFunc: func(obj conditions.Setter) { + conditions.MarkReconciling(obj, "SomeReasonX", "some msg X") + conditions.MarkTrue(obj, meta.ReadyCondition, "SomeReasonY", "some msg Y") + }, + result: resultFailed, + recErr: errors.New("foo failed"), + wantErr: true, + assertConditions: []metav1.Condition{ + *conditions.FalseCondition(meta.ReadyCondition, meta.FailedReason, "foo failed"), + *conditions.TrueCondition(meta.ReconcilingCondition, "SomeReasonX", "some msg X"), + }, + }, { name: "stalled and reconciling, Ready=False, remove reconciling, retain ready", beforeFunc: func(obj conditions.Setter) {