-
Notifications
You must be signed in to change notification settings - Fork 134
/
domain.go
97 lines (86 loc) · 2.21 KB
/
domain.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package job
import (
"time"
v1 "k8s.io/api/core/v1"
networking "k8s.io/api/networking/v1"
)
type SubmitJobMeta struct {
RunMeta *RunMeta
Owner string
OwnershipGroups []string
}
type SubmitJob struct {
Meta SubmitJobMeta
Pod *v1.Pod
Ingresses []*networking.Ingress
Services []*v1.Service
}
type RunMeta struct {
JobId string
RunId string
JobSet string
Queue string
}
func (r *RunMeta) DeepCopy() *RunMeta {
return &RunMeta{
JobId: r.JobId,
RunId: r.RunId,
JobSet: r.JobSet,
Queue: r.Queue,
}
}
type RunPhase int
const (
// Invalid is when the job run provided could not be processed
// examples: invalid id formats, a missing podspec definition
Invalid RunPhase = iota
// Leased is the initial state and occurs before we submit the run to kubernetes
Leased
// SuccessfulSubmission is when a job was successfully sent to the k8s api
SuccessfulSubmission
// FailedSubmission is when a failed submission has been reported
FailedSubmission
// Active is any run present in Kubernetes
Active
// Missing is when we have lost track of the run
// This may happen if we submit a pod to kubernetes but the pod never becomes present in kubernetes
Missing
)
func (r RunPhase) String() string {
switch r {
case Invalid:
return "invalid"
case Leased:
return "leased"
case SuccessfulSubmission:
return "successful-submission"
case FailedSubmission:
return "failed-submission"
case Active:
return "active"
case Missing:
return "missing"
default:
return "unknown"
}
}
type RunState struct {
Meta *RunMeta
Job *SubmitJob
KubernetesId string
Phase RunPhase
CancelRequested bool
PreemptionRequested bool
LastPhaseTransitionTime time.Time
}
func (r *RunState) DeepCopy() *RunState {
return &RunState{
Meta: r.Meta.DeepCopy(),
Job: r.Job, // This isn't deep copied right now - as it would be expensive to do so
KubernetesId: r.KubernetesId,
Phase: r.Phase,
CancelRequested: r.CancelRequested,
PreemptionRequested: r.PreemptionRequested,
LastPhaseTransitionTime: r.LastPhaseTransitionTime,
}
}