Skip to content

Commit

Permalink
fix(*): Change event & saga root exceptions to nonretryable (#4095)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Oct 15, 2019
1 parent ac1373c commit 696230c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public boolean isRetryable(@Nonnull Exception e) {
return Optional.ofNullable(((SpinnakerException) e).getRetryable()).orElse(false);
}

boolean retryable = false;
try {
String dynamicNonRetryableClasses =
dynamicConfigService.getConfig(
Expand All @@ -69,13 +70,16 @@ public boolean isRetryable(@Nonnull Exception e) {
.flatMap(Collection::stream)
.collect(Collectors.toList());

return !nonRetryableClasses.contains(e.getClass().getName());
retryable = !nonRetryableClasses.contains(e.getClass().getName());
} else {
retryable = !properties.getNonRetryableClasses().contains(e.getClass().getName());
}
return !properties.getNonRetryableClasses().contains(e.getClass().getName());

} catch (Exception caughtException) {
log.error("Unexpected exception while processing retryable classes", caughtException);
return false;
}

log.trace("Evaluated retryable status for {} to '{}'", e.getClass().getName(), retryable);

return retryable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ class AggregateChangeRejectedException(
"Attempting to save new events against an old aggregate version " +
"(version: $aggregateVersion, originatingVersion: $originatingVersion)"
) {
override fun getRetryable() = true
init {
retryable = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ import com.netflix.spinnaker.kork.exceptions.IntegrationException
/**
* Thrown when a [SpinnakerEvent] cannot be created.
*/
class InvalidEventTypeException(cause: Throwable) : IntegrationException(cause), EventingException
class InvalidEventTypeException(cause: Throwable) : IntegrationException(cause), EventingException {
init {
retryable = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ import com.netflix.spinnaker.kork.exceptions.IntegrationException
*/
class UninitializedEventException : IntegrationException(
"Cannot access event metadata before initialization"
), EventingException
), EventingException {
init {
retryable = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ import com.netflix.spinnaker.clouddriver.saga.flow.SagaAction
*/
class SagaFlowActionNotFoundException(sagaAction: Class<out SagaAction<*>>) : SagaIntegrationException(
"Could not find a SagaAction in flow for ${sagaAction.simpleName}"
)
) {
init {
retryable = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ open class SagaIntegrationException(message: String, cause: Throwable?) :
constructor(message: String) : this(message, null)

init {
// Defer to the cause for retryable; but default to retryable if the retryable flag is unavailable.
// Defer to the cause for retryable; default to not retryable if the retryable flag is unavailable.
retryable = if (cause is SpinnakerException) {
cause.retryable ?: true
cause.retryable ?: false
} else {
true
false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ package com.netflix.spinnaker.clouddriver.saga.exceptions
/**
* Thrown when a [Saga] requires a specific [SagaCommand] type, but one does not exist in the [Saga] event log.
*/
class SagaMissingRequiredCommandException(message: String) : SagaIntegrationException(message)
class SagaMissingRequiredCommandException(message: String) : SagaIntegrationException(message) {
init {
retryable = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ package com.netflix.spinnaker.clouddriver.saga.exceptions
/**
* Thrown when a [Saga] cannot be found but it is expected to already exist.
*/
class SagaNotFoundException(message: String) : SagaSystemException(message)
class SagaNotFoundException(message: String) : SagaSystemException(message) {
init {
retryable = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ class SagaStateIntegrationException(message: String) : SagaIntegrationException(
fun typeNotFound(expectedType: Class<*>, saga: Saga) =
SagaStateIntegrationException(
"No SagaEvent present for requested type: ${expectedType.simpleName} (${saga.name}/${saga.id})"
)
).also {
it.retryable = false
}

fun tooManyResults(expectedType: Class<*>, saga: Saga) =
SagaStateIntegrationException(
"More than one SagaEvent present for requested type: ${expectedType.simpleName} (${saga.name}/${saga.id})"
)
).also {
it.retryable = false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ open class SagaSystemException(message: String, cause: Throwable?) : SystemExcep
constructor(message: String) : this(message, null)

init {
retryable = true
retryable = false
}
}

0 comments on commit 696230c

Please sign in to comment.