Stop workflow in any status (#17271)
Workflows can now be cancelled when not started or enqueued. Also displaying the stop option when selecting all. We got the case of a client that did an infinite loop. So he had a lot of workflows to stop. Supporting select all would have avoid him to wait for 4 hours so we process the runs throttled. This is not something that is supposed to happen often so I did not see the point of refactoring the endpoint. But I wanted the users to have this option just in case
This commit is contained in:
@@ -80,6 +80,13 @@ export class RunWorkflowJob {
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
if (
|
||||
workflowRun.status !== WorkflowRunStatus.ENQUEUED &&
|
||||
workflowRun.status !== WorkflowRunStatus.NOT_STARTED
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const workflowVersion =
|
||||
await this.workflowCommonWorkspaceService.getWorkflowVersionOrFail({
|
||||
workspaceId,
|
||||
|
||||
+4
-1
@@ -156,7 +156,10 @@ export class WorkflowRunWorkspaceService {
|
||||
workflowRunToUpdate.status !== WorkflowRunStatus.ENQUEUED &&
|
||||
workflowRunToUpdate.status !== WorkflowRunStatus.NOT_STARTED
|
||||
) {
|
||||
return;
|
||||
throw new WorkflowRunException(
|
||||
'Workflow run is not enqueued or not started',
|
||||
WorkflowRunExceptionCode.INVALID_OPERATION,
|
||||
);
|
||||
}
|
||||
|
||||
const partialUpdate = {
|
||||
|
||||
+9
-3
@@ -200,12 +200,18 @@ export class WorkflowRunnerWorkspaceService {
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
if (workflowRun.status !== WorkflowRunStatus.RUNNING) {
|
||||
const stoppableStatuses = [
|
||||
WorkflowRunStatus.NOT_STARTED,
|
||||
WorkflowRunStatus.ENQUEUED,
|
||||
WorkflowRunStatus.RUNNING,
|
||||
];
|
||||
|
||||
if (!stoppableStatuses.includes(workflowRun.status)) {
|
||||
throw new WorkflowRunException(
|
||||
'Workflow run is not running',
|
||||
'Workflow run cannot be stopped',
|
||||
WorkflowRunExceptionCode.INVALID_OPERATION,
|
||||
{
|
||||
userFriendlyMessage: msg`Workflow run is not running`,
|
||||
userFriendlyMessage: msg`Workflow run cannot be stopped in its current status`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user