From b6c869a67e56185a4824734abe66ebb511ae553d Mon Sep 17 00:00:00 2001 From: Brandon Palm Date: Mon, 27 Jul 2026 14:42:27 -0500 Subject: [PATCH] NO-JIRA: Fix ConditionMatcher.Matches early-return when Any is true When Any is true, the Matches function should return true if at least one condition matching the type pattern has the expected status. However, the early-return on status mismatch fires before checking all conditions, causing false negatives when a non-matching condition appears before a matching one in the iteration order. This produces flaky e2e failures in overrides tests because the API returns conditions in non-deterministic order: if the static-resources Degraded=False condition is iterated before the deployment Degraded=True condition, the matcher incorrectly returns false. Guard the early-return with !m.Any so that Any mode continues searching for at least one match instead of short-circuiting on the first mismatch. --- test/e2e/condition_matcher_test.go | 4 +++- test/e2e/condition_matcher_unit_test.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/e2e/condition_matcher_test.go b/test/e2e/condition_matcher_test.go index 8f2865554..ba9940b2e 100644 --- a/test/e2e/condition_matcher_test.go +++ b/test/e2e/condition_matcher_test.go @@ -53,7 +53,9 @@ func (m *ConditionMatcher) Matches(conditions []opv1.OperatorCondition) bool { } if m.MatchesType(&cond) && !m.MatchesStatus(&cond) { - return false + if !m.Any { + return false + } } } diff --git a/test/e2e/condition_matcher_unit_test.go b/test/e2e/condition_matcher_unit_test.go index d88ea3b72..6d511ddf9 100644 --- a/test/e2e/condition_matcher_unit_test.go +++ b/test/e2e/condition_matcher_unit_test.go @@ -101,6 +101,20 @@ func TestVerifyOperatorStatusCondition(t *testing.T) { expectError: true, errorContains: "context deadline exceeded", }, + { + name: "Any mode succeeds when matching condition appears after non-matching one", + expectedConditions: map[string]opv1.ConditionStatus{ + "Degraded": opv1.ConditionTrue, + }, + initialObjects: []runtime.Object{ + newCertManagerObjectWithConditions( + opv1.OperatorCondition{Type: controllerPrefix + "-static-resources-Degraded", Status: opv1.ConditionFalse}, + opv1.OperatorCondition{Type: controllerPrefix + "Degraded", Status: opv1.ConditionTrue}, + ), + }, + matchAny: true, + expectError: false, + }, { name: "A missing condition for Progressing", expectedConditions: map[string]opv1.ConditionStatus{