-
Notifications
You must be signed in to change notification settings - Fork 611
/
nodes.go
281 lines (234 loc) · 8.72 KB
/
nodes.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
package v1alpha1
import (
"bytes"
"time"
"github.com/golang/protobuf/jsonpb"
typesv1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
)
var marshaler = jsonpb.Marshaler{}
type OutputVarMap struct {
*core.VariableMap
}
func (in *OutputVarMap) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.VariableMap); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (in *OutputVarMap) UnmarshalJSON(b []byte) error {
in.VariableMap = &core.VariableMap{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.VariableMap)
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *OutputVarMap) DeepCopyInto(out *OutputVarMap) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
type Binding struct {
*core.Binding
}
func (in *Binding) UnmarshalJSON(b []byte) error {
in.Binding = &core.Binding{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.Binding)
}
func (in *Binding) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.Binding); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Binding) DeepCopyInto(out *Binding) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
// Strategy to be used to Retry a node that is in RetryableFailure state
type RetryStrategy struct {
// MinAttempts implies the at least n attempts to try this node before giving up. The at least here is because we may
// fail to write the attempt information and end up retrying again.
// Also `0` and `1` both mean at least one attempt will be done. 0 is a degenerate case.
MinAttempts *int `json:"minAttempts"`
// TODO Add retrydelay?
}
type Alias struct {
core.Alias
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Alias) DeepCopyInto(out *Alias) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
type NodeMetadata struct {
core.NodeMetadata
}
func (in *NodeMetadata) DeepCopyInto(out *NodeMetadata) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
type ExtendedResources struct {
*core.ExtendedResources
}
func (in *ExtendedResources) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.ExtendedResources); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (in *ExtendedResources) UnmarshalJSON(b []byte) error {
in.ExtendedResources = &core.ExtendedResources{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.ExtendedResources)
}
func (in *ExtendedResources) DeepCopyInto(out *ExtendedResources) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
type NodeSpec struct {
ID NodeID `json:"id"`
Name string `json:"name,omitempty"`
Resources *typesv1.ResourceRequirements `json:"resources,omitempty"`
Kind NodeKind `json:"kind"`
BranchNode *BranchNodeSpec `json:"branch,omitempty"`
TaskRef *TaskID `json:"task,omitempty"`
WorkflowNode *WorkflowNodeSpec `json:"workflow,omitempty"`
GateNode *GateNodeSpec `json:"gate,omitempty"`
ArrayNode *ArrayNodeSpec `json:"array,omitempty"`
InputBindings []*Binding `json:"inputBindings,omitempty"`
Config *typesv1.ConfigMap `json:"config,omitempty"`
RetryStrategy *RetryStrategy `json:"retry,omitempty"`
OutputAliases []Alias `json:"outputAlias,omitempty"`
// SecurityContext holds pod-level security attributes and common container settings.
// Optional: Defaults to empty. See type description for default values of each field.
// +optional
SecurityContext *typesv1.PodSecurityContext `json:"securityContext,omitempty" protobuf:"bytes,14,opt,name=securityContext"`
// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec.
// If specified, these secrets will be passed to individual puller implementations for them to use. For example,
// in the case of docker, only DockerConfig type secrets are honored.
// More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
ImagePullSecrets []typesv1.LocalObjectReference `json:"imagePullSecrets,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,15,rep,name=imagePullSecrets"`
// Specifies the hostname of the Pod
// If not specified, the pod's hostname will be set to a system-defined value.
// +optional
Hostname string `json:"hostname,omitempty" protobuf:"bytes,16,opt,name=hostname"`
// If specified, the fully qualified Pod hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
// If not specified, the pod will not have a domainname at all.
// +optional
Subdomain string `json:"subdomain,omitempty" protobuf:"bytes,17,opt,name=subdomain"`
// If specified, the pod's scheduling constraints
// +optional
Affinity *typesv1.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`
// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
// +optional
SchedulerName string `json:"schedulerName,omitempty" protobuf:"bytes,19,opt,name=schedulerName"`
// If specified, includes overrides for extended resources to allocate to the
// node.
// +optional
ExtendedResources *ExtendedResources `json:"extendedResources,omitempty" protobuf:"bytes,20,opt,name=extendedResources"`
// If specified, the pod's tolerations.
// +optional
Tolerations []typesv1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
// Node execution timeout
ExecutionDeadline *v1.Duration `json:"executionDeadline,omitempty"`
// StartTime before the system will actively try to mark it failed and kill associated containers.
// Value must be a positive integer. This includes time spent waiting in the queue.
// +optional
ActiveDeadline *v1.Duration `json:"activeDeadline,omitempty"`
// The value set to True means task is OK with getting interrupted
// +optional
Interruptible *bool `json:"interruptible,omitempty"`
ContainerImage string `json:"containerImage,omitempty"`
}
func (in *NodeSpec) GetName() string {
return in.Name
}
func (in *NodeSpec) GetRetryStrategy() *RetryStrategy {
return in.RetryStrategy
}
func (in *NodeSpec) GetExecutionDeadline() *time.Duration {
if in.ExecutionDeadline != nil {
return &in.ExecutionDeadline.Duration
}
return nil
}
func (in *NodeSpec) GetActiveDeadline() *time.Duration {
if in.ActiveDeadline != nil {
return &in.ActiveDeadline.Duration
}
return nil
}
func (in *NodeSpec) IsInterruptible() *bool {
return in.Interruptible
}
func (in *NodeSpec) GetConfig() *typesv1.ConfigMap {
return in.Config
}
func (in *NodeSpec) GetResources() *typesv1.ResourceRequirements {
return in.Resources
}
func (in *NodeSpec) GetExtendedResources() *core.ExtendedResources {
if in.ExtendedResources == nil {
return nil
}
return in.ExtendedResources.ExtendedResources
}
func (in *NodeSpec) GetOutputAlias() []Alias {
return in.OutputAliases
}
func (in *NodeSpec) GetWorkflowNode() ExecutableWorkflowNode {
if in.WorkflowNode == nil {
return nil
}
return in.WorkflowNode
}
func (in *NodeSpec) GetBranchNode() ExecutableBranchNode {
if in.BranchNode == nil {
return nil
}
return in.BranchNode
}
func (in *NodeSpec) GetGateNode() ExecutableGateNode {
if in.GateNode == nil {
return nil
}
return in.GateNode
}
func (in *NodeSpec) GetArrayNode() ExecutableArrayNode {
if in.ArrayNode == nil {
return nil
}
return in.ArrayNode
}
func (in *NodeSpec) GetTaskID() *TaskID {
return in.TaskRef
}
func (in *NodeSpec) GetKind() NodeKind {
return in.Kind
}
func (in *NodeSpec) GetID() NodeID {
return in.ID
}
func (in *NodeSpec) IsStartNode() bool {
return in.ID == StartNodeID
}
func (in *NodeSpec) IsEndNode() bool {
return in.ID == EndNodeID
}
func (in *NodeSpec) GetInputBindings() []*Binding {
return in.InputBindings
}
func (in *NodeSpec) GetContainerImage() string {
return in.ContainerImage
}