Skip to content

Commit

Permalink
fix(queue): Propagate auth context on CancelStageHandler (#3027)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Sebastian authored and marchello2000 committed Jul 8, 2019
1 parent 752aaf4 commit 974995e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.orca.TaskResolver
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilderFactory
import com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.PIPELINE
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.pipeline.util.StageNavigator
import com.netflix.spinnaker.orca.q.CancelStage
import com.netflix.spinnaker.orca.q.RescheduleExecution
import com.netflix.spinnaker.orca.q.RunTask
Expand All @@ -35,10 +36,11 @@ class CancelStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
override val stageDefinitionBuilderFactory: StageDefinitionBuilderFactory,
override val stageNavigator: StageNavigator,

@Qualifier("messageHandlerPool") private val executor: Executor,
private val taskResolver: TaskResolver
) : OrcaMessageHandler<CancelStage>, StageBuilderAware {
) : OrcaMessageHandler<CancelStage>, StageBuilderAware, AuthenticationAware {

override val messageType = CancelStage::class.java

Expand Down Expand Up @@ -84,7 +86,9 @@ class CancelStageHandler(
// routines may run long enough to cause message acknowledgment to
// time out.
executor.execute {
builder.cancel(stage)
stage.withAuth {
builder.cancel(stage)
}
// Special case for PipelineStage to ensure prompt cancellation of
// child pipelines and deployment strategies regardless of task backoff
if (stage.type.equals("pipeline", true) && stage.context.containsKey("executionId")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.netflix.spinnaker.orca.pipeline.DefaultStageDefinitionBuilderFactory
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilder
import com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.PIPELINE
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.pipeline.util.StageNavigator
import com.netflix.spinnaker.orca.q.CancelStage
import com.netflix.spinnaker.orca.q.singleTaskStage
import com.netflix.spinnaker.q.Queue
Expand All @@ -52,6 +53,7 @@ object CancelStageHandlerTest : SubjectSpek<CancelStageHandler>({
val repository: ExecutionRepository = mock()
val executor = MoreExecutors.directExecutor()
val taskResolver: TaskResolver = TaskResolver(emptyList())
val stageNavigator: StageNavigator = mock()

val cancellableStage: CancelableStageDefinitionBuilder = mock()
val stageResolver = StageResolver(listOf(singleTaskStage, cancellableStage))
Expand All @@ -61,6 +63,7 @@ object CancelStageHandlerTest : SubjectSpek<CancelStageHandler>({
queue,
repository,
DefaultStageDefinitionBuilderFactory(stageResolver),
stageNavigator,
executor,
taskResolver
)
Expand Down

0 comments on commit 974995e

Please sign in to comment.