diff --git a/apis/common/condition.go b/apis/common/condition.go index f1c91b809..03f67110c 100644 --- a/apis/common/condition.go +++ b/apis/common/condition.go @@ -96,8 +96,15 @@ type Condition struct { //nolint:recvcheck // False positive - only has non-poin } // Equal returns true if the condition is identical to the supplied condition, -// ignoring the LastTransitionTime. +// ignoring the LastTransitionTime. If one or both conditions have not +// provided the ObservedGeneration it is not considered in the comparison. func (c Condition) Equal(other Condition) bool { + if c.ObservedGeneration == 0 || other.ObservedGeneration == 0 { + return c.Type == other.Type && + c.Status == other.Status && + c.Reason == other.Reason && + c.Message == other.Message + } return c.Type == other.Type && c.Status == other.Status && c.Reason == other.Reason && diff --git a/apis/common/condition_test.go b/apis/common/condition_test.go index 50b052ce4..6e0846e33 100644 --- a/apis/common/condition_test.go +++ b/apis/common/condition_test.go @@ -76,9 +76,27 @@ func TestConditionEqual(t *testing.T) { b: Condition{Message: "uncool"}, want: false, }, + "IdenticalWithMissingObservedGeneration": { + a: Condition{ + Type: TypeReady, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.Now(), + Reason: ReasonCreating, + Message: "UnitTest", + ObservedGeneration: 1, + }, + b: Condition{ + Type: TypeReady, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.Now(), + Reason: ReasonCreating, + Message: "UnitTest", + }, + want: true, + }, "DifferentObservedGeneration": { a: Condition{ObservedGeneration: 1}, - b: Condition{}, + b: Condition{ObservedGeneration: 2}, want: false, }, "CheckReconcilePaused": {