-
Couldn't load subscription status.
- Fork 81
Change the behavior of hanlding a WaitTask timeout #451
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,7 +102,7 @@ func (w *WaitTask) Start(taskContext *TaskContext) { | |
|
|
||
| // setTimer creates the timer with the timeout value taken from | ||
| // the WaitTask struct. Once the timer expires, it will send | ||
| // a message on the TaskChannel provided in the taskContext. | ||
| // a message on the EventChannel provided in the taskContext. | ||
| func (w *WaitTask) setTimer(taskContext *TaskContext) { | ||
| timer := time.NewTimer(w.Timeout) | ||
| go func() { | ||
|
|
@@ -111,16 +111,23 @@ func (w *WaitTask) setTimer(taskContext *TaskContext) { | |
| // Timeout is cancelled. | ||
| <-timer.C | ||
| select { | ||
| // We only send the taskResult if no one has gotten | ||
| // We only send the TimeoutError to the eventChannel if no one has gotten | ||
| // to the token first. | ||
| case <-w.token: | ||
| taskContext.TaskChannel() <- TaskResult{ | ||
| Err: &TimeoutError{ | ||
| Identifiers: w.Ids, | ||
| Timeout: w.Timeout, | ||
| Condition: w.Condition, | ||
| err := &TimeoutError{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I like that we no longer need to amend certain error types in the runner itself. In this case, it seems like we can just create the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Identifiers: w.Ids, | ||
| Timeout: w.Timeout, | ||
| Condition: w.Condition, | ||
| } | ||
| amendTimeoutError(taskContext, err) | ||
| taskContext.EventChannel() <- event.Event{ | ||
| Type: event.WaitType, | ||
| WaitEvent: event.WaitEvent{ | ||
| GroupName: w.Name(), | ||
| Error: err, | ||
| }, | ||
| } | ||
| taskContext.TaskChannel() <- TaskResult{} | ||
| default: | ||
| return | ||
| } | ||
|
|
@@ -130,6 +137,24 @@ func (w *WaitTask) setTimer(taskContext *TaskContext) { | |
| } | ||
| } | ||
|
|
||
| func amendTimeoutError(taskContext *TaskContext, err error) { | ||
| if timeoutErr, ok := err.(*TimeoutError); ok { | ||
| var timedOutResources []TimedOutResource | ||
| for _, id := range timeoutErr.Identifiers { | ||
| result := taskContext.ResourceCache().Get(id) | ||
| if timeoutErr.Condition.Meets(result.Status) { | ||
| continue | ||
| } | ||
| timedOutResources = append(timedOutResources, TimedOutResource{ | ||
| Identifier: id, | ||
| Status: result.Status, | ||
| Message: result.StatusMessage, | ||
| }) | ||
| } | ||
| timeoutErr.TimedOutResources = timedOutResources | ||
| } | ||
| } | ||
|
|
||
| // checkCondition checks whether the condition set in the task | ||
| // is currently met given the status of resources in the cache. | ||
| func (w *WaitTask) checkCondition(taskContext *TaskContext) bool { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.