From 200d9704b28899102847fcab3a8815822c3f0cfd Mon Sep 17 00:00:00 2001 From: rohitagg2020 <55523204+rohitagg2020@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:20:03 +0530 Subject: [PATCH] Fixing issue on waitRule timeout where a non matching condition in the waitRule is resetting the map (#999) Signed-off-by: Rohit Aggarwal Co-authored-by: Rohit Aggarwal --- pkg/kapp/resourcesmisc/custom_waiting_resource.go | 9 +++++---- test/e2e/wait_timeout_test.go | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/kapp/resourcesmisc/custom_waiting_resource.go b/pkg/kapp/resourcesmisc/custom_waiting_resource.go index d1a3ef3f2..110ea5689 100644 --- a/pkg/kapp/resourcesmisc/custom_waiting_resource.go +++ b/pkg/kapp/resourcesmisc/custom_waiting_resource.go @@ -97,7 +97,7 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState { if condMatcher.Timeout != "" { isTimeOutConditionPresent = true - if s.hasTimeoutOccurred(condMatcher.Timeout, fmt.Sprintf("%s.%s", s.resource.Namespace(), s.resource.Name())) { + if s.hasTimeoutOccurred(condMatcher.Timeout, s.resource.Description()) { return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( "Encountered failure condition %s == %s: %s (message: %s) continuously for %s duration", cond.Type, condMatcher.Status, cond.Reason, cond.Message, condMatcher.Timeout)} @@ -115,9 +115,10 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState { } } - // Reset the timer in case timeout condition flipped from being present to not present in the Cluster resource status - if !isTimeOutConditionPresent { - timeoutMap.Delete(fmt.Sprintf("%s.%s", s.resource.Namespace(), s.resource.Name())) + // Reset the timer in case timeout condition flipped from being present to not present in the Cluster resource status. + // Reset should only happen if condMatcher has timeout. Otherwise, it is possible that condMatcher which dont have timeout will try to reset the map. + if condMatcher.Timeout != "" && !isTimeOutConditionPresent { + timeoutMap.Delete(s.resource.Description()) continue } } diff --git a/test/e2e/wait_timeout_test.go b/test/e2e/wait_timeout_test.go index 29e4ac5e0..b6b4ccecb 100644 --- a/test/e2e/wait_timeout_test.go +++ b/test/e2e/wait_timeout_test.go @@ -50,12 +50,12 @@ kind: Config waitRules: - supportsObservedGeneration: true conditionMatchers: - - type: ContainersReady - status: "False" - timeout: 50s - type: Ready status: "True" success: true + - type: ContainersReady + status: "False" + timeout: 50s resourceMatchers: - apiVersionKindMatcher: {apiVersion: v1, kind: Pod} `