diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/ConditionAwareDeployStagePreprocessor.java b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/ConditionAwareDeployStagePreprocessor.java index 6810c69185..7cacbe7f10 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/ConditionAwareDeployStagePreprocessor.java +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/ConditionAwareDeployStagePreprocessor.java @@ -17,12 +17,10 @@ package com.netflix.spinnaker.orca.clouddriver.pipeline; import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.strategies.DeployStagePreProcessor; -import com.netflix.spinnaker.orca.conditions.ConditionSupplier; import com.netflix.spinnaker.orca.kato.pipeline.support.StageData; import com.netflix.spinnaker.orca.pipeline.WaitForConditionStage; import com.netflix.spinnaker.orca.pipeline.model.Stage; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; @@ -33,7 +31,6 @@ @Component @ConditionalOnExpression("${tasks.evaluateCondition.enabled:false}") -@ConditionalOnBean(value = ConditionSupplier.class) public class ConditionAwareDeployStagePreprocessor implements DeployStagePreProcessor { private final WaitForConditionStage waitForConditionStage; diff --git a/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTask.java b/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTask.java index 6d77fda069..04f743d899 100644 --- a/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTask.java +++ b/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTask.java @@ -27,7 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; import javax.annotation.Nonnull; @@ -41,17 +41,17 @@ import static com.netflix.spinnaker.orca.pipeline.WaitForConditionStage.WaitForConditionContext.*; @Component -@ConditionalOnBean(ConditionSupplier.class) +@ConditionalOnExpression("${tasks.evaluateCondition.enabled:false}") public class EvaluateConditionTask implements RetryableTask { private static final Logger log = LoggerFactory.getLogger(EvaluateConditionTask.class); private final ConditionConfigurationProperties conditionsConfigurationProperties; - private final List suppliers; + private final Optional> suppliers; private final Clock clock; @Autowired public EvaluateConditionTask( ConditionConfigurationProperties conditionsConfigurationProperties, - List suppliers, + Optional> suppliers, Clock clock ) { this.conditionsConfigurationProperties = conditionsConfigurationProperties; @@ -73,7 +73,7 @@ public long getTimeout() { @Override public TaskResult execute(@Nonnull Stage stage) { final WaitForConditionContext ctx = stage.mapTo(WaitForConditionContext.class); - if (ctx.getStatus() == Status.SKIPPED) { + if (ctx.getStatus() == Status.SKIPPED || !suppliers.isPresent()) { return new TaskResult(ExecutionStatus.SUCCEEDED, Collections.singletonMap("status", Status.SKIPPED)); } @@ -88,7 +88,7 @@ public TaskResult execute(@Nonnull Stage stage) { } try { - Set conditions = suppliers + Set conditions = suppliers.get() .stream() .flatMap(supplier -> supplier.getConditions(stage).stream()).filter(Objects::nonNull) .collect(Collectors.toSet()); diff --git a/orca-core/src/test/groovy/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTaskSpec.groovy b/orca-core/src/test/groovy/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTaskSpec.groovy index 1670d3ad2b..fa220db58e 100644 --- a/orca-core/src/test/groovy/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTaskSpec.groovy +++ b/orca-core/src/test/groovy/com/netflix/spinnaker/orca/pipeline/tasks/EvaluateConditionTaskSpec.groovy @@ -44,7 +44,7 @@ class EvaluateConditionTaskSpec extends Specification { @Subject def task = new EvaluateConditionTask( conditionsConfigurationProperties, - [conditionSupplier], + Optional.of([conditionSupplier]), clock )