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

Signed-off-by: Rohit Aggarwal <[email protected]>
  • Loading branch information
rohitagg2020 committed Aug 8, 2024
1 parent 12ddf94 commit f6acd93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 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,8 +115,9 @@ 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 {
// 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(fmt.Sprintf("%s.%s", s.resource.Namespace(), s.resource.Name()))
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 f6acd93

Please sign in to comment.