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

Enrich TerminateExecution error to tell propeller the execution already terminated #551

Merged
merged 2 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 1 deletion pkg/manager/impl/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1644,15 +1644,17 @@ func (m *ExecutionManager) TerminateExecution(
logger.Infof(ctx, "couldn't find execution [%+v] to save termination cause", request.Id)
return nil, err
}

if common.IsExecutionTerminal(core.WorkflowExecution_Phase(core.WorkflowExecution_Phase_value[executionModel.Phase])) {
return nil, errors.NewFlyteAdminError(codes.PermissionDenied, "Cannot abort an already terminate workflow execution")
return nil, errors.NewAlreadyInTerminalStateError(ctx, "Cannot abort an already terminate workflow execution", executionModel.Phase)
}

err = transformers.SetExecutionAborting(&executionModel, request.Cause, getUser(ctx))
if err != nil {
logger.Debugf(ctx, "failed to add abort metadata for execution [%+v] with err: %v", request.Id, err)
return nil, err
}

err = m.db.ExecutionRepo().Update(ctx, executionModel)
if err != nil {
logger.Debugf(ctx, "failed to save abort cause for terminated execution: %+v with err: %v", request.Id, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/impl/execution_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@ func TestTerminateExecution_AlreadyTerminated(t *testing.T) {
assert.Nil(t, resp)
s, ok := status.FromError(err)
assert.True(t, ok)
assert.Equal(t, codes.PermissionDenied, s.Code())
assert.Equal(t, codes.FailedPrecondition, s.Code())
}

func TestGetExecutionData(t *testing.T) {
Expand Down