/
executions.go
52 lines (41 loc) · 1.37 KB
/
executions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package common
import (
"fmt"
"k8s.io/apimachinery/pkg/util/rand"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
)
const ExecutionIDLength = 20
const ExecutionStringFormat = "a%s"
/* #nosec */
func GetExecutionName(seed int64) string {
rand.Seed(seed)
return fmt.Sprintf(ExecutionStringFormat, rand.String(ExecutionIDLength-1))
}
var terminalExecutionPhases = map[core.WorkflowExecution_Phase]bool{
core.WorkflowExecution_SUCCEEDED: true,
core.WorkflowExecution_FAILED: true,
core.WorkflowExecution_TIMED_OUT: true,
core.WorkflowExecution_ABORTED: true,
}
var terminalNodeExecutionPhases = map[core.NodeExecution_Phase]bool{
core.NodeExecution_SUCCEEDED: true,
core.NodeExecution_FAILED: true,
core.NodeExecution_TIMED_OUT: true,
core.NodeExecution_ABORTED: true,
core.NodeExecution_SKIPPED: true,
core.NodeExecution_RECOVERED: true,
}
var terminalTaskExecutionPhases = map[core.TaskExecution_Phase]bool{
core.TaskExecution_SUCCEEDED: true,
core.TaskExecution_FAILED: true,
core.TaskExecution_ABORTED: true,
}
func IsExecutionTerminal(phase core.WorkflowExecution_Phase) bool {
return terminalExecutionPhases[phase]
}
func IsNodeExecutionTerminal(phase core.NodeExecution_Phase) bool {
return terminalNodeExecutionPhases[phase]
}
func IsTaskExecutionTerminal(phase core.TaskExecution_Phase) bool {
return terminalTaskExecutionPhases[phase]
}