This repository was archived by the owner on Feb 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathappwrapper_types.go
272 lines (197 loc) · 8.36 KB
/
appwrapper_types.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
/*
Copyright 2023 IBM Corporation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// AppWrapperSpec defines the desired state of AppWrapper
type AppWrapperSpec struct {
// Priority
Priority int32 `json:"priority,omitempty"`
// Priority slope
NotImplemented_PrioritySlope resource.Quantity `json:"priorityslope,omitempty"`
NotImplemented_Service AppWrapperService `json:"service,omitempty"`
// Wrapped resources
Resources AppWrapperResources `json:"resources"`
NotImplemented_Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Scheduling specifies the parameters used for scheduling the wrapped resources.
// It defines the policy for requeuing jobs based on the number of running pods.
Scheduling SchedulingSpec `json:"schedulingSpec,omitempty"`
}
type SchedulingSpec struct {
NotImplemented_NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Minimum number of expected running and successful pods.
// Set to -1 to disable pod monitoring, cleanup on failure, and termination detection based on pod counts.
// Set to 0 to enable pod monitoring (at least 1 pod), cleanup on failure, and disable termination detection.
// Set to n>=1 to enable pod monitoring (at least n pods), cleanup on failure, and termination detection.
MinAvailable int32 `json:"minAvailable,omitempty"`
// Requeuing specification
Requeuing RequeuingSpec `json:"requeuing,omitempty"`
NotImplemented_DispatchDuration NotImplemented_DispatchDurationSpec `json:"dispatchDuration,omitempty"`
}
type NotImplemented_DispatchDurationSpec struct {
Expected int32 `json:"expected,omitempty"`
Limit int32 `json:"limit,omitempty"`
Overrun bool `json:"overrun,omitempty"`
}
type RequeuingSpec struct {
NotImplemented_InitialTimeInSeconds int64 `json:"initialTimeInSeconds,omitempty"`
// Initial waiting time before requeuing conditions are checked
// +kubebuilder:default=270
TimeInSeconds int64 `json:"timeInSeconds,omitempty"`
// +kubebuilder:default=0
NotImplemented_MaxTimeInSeconds int64 `json:"maxTimeInSeconds,omitempty"`
// +kubebuilder:default=exponential
NotImplemented_GrowthType string `json:"growthType,omitempty"`
// +kubebuilder:default=0
NotImplemented_NumRequeuings int32 `json:"numRequeuings,omitempty"`
// Max requeuings permitted (infinite if zero)
// +kubebuilder:default=0
MaxNumRequeuings int32 `json:"maxNumRequeuings,omitempty"`
// Enable forced deletion after delay if greater than zero
// +kubebuilder:default=570
ForceDeletionTimeInSeconds int64 `json:"forceDeletionTimeInSeconds,omitempty"`
// Waiting time before trying to dispatch again after requeuing
// +kubebuilder:default=90
PauseTimeInSeconds int64 `json:"pauseTimeInSeconds,omitempty"`
}
// AppWrapperStatus defines the observed state of AppWrapper
type AppWrapperStatus struct {
// State
State AppWrapperState `json:"state,omitempty"`
// Status of wrapped resources
Step AppWrapperStep `json:"step,omitempty"`
// When last dispatched
DispatchTimestamp metav1.Time `json:"dispatchTimestamp,omitempty"`
// When last requeued
RequeueTimestamp metav1.Time `json:"requeueTimestamp,omitempty"`
// How many times restarted
Restarts int32 `json:"restarts"`
// Transition log
Transitions []AppWrapperTransition `json:"transitions,omitempty"`
// Number of transitions
TransitionCount int32 `json:"transitionCount,omitempty"`
// Conditions
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
// AppWrapperState is the label for the AppWrapper status
type AppWrapperState string
// AppWrapperState is the status of wrapped resources
type AppWrapperStep string
// AppWrapperQueuedReason is the Type for the Queued Condition
type AppWrapperQueuedReason string
const (
// Initial state upon creation of the AppWrapper object
Empty AppWrapperState = ""
// AppWrapper has not been dispatched yet or has been requeued
Queued AppWrapperState = "Pending"
// AppWrapper has been dispatched and not requeued
Running AppWrapperState = "Running"
// AppWrapper completed successfully
Succeeded AppWrapperState = "Completed"
// AppWrapper failed and is not requeued
Failed AppWrapperState = "Failed"
// Resources are not deployed
Idle AppWrapperStep = ""
// The MCAD dispatcher is dispatching an appwrapper for execution by the runner
Dispatching AppWrapperStep = "dispatching"
// The MCAD runner has accepted an appwrapper for execution
Accepting AppWrapperStep = "accepting"
// The MCAD runner is in the process of creating the wrapped resources
Creating AppWrapperStep = "creating"
// The wrapped resources have been deployed successfully
Created AppWrapperStep = "created"
// The MCAD runner is in the process of deleting the wrapped resources
Deleting AppWrapperStep = "deleting"
// The MCAD runner has returned control of an appwrapper to the dispatcher
Deleted AppWrapperStep = "deleted"
// Queued because of insufficient available resources
QueuedInsufficientResources AppWrapperQueuedReason = "InsufficientResources"
// Queued because of insufficient available quota
QueuedInsufficientQuota AppWrapperQueuedReason = "InsufficientQuota"
// Queued because it was requeued
QueuedRequeue AppWrapperQueuedReason = "Requeued"
// Not Queued because it was dispatched
QueuedDispatch AppWrapperQueuedReason = "Dispatched"
)
// AppWrapperService
type AppWrapperService struct {
Spec v1.ServiceSpec `json:"spec"`
}
// AppWrapper resources
type AppWrapperResources struct {
GenericItems []GenericItem `json:"GenericItems,omitempty"`
}
// AppWrapper resource
type GenericItem struct {
NotImplemented_Replicas int32 `json:"replicas,omitempty"`
NotImplemented_MinAvailable *int32 `json:"minavailable,omitempty"`
NotImplemented_Allocated int32 `json:"allocated,omitempty"`
NotImplemented_Priority int32 `json:"priority,omitempty"`
NotImplemented_PrioritySlope resource.Quantity `json:"priorityslope,omitempty"`
// The template for the resource
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:EmbeddedResource
GenericTemplate runtime.RawExtension `json:"generictemplate,omitempty"`
// Array of resource requests
CustomPodResources []CustomPodResource `json:"custompodresources,omitempty"`
// A comma-separated list of keywords to match against condition types
CompletionStatus string `json:"completionstatus,omitempty"`
}
// Resource requests
type CustomPodResource struct {
// Replica count
Replicas int32 `json:"replicas"`
// Resource requests per replica
Requests v1.ResourceList `json:"requests"`
// Limits per replica
Limits v1.ResourceList `json:"limits,omitempty"`
}
// State transition
type AppWrapperTransition struct {
// Timestamp
Time metav1.Time `json:"time"`
// Reason
Reason string `json:"reason,omitempty"`
// Controller that made the transition
Controller string `json:"controller,omitempty"`
// State entered
State AppWrapperState `json:"state"`
// Status of wrapped resources
Step AppWrapperStep `json:"step,omitempty"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=`.status.state`
//+kubebuilder:printcolumn:name="Restarts",type="integer",JSONPath=`.status.restarts`
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// AppWrapper is the Schema for the appwrappers API
type AppWrapper struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec AppWrapperSpec `json:"spec,omitempty"`
Status AppWrapperStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// AppWrapperList contains a list of AppWrapper
type AppWrapperList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AppWrapper `json:"items"`
}
func init() {
SchemeBuilder.Register(&AppWrapper{}, &AppWrapperList{})
}