refactor(google): Remove Task as a paramter for doRetry
Allows use to remove the dependency on `clouddriver-core`.
This is mainly useful because Front50 also depends on
`clouddriver-google-common` and thereby indirectly on all
of clouddriver-core and every dependency it brings in.
MODIFY
clouddriver-appengine/src/main/groovy/com/netflix/spinnaker/clouddriver/appengine/deploy/AppengineSafeRetry.groovy
clouddriver-appengine/src/main/groovy/com/netflix/spinnaker/clouddriver/appengine/deploy/AppengineSafeRetry.groovy
@@ -44,10 +44,10 @@ class AppengineSafeRetry extends GoogleCommonSafeRetry {
List<Integer> successfulErrorCodes,
Map tags,
Registry registry) {
+ task?.updateStatus tags.phase, "Attempting $tags.action of $resource..."
return super.doRetry(
operation,
resource,
- task,
retryCodes,
successfulErrorCodes,
maxWaitInterval,

MODIFY
clouddriver-google-common/clouddriver-google-common.gradle
clouddriver-google-common/clouddriver-google-common.gradle
dependencies {
- compile project(":clouddriver-core")
spinnaker.group('google')
+ spinnaker.group('fiat')
+ compile spinnaker.dependency('spectatorApi')
}

MODIFY
clouddriver-google-common/src/main/groovy/com/netflix/spinnaker/clouddriver/googlecommon/deploy/GoogleCommonSafeRetry.groovy
clouddriver-google-common/src/main/groovy/com/netflix/spinnaker/clouddriver/googlecommon/deploy/GoogleCommonSafeRetry.groovy
@@ -18,7 +18,6 @@ package com.netflix.spinnaker.clouddriver.googlecommon.deploy
import com.google.api.client.googleapis.json.GoogleJsonResponseException
import com.netflix.spectator.api.Registry
-import com.netflix.spinnaker.clouddriver.data.task.Task
import groovy.util.logging.Slf4j
import java.util.concurrent.TimeUnit
@@ -38,7 +37,6 @@ abstract class GoogleCommonSafeRetry {
* @param operation - The operation.
* @param action - String describing the operation.
* @param resource - Resource we are operating on.
- * @param task - Spinnaker task. Can be null.
* @param phase
* @param retryCodes - GoogleJsonResponseException codes we retry on.
* @param successfulErrorCodes - GoogleJsonException codes we treat as success.
@@ -47,7 +45,6 @@ abstract class GoogleCommonSafeRetry {
*/
public Object doRetry(Closure operation,
String resource,
- Task task,
List<Integer> retryCodes,
List<Integer> successfulErrorCodes,
Long maxWaitInterval,
@@ -58,7 +55,7 @@ abstract class GoogleCommonSafeRetry {
Registry registry) {
long startTime = registry.clock().monotonicTime()
SafeRetryState state = performOperation(
- operation, tags.action, resource, task, tags.phase,
+ operation, tags.action, resource, tags.phase,
retryCodes, successfulErrorCodes,
maxWaitInterval, retryIntervalBase, jitterMultiplier, maxRetries)
@@ -75,7 +72,6 @@ abstract class GoogleCommonSafeRetry {
protected SafeRetryState performOperation(Closure operation,
String action,
String resource,
- Task task,
String phase,
List<Integer> retryCodes,
List<Integer> successfulErrorCodes,
@@ -89,9 +85,7 @@ abstract class GoogleCommonSafeRetry {
while (state.tries < maxAttempts) {
def tries = ++state.tries
try {
- if (tries == 1) {
- task?.updateStatus phase, "Attempting $action of $resource..."
- } else {
+ if (tries != 1) {
// Sleep with exponential backoff based on the number of retries. Add retry jitter with Math.random() to
// prevent clients syncing up and bursting at regular intervals. Don't wait longer than a minute.
Long thisIntervalWait = TimeUnit.SECONDS.toMillis(Math.pow(retryIntervalBase, tries - 1) as Integer)

MODIFY
clouddriver-google-common/src/test/groovy/com/netflix/spinnaker/clouddriver/googlecommon/deploy/GoogleCommonSafeRetrySpec.groovy
clouddriver-google-common/src/test/groovy/com/netflix/spinnaker/clouddriver/googlecommon/deploy/GoogleCommonSafeRetrySpec.groovy
@@ -24,7 +24,6 @@ import com.google.api.client.testing.json.MockJsonFactory
import com.google.common.collect.ImmutableMap;
import com.netflix.spectator.api.DefaultRegistry;
import com.netflix.spectator.api.Registry;
-import com.netflix.spinnaker.clouddriver.data.task.Task
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
@@ -71,7 +70,7 @@ class GoogleCommonSafeRetrySpec extends Specification {
when:
Object result = retrier.doRetry(
- mockClosure, "resource", Mock(Task),
+ mockClosure, "resource",
Arrays.asList(500), Arrays.asList(404),
new Long(-1), new Long(-1), new Long(-1), new Long(maxRetries),
ImmutableMap.of("action", "test"), registry)
@@ -88,7 +87,7 @@ class GoogleCommonSafeRetrySpec extends Specification {
when:
Object result = retrier.doRetry(
- mockClosure, "resource", Mock(Task),
+ mockClosure, "resource",
Arrays.asList(500), Arrays.asList(404),
new Long(-1), new Long(-1), new Long(-1), new Long(maxRetries),
ImmutableMap.of("action", "test"), registry)
@@ -112,7 +111,7 @@ class GoogleCommonSafeRetrySpec extends Specification {
when:
Object result = retrier.doRetry(
- mockClosure, "resource", Mock(Task),
+ mockClosure, "resource",
Arrays.asList(500), Arrays.asList(404),
new Long(-1), new Long(-1), new Long(-1), new Long(maxAttempts),
ImmutableMap.of("action", "test"), registry)
@@ -137,7 +136,7 @@ class GoogleCommonSafeRetrySpec extends Specification {
when:
Object result = retrier.doRetry(
- mockClosure, "resource", Mock(Task),
+ mockClosure, "resource",
Arrays.asList(500), Arrays.asList(404),
new Long(-1), new Long(-1), new Long(-1), new Long(maxRetries),
ImmutableMap.of("action", "test"), registry)
@@ -162,7 +161,7 @@ class GoogleCommonSafeRetrySpec extends Specification {
when:
Object result = retrier.doRetry(
- mockClosure, "resource", Mock(Task),
+ mockClosure, "resource",
Arrays.asList(500), null,
new Long(-1), new Long(-1), new Long(-1), new Long(maxRetries),
ImmutableMap.of("action", "test"), registry)

MODIFY
clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/deploy/SafeRetry.groovy
clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/deploy/SafeRetry.groovy
@@ -48,9 +48,9 @@ class SafeRetry extends GoogleCommonSafeRetry {
List<Integer> successfulErrorCodes,
Map tags,
Registry registry) {
+ task?.updateStatus tags.phase, "Attempting $tags.action of $resource..."
return super.doRetry(operation,
resource,
- task,
retryCodes,
successfulErrorCodes,
maxWaitInterval,

refactor(google): Remove Task as a paramter for doRetry (#2981)

Allows use to remove the dependency on `clouddriver-core`.
This is mainly useful because Front50 also depends on
`clouddriver-google-common` and thereby indirectly on all
of clouddriver-core and every dependency it brings in.