Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LukeButters
Copy link
Contributor

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

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

@LukeButters LukeButters requested a review from a team as a code owner April 3, 2025 05:45
@@ -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);
Copy link
Contributor Author

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.

Copy link
Contributor

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.
///
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor

@sburmanoctopus sburmanoctopus left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants