We want a user to be able to cancel runs early, both "apply" and "commit" runs. We also want to be able to cancel Deploys & Workflows.
However, can we cancel saves, mid save? Let's look at the code path.
Because the concerns happen in different places. If we are trying to cancel a "deploy", it may be that we are canceling during a "save", "workflow update", or "run".
Just Runs
Add cancelRunCh, channel living on Orchestrator
In runWorkflow and ApplyWorkflow, wrap the context in a context enclosure. In a go routine, select: for messages coming off the cancelRunCh, if it matches the runID, call cancel, and for the ctx.Done, close the routine after either happens.
Add orchestrator.CancelRun that takes a runID string & sends it over the cancleRunCh channel.
add CancelRun method in lib.Automation that takes a runID string
add method endpoint AECancelRun
Testing this is going to be annoying. New test? ApplyWorkflow and RunWorkflow where the apply & run functions delay for 4 seconds. Test that after we call CancelRun, we timeout within less time.
We want a user to be able to cancel runs early, both "apply" and "commit" runs. We also want to be able to cancel
Deploys
&Workflows
.However, can we cancel saves, mid save? Let's look at the code path.
Because the concerns happen in different places. If we are trying to cancel a "deploy", it may be that we are canceling during a "save", "workflow update", or "run".
Just Runs
cancelRunCh
, channel living onOrchestrator
runWorkflow
andApplyWorkflow
, wrap the context in a context enclosure. In a go routine, select: for messages coming off thecancelRunCh
, if it matches the runID, callcancel
, and for the ctx.Done, close the routine after either happens.orchestrator.CancelRun
that takes a runID string & sends it over thecancleRunCh
channel.CancelRun
method inlib.Automation
that takes a runID stringAECancelRun
ApplyWorkflow
andRunWorkflow
where theapply
&run
functions delay for 4 seconds. Test that after we callCancelRun
, we timeout within less time.