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

fix(tasks): stop using 'shared' task state #1731

Merged
merged 1 commit into from
Oct 24, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.netflix.spinnaker.orca.pipeline.tasks

import java.time.Duration
import java.util.concurrent.TimeUnit
import com.netflix.spinnaker.orca.RetryableTask
import com.netflix.spinnaker.orca.TaskResult
Expand All @@ -29,29 +28,16 @@ import static com.netflix.spinnaker.orca.ExecutionStatus.SUCCEEDED
@Component
@CompileStatic
class WaitTask implements RetryableTask {
long backoffPeriod = 15000
long timeout = Integer.MAX_VALUE
long waitTimeMs
final long backoffPeriod = 15000
final long timeout = Integer.MAX_VALUE

TimeProvider timeProvider = new TimeProvider()

@Override
long getDynamicBackoffPeriod(Duration taskDuration) {
if (taskDuration <= Duration.ofMillis(waitTimeMs)) {
// 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
}
}


@Override
TaskResult execute(Stage stage) {
// wait time is specified in seconds
long waitTime = stage.context.waitTime as long
waitTimeMs = TimeUnit.MILLISECONDS.convert(waitTime, TimeUnit.SECONDS)
def waitTimeMs = TimeUnit.MILLISECONDS.convert(waitTime, TimeUnit.SECONDS)
def now = timeProvider.millis

if (!stage.context.containsKey("waitTaskState") || !stage.context.waitTaskState instanceof Map) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class ManualJudgmentStage implements StageDefinitionBuilder, RestartableStage, A
@Component
@VisibleForTesting
public static class WaitForManualJudgmentTask implements RetryableTask {
long backoffPeriod = 15000
long timeout = TimeUnit.DAYS.toMillis(3)
final long backoffPeriod = 15000
final long timeout = TimeUnit.DAYS.toMillis(3)

@Override
long getDynamicBackoffPeriod(Duration taskDuration) {
Expand All @@ -82,8 +82,6 @@ class ManualJudgmentStage implements StageDefinitionBuilder, RestartableStage, A

@Override
TaskResult execute(Stage stage) {
stage.getTopLevelTimeout().ifPresent({ timeout = it })

StageData stageData = stage.mapTo(StageData)
NotificationState notificationState
ExecutionStatus executionStatus
Expand Down