Skip to content

Commit

Permalink
chore(clouddriver): Add fast prop for disabling saga retries (#3229)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Oct 15, 2019
1 parent 42a5665 commit 8aba734
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.netflix.spinnaker.orca.clouddriver.tasks

import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import com.netflix.spinnaker.orca.ExecutionStatus
import com.netflix.spinnaker.orca.RetryableTask
import com.netflix.spinnaker.orca.TaskResult
Expand Down Expand Up @@ -52,16 +53,18 @@ class MonitorKatoTask implements RetryableTask, CloudProviderAware {
private final Clock clock
private final Registry registry
private final KatoService kato
private final DynamicConfigService dynamicConfigService

@Autowired
MonitorKatoTask(KatoService katoService, Registry registry) {
this(katoService, registry, Clock.systemUTC())
MonitorKatoTask(KatoService katoService, Registry registry, DynamicConfigService dynamicConfigService) {
this(katoService, registry, Clock.systemUTC(), dynamicConfigService)
}

MonitorKatoTask(KatoService katoService, Registry registry, Clock clock) {
MonitorKatoTask(KatoService katoService, Registry registry, Clock clock, DynamicConfigService dynamicConfigService) {
this.registry = registry
this.clock = clock
this.kato = katoService
this.dynamicConfigService = dynamicConfigService
}

long getBackoffPeriod() { 5000L }
Expand Down Expand Up @@ -161,7 +164,7 @@ class MonitorKatoTask implements RetryableTask, CloudProviderAware {
outputs["kato.tasks"] = katoTasks
}

if (status == ExecutionStatus.TERMINAL && katoTask.status.retryable) {
if (status == ExecutionStatus.TERMINAL && katoTask.status.retryable && dynamicConfigService.isEnabled("tasks.monitor-kato-task.saga-retries", true)) {
stage.execution.systemNotifications.add(new SystemNotification(
clock.millis(),
"katoRetryTask",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.netflix.spinnaker.orca.clouddriver.tasks.job;

import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.orca.TaskResult;
import com.netflix.spinnaker.orca.clouddriver.KatoService;
import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask;
Expand All @@ -32,13 +33,18 @@ public class MonitorJobTask extends MonitorKatoTask {
private final JobUtils jobUtils;

@Autowired
public MonitorJobTask(KatoService katoService, Registry registry, JobUtils jobUtils) {
super(katoService, registry);
public MonitorJobTask(
KatoService katoService,
Registry registry,
JobUtils jobUtils,
DynamicConfigService dynamicConfigService) {
super(katoService, registry, dynamicConfigService);
this.jobUtils = jobUtils;
}

public MonitorJobTask(KatoService katoService, Registry registry) {
super(katoService, registry);
public MonitorJobTask(
KatoService katoService, Registry registry, DynamicConfigService dynamicConfigService) {
super(katoService, registry, dynamicConfigService);
this.jobUtils = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

package com.netflix.spinnaker.orca.clouddriver.tasks

import java.time.Clock
import java.time.Instant
import java.time.ZoneId
import com.netflix.spectator.api.NoopRegistry
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import com.netflix.spinnaker.orca.ExecutionStatus
import com.netflix.spinnaker.orca.clouddriver.KatoService
import com.netflix.spinnaker.orca.clouddriver.model.Task
Expand All @@ -34,6 +32,10 @@ import spock.lang.Specification
import spock.lang.Subject
import spock.lang.Unroll

import java.time.Clock
import java.time.Instant
import java.time.ZoneId

import static com.netflix.spinnaker.orca.test.model.ExecutionBuilder.stage

class MonitorKatoTaskSpec extends Specification {
Expand All @@ -42,8 +44,9 @@ class MonitorKatoTaskSpec extends Specification {
def now = Instant.now()

KatoService kato = Mock(KatoService)
DynamicConfigService dynamicConfigService = Mock()

@Subject task = new MonitorKatoTask(kato, new NoopRegistry(), Clock.fixed(now, ZoneId.of("UTC"))) {{
@Subject task = new MonitorKatoTask(kato, new NoopRegistry(), Clock.fixed(now, ZoneId.of("UTC")), dynamicConfigService) {{
taskNotFoundTimeoutMs = TASK_NOT_FOUND_TIMEOUT
}}

Expand Down Expand Up @@ -189,6 +192,7 @@ class MonitorKatoTaskSpec extends Specification {

then:
notThrown(RetrofitError)
dynamicConfigService.isEnabled("tasks.monitor-kato-task.saga-retries", _) >> true
with(kato) {
1 * lookupTask(katoTask.id, false) >> { Observable.just(katoTask) }
1 * resumeTask(katoTask.id) >> { new TaskId(katoTask.id) }
Expand Down

0 comments on commit 8aba734

Please sign in to comment.