Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue on waitRule timeout #999

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading