Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/Octopus.Tentacle.Client/ScriptExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public async Task<ScriptOperationExecutionResult> GetStatus(CommandContext comma
return await scriptExecutor.GetStatus(commandContext, cancellationToken);
}

public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext, CancellationToken cancellationToken)
{
var scriptExecutorFactory = CreateScriptExecutorFactory();
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(commandContext.ScripServiceVersionUsed);

return await scriptExecutor.CancelScript(commandContext);
return await scriptExecutor.CancelScript(commandContext, cancellationToken);
}

public async Task<ScriptStatus?> CompleteScript(CommandContext commandContext, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Task<ScriptOperationExecutionResult> StartScript(ExecuteScriptCommand command,
/// </summary>
/// <param name="commandContext">The CommandContext from the previous command</param>
/// <returns>The result, which includes the CommandContext for the next command</returns>
Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext);
Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext, CancellationToken cancellationToken);

/// <summary>
/// Complete the script.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async Task<KubernetesScriptStatusResponseV1> GetStatusAction(CancellationToken c
return Map(kubernetesScriptStatusResponseV1);
}

public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext, CancellationToken cancellationToken)
{
async Task<KubernetesScriptStatusResponseV1> CancelScriptAction(CancellationToken ct)
{
Expand All @@ -173,8 +173,7 @@ async Task<KubernetesScriptStatusResponseV1> CancelScriptAction(CancellationToke
CancelScriptAction,
logger,
clientOperationMetricsBuilder,
// We don't want to cancel this operation as it is responsible for stopping the script executing on the Tentacle
CancellationToken.None).ConfigureAwait(false);
cancellationToken).ConfigureAwait(false);
return Map(kubernetesScriptStatusResponseV1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public async Task<ScriptOperationExecutionResult> GetStatus(CommandContext comma
return Map(scriptStatusResponseV1);
}

public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext, CancellationToken cancellationToken)
{
var response = await rpcCallExecutor.ExecuteWithNoRetries(
RpcCall.Create<IScriptService>(nameof(IScriptService.CancelScript)),
Expand All @@ -119,7 +119,7 @@ public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext co
},
logger,
clientOperationMetricsBuilder,
CancellationToken.None).ConfigureAwait(false);
cancellationToken).ConfigureAwait(false);

return Map(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async Task<ScriptStatusResponseV2> GetStatusAction(CancellationToken ct)
return Map(scriptStatusResponseV2);
}

public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext, CancellationToken cancellationToken)
{
async Task<ScriptStatusResponseV2> CancelScriptAction(CancellationToken ct)
{
Expand All @@ -166,8 +166,7 @@ async Task<ScriptStatusResponseV2> CancelScriptAction(CancellationToken ct)
CancelScriptAction,
logger,
clientOperationMetricsBuilder,
// We don't want to cancel this operation as it is responsible for stopping the script executing on the Tentacle
CancellationToken.None).ConfigureAwait(false);
cancellationToken).ConfigureAwait(false);
return Map(scriptStatusResponseV2);
}

Expand Down