Skip to content

Commit

Permalink
fix(logging): Propagate logging context to cancellation (spinnaker#3819)
Browse files Browse the repository at this point in the history
Currently, cancellation is called on a separate thread and the logging context isn't passed into it.
So if there is an issue in cancellation flow the execution id/stage id aren't propagated to the logger making it hard to debug

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
marchello2000 and mergify[bot] authored Jul 16, 2020
1 parent 0bb15f3 commit 1bb3aa6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.netflix.spinnaker.orca.q.CancelStage
import com.netflix.spinnaker.orca.q.RescheduleExecution
import com.netflix.spinnaker.orca.q.RunTask
import com.netflix.spinnaker.q.Queue
import com.netflix.spinnaker.security.AuthenticatedRequest
import java.util.concurrent.Executor
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Component
Expand Down Expand Up @@ -86,10 +87,11 @@ class CancelStageHandler(
// for the time being we execute this off-thread as some cancel
// routines may run long enough to cause message acknowledgment to
// time out.
executor.execute {
val cancellationClosure = AuthenticatedRequest.propagate {
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 All @@ -100,6 +102,9 @@ class CancelStageHandler(
}
}
}
executor.execute {
cancellationClosure.call()
}
}
}
}
Expand Down

0 comments on commit 1bb3aa6

Please sign in to comment.