Skip to content

Commit

Permalink
fix(core): revert configurable timeouts (bp #3644) (#3646)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed May 1, 2020
1 parent 16ffe11 commit e2b32d9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution
import com.netflix.spinnaker.orca.api.pipeline.TaskResult
import com.netflix.spinnaker.orca.clouddriver.KatoRestService
import com.netflix.spinnaker.orca.clouddriver.tasks.AbstractCloudProviderAwareTask
import com.netflix.spinnaker.orca.pipeline.model.OverridableStageTimeout
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

Expand All @@ -45,6 +45,7 @@ public class WaitOnJobCompletion extends AbstractCloudProviderAwareTask implemen
final long backoffPeriod = TimeUnit.SECONDS.toMillis(10)
final long timeout = TimeUnit.MINUTES.toMillis(120)


@Autowired
KatoRestService katoRestService

Expand All @@ -65,26 +66,6 @@ public class WaitOnJobCompletion extends AbstractCloudProviderAwareTask implemen
*/
static final Duration PROVIDER_PADDING = Duration.ofMinutes(5)

@Override
long getDynamicTimeout(@Nonnull StageExecution stage) {
String jobTimeoutFromProvider = (stage.context.get("jobRuntimeLimit") as String)

if (jobTimeoutFromProvider != null) {
try {
return Duration.parse(jobTimeoutFromProvider).plus(PROVIDER_PADDING).toMillis()
} catch (DateTimeParseException e) {
log.warn("Failed to parse job timeout specified by provider: '${jobTimeoutFromProvider}', using default", e)
}
}

OverridableStageTimeout timeout = stage.mapTo(OverridableStageTimeout.class)
if (timeout.timeoutMinutes.isPresent()) {
return TimeUnit.MINUTES.toMillis(timeout.timeoutMinutes.getAsLong())
}

return getTimeout()
}

@Override @Nullable
TaskResult onTimeout(@Nonnull StageExecution stage) {
jobUtils.cancelWait(stage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.netflix.spinnaker.orca.clouddriver.model.Manifest;
import com.netflix.spinnaker.orca.clouddriver.model.Manifest.Status;
import com.netflix.spinnaker.orca.clouddriver.utils.CloudProviderAware;
import com.netflix.spinnaker.orca.pipeline.model.OverridableStageTimeout;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -56,16 +55,6 @@ public long getTimeout() {
return TimeUnit.MINUTES.toMillis(30);
}

@Override
public long getDynamicTimeout(StageExecution stage) {
OverridableStageTimeout timeout = stage.mapTo(OverridableStageTimeout.class);
if (timeout.getTimeoutMinutes().isPresent()) {
return TimeUnit.MINUTES.toMillis(timeout.getTimeoutMinutes().getAsLong());
}

return getTimeout();
}

@Nonnull
@Override
public TaskResult execute(@Nonnull StageExecution stage) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -276,46 +276,6 @@ void waitsForAllManifestsWhenOneFailedAndOneUnknown() {
.containsExactly(failedMessage(MANIFEST_1), waitingToStabilizeMessage(MANIFEST_2));
}

@Test
void manifestTimeoutOneMinute() {
OortService oortService = mock(OortService.class);
WaitForManifestStableTask task = new WaitForManifestStableTask(oortService);

StageExecutionImpl myStage = createStageWithContext(ImmutableMap.of("timeoutMinutes", 1));

assertThat(task.getDynamicTimeout(myStage)).isEqualTo(60000);
}

@Test
void manifestTimeoutMissingTimeoutShouldBe30Minutes() {
OortService oortService = mock(OortService.class);
WaitForManifestStableTask task = new WaitForManifestStableTask(oortService);

StageExecutionImpl myStage = createStageWithContext(ImmutableMap.of("isee", "nothing"));

assertThat(task.getDynamicTimeout(myStage)).isEqualTo(1800000);
}

@Test
void manifestTimeoutIsEmptyString() {
OortService oortService = mock(OortService.class);
WaitForManifestStableTask task = new WaitForManifestStableTask(oortService);

StageExecutionImpl myStage = createStageWithContext(ImmutableMap.of("timeoutMinutes", ""));

assertThat(task.getDynamicTimeout(myStage)).isEqualTo(1800000);
}

@Test
void manifestTimeoutIs1AsString() {
OortService oortService = mock(OortService.class);
WaitForManifestStableTask task = new WaitForManifestStableTask(oortService);

StageExecutionImpl myStage = createStageWithContext(ImmutableMap.of("timeoutMinutes", "1"));

assertThat(task.getDynamicTimeout(myStage)).isEqualTo(60000);
}

private static String waitingToStabilizeMessage(String manifest) {
return String.format(
"'%s' in '%s' for account %s: waiting for manifest to stabilize",
Expand Down

This file was deleted.

0 comments on commit e2b32d9

Please sign in to comment.