Skip to content

Commit

Permalink
fix(polling): update time left calculation (spinnaker#1713)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns authored Oct 18, 2017
1 parent 8df5b40 commit b1e32b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class RestrictExecutionDuringTimeWindow implements StageDefinitionBuilder {
@Override
long getDynamicBackoffPeriod(Duration taskDuration) {
if (taskDuration < Duration.ofMillis(timeout)) {
// wait until timeout is over to poll
return Duration.ofMillis(timeout).toMillis()
// task needs to run again right after it should be complete, so add half a second
return Duration.ofMillis(timeout).minus(taskDuration).plus(Duration.ofMillis(500)).toMillis()
} else {
//start polling normally after timeout to account for delays like throttling
return backoffPeriod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class WaitTask implements RetryableTask {
@Override
long getDynamicBackoffPeriod(Duration taskDuration) {
if (taskDuration <= Duration.ofMillis(waitTimeMs)) {
// wait until timeout is over to poll
return Duration.ofMillis(waitTimeMs).toMillis()
// task needs to run again right after it should be complete, so add half a second
return Duration.ofMillis(waitTimeMs).minus(taskDuration).plus(Duration.ofMillis(500)).toMillis()
} else {
// start polling normally after timeout to account for delays like throttling
return backoffPeriod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class ManualJudgmentStage implements StageDefinitionBuilder, RestartableStage, A
@Override
long getDynamicBackoffPeriod(Duration taskDuration) {
if (taskDuration < Duration.ofMillis(timeout)) {
// wait until timeout is over to poll
return Duration.ofMillis(timeout).toMillis()
// task needs to run again right after it should be complete, so add half a second
return Duration.ofMillis(timeout).minus(taskDuration).plus(Duration.ofMillis(500)).toMillis()
} else {
// start polling normally after timeout to account for delays like throttling
return backoffPeriod
Expand Down

0 comments on commit b1e32b4

Please sign in to comment.