Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit 1026231

Browse files
authored
Enrich TerminateExecution error to tell propeller the execution already terminated (#551)
* Enrich TerminateWorkflow error to tell propeller the execution already terminated Signed-off-by: Haytham Abuelfutuh <[email protected]> * Fix unit test Signed-off-by: Haytham Abuelfutuh <[email protected]> --------- Signed-off-by: Haytham Abuelfutuh <[email protected]>
1 parent 97a6aa4 commit 1026231

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: pkg/manager/impl/execution_manager.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1544,15 +1544,17 @@ func (m *ExecutionManager) TerminateExecution(
15441544
logger.Infof(ctx, "couldn't find execution [%+v] to save termination cause", request.Id)
15451545
return nil, err
15461546
}
1547+
15471548
if common.IsExecutionTerminal(core.WorkflowExecution_Phase(core.WorkflowExecution_Phase_value[executionModel.Phase])) {
1548-
return nil, errors.NewFlyteAdminError(codes.PermissionDenied, "Cannot abort an already terminate workflow execution")
1549+
return nil, errors.NewAlreadyInTerminalStateError(ctx, "Cannot abort an already terminate workflow execution", executionModel.Phase)
15491550
}
15501551

15511552
err = transformers.SetExecutionAborting(&executionModel, request.Cause, getUser(ctx))
15521553
if err != nil {
15531554
logger.Debugf(ctx, "failed to add abort metadata for execution [%+v] with err: %v", request.Id, err)
15541555
return nil, err
15551556
}
1557+
15561558
err = m.db.ExecutionRepo().Update(ctx, executionModel)
15571559
if err != nil {
15581560
logger.Debugf(ctx, "failed to save abort cause for terminated execution: %+v with err: %v", request.Id, err)

Diff for: pkg/manager/impl/execution_manager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ func TestTerminateExecution_AlreadyTerminated(t *testing.T) {
32313231
assert.Nil(t, resp)
32323232
s, ok := status.FromError(err)
32333233
assert.True(t, ok)
3234-
assert.Equal(t, codes.PermissionDenied, s.Code())
3234+
assert.Equal(t, codes.FailedPrecondition, s.Code())
32353235
}
32363236

32373237
func TestGetExecutionData(t *testing.T) {

0 commit comments

Comments
 (0)