-
Notifications
You must be signed in to change notification settings - Fork 20
Allow callers to cancel their request to cancel the script #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Allow callers to cancel their request to cancel the script #1085
Conversation
@@ -79,7 +79,8 @@ async Task<ScriptOperationExecutionResult> ObserveUntilComplete( | |||
{ | |||
if (scriptExecutionCancellationToken.IsCancellationRequested) | |||
{ | |||
lastResult = await scriptExecutor.CancelScript(lastResult.ContextForNextCommand).ConfigureAwait(false); | |||
// We don't want to cancel this operation as it is responsible for stopping the script executing on the Tentacle | |||
lastResult = await scriptExecutor.CancelScript(lastResult.ContextForNextCommand, CancellationToken.None).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CancellationToken.None
is moved up here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this PR is so that we can cancel the cancellation request, so that the cancellation request does not block Octopus Server from shutting down.
But this made me wonder, why is this not an issue for the non-resilient pipeline? Surely it would get told to cancel a running deployment when it shuts down too, right? I would have thought that would also block.
@@ -34,37 +34,43 @@ Task<ScriptExecutionResult> ExecuteScript( | |||
CancellationToken scriptExecutionCancellationToken); | |||
|
|||
/// <summary> | |||
/// Start the script. | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we delete this summary? Yeah, it's simple, but it's better than none.
/// <param name="scriptExecutionCancellationToken"></param> | ||
Task<ScriptStatus?> CompleteScript(CommandContext commandContext, ITentacleClientTaskLog logger, CancellationToken scriptExecutionCancellationToken); | ||
/// <param name="requestCancellationToken">Cancels the inflight request</param> | ||
Task<ScriptStatus?> CompleteScript(CommandContext commandContext, ITentacleClientTaskLog logger, CancellationToken requestCancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, what's the consequence of killing a request to cancel?
I would have thought this would result in the tentacle potentially running the script after we have told the user that we are cancelled, right?
Is this going to be an issue? I.e., is the trade off of shutting down Octopus Server quicker worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does what it says on the tin. So I'll pre-approve it.
I would like to have those questions I raised answered before we merge though, as I want to be sure this is what we want to do.
Background
Otherwise callers of the event driven script executor can't bail out on requests to cancel the script.
Which is preventing octopus from shutting down.
How to review this PR
Quality ✔️
Pre-requisites