Skip to content

Commit 61152f4

Browse files
committed
Update task cleanup wait logic to clean task resources immediately instead of waiting 3 hours
1 parent b3bbc71 commit 61152f4

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

agent/engine/task_manager.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -1092,18 +1092,16 @@ func (mtask *managedTask) time() ttime.Time {
10921092

10931093
func (mtask *managedTask) cleanupTask(taskStoppedDuration time.Duration) {
10941094
cleanupTimeDuration := mtask.GetKnownStatusTime().Add(taskStoppedDuration).Sub(ttime.Now())
1095-
// There is a potential deadlock here if cleanupTime is negative. Ignore the computed
1096-
// value in this case in favor of the default config value.
1095+
cleanupTime := make(<-chan time.Time)
10971096
if cleanupTimeDuration < 0 {
1098-
seelog.Infof("Managed task [%s]: Cleanup Duration is too short. Resetting to: %s",
1099-
mtask.Arn, config.DefaultTaskCleanupWaitDuration.String())
1100-
cleanupTimeDuration = config.DefaultTaskCleanupWaitDuration
1097+
seelog.Infof("Managed task [%s]: Cleanup Duration has been exceeded. Starting cleanup now ", mtask.Arn)
1098+
cleanupTime = mtask.time().After(time.Nanosecond)
1099+
} else {
1100+
cleanupTime = mtask.time().After(cleanupTimeDuration)
11011101
}
1102-
cleanupTime := mtask.time().After(cleanupTimeDuration)
11031102
cleanupTimeBool := make(chan struct{})
11041103
go func() {
11051104
<-cleanupTime
1106-
cleanupTimeBool <- struct{}{}
11071105
close(cleanupTimeBool)
11081106
}()
11091107
// wait for the cleanup time to elapse, signalled by cleanupTimeBool

0 commit comments

Comments
 (0)