Skip to content

Commit

Permalink
Fixing issue on waitRule timeout where a non matching condition in th…
Browse files Browse the repository at this point in the history
…e waitRule is resetting the map (#999)

Signed-off-by: Rohit Aggarwal <[email protected]>
Co-authored-by: Rohit Aggarwal <[email protected]>
  • Loading branch information
rohitagg2020 and rohitagg2020 authored Aug 8, 2024
1 parent 12ddf94 commit 200d970
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pkg/kapp/resourcesmisc/custom_waiting_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/wait_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
`
Expand Down

0 comments on commit 200d970

Please sign in to comment.