...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package recorder
17
18 import (
19 "fmt"
20 "strings"
21
22 corev1 "k8s.io/api/core/v1"
23
24 "github.com/chaos-mesh/chaos-mesh/api/v1alpha1"
25 )
26
27 type InvalidEntry struct {
28 EntryTemplate string
29 }
30
31 func (it InvalidEntry) Type() string {
32 return corev1.EventTypeWarning
33 }
34
35 func (it InvalidEntry) Reason() string {
36 return v1alpha1.InvalidEntry
37 }
38
39 func (it InvalidEntry) Message() string {
40 return fmt.Sprintf("failed to spawn new entry node of workflow, entry: %s", it.EntryTemplate)
41 }
42
43 type EntryCreated struct {
44 Entry string
45 }
46
47 func (it EntryCreated) Type() string {
48 return corev1.EventTypeNormal
49 }
50
51 func (it EntryCreated) Reason() string {
52 return v1alpha1.EntryCreated
53 }
54
55 func (it EntryCreated) Message() string {
56 return fmt.Sprintf("entry node created, entry node %s", it.Entry)
57 }
58
59 type NodesCreated struct {
60 ChildNodes []string
61 }
62
63 func (it NodesCreated) Type() string {
64 return corev1.EventTypeNormal
65 }
66
67 func (it NodesCreated) Reason() string {
68 return v1alpha1.NodesCreated
69 }
70
71 func (it NodesCreated) Message() string {
72 return fmt.Sprintf("child nodes created, %s", strings.Join(it.ChildNodes, ","))
73 }
74
75 type ChaosCustomResourceCreated struct {
76 Name string
77 Kind string
78 }
79
80 func (it ChaosCustomResourceCreated) Type() string {
81 return corev1.EventTypeNormal
82 }
83
84 func (it ChaosCustomResourceCreated) Reason() string {
85 return v1alpha1.ChaosCRCreated
86 }
87
88 func (it ChaosCustomResourceCreated) Message() string {
89 return fmt.Sprintf("chaos CR %s created", it.Name)
90 }
91
92 type ChaosCustomResourceCreateFailed struct {
93 }
94
95 func (it ChaosCustomResourceCreateFailed) Type() string {
96 return corev1.EventTypeWarning
97 }
98
99 func (it ChaosCustomResourceCreateFailed) Reason() string {
100 return v1alpha1.ChaosCRCreateFailed
101 }
102
103 func (it ChaosCustomResourceCreateFailed) Message() string {
104 return "failed to create chaos CR"
105 }
106
107 type ChaosCustomResourceDeleted struct {
108 Name string
109 Kind string
110 }
111
112 func (it ChaosCustomResourceDeleted) Type() string {
113 return corev1.EventTypeNormal
114 }
115
116 func (it ChaosCustomResourceDeleted) Reason() string {
117 return v1alpha1.ChaosCRDeleted
118 }
119
120 func (it ChaosCustomResourceDeleted) Message() string {
121 return fmt.Sprintf("chaos CR %s deleted", it.Name)
122 }
123
124 type ChaosCustomResourceDeleteFailed struct {
125 Name string
126 Kind string
127 }
128
129 func (it ChaosCustomResourceDeleteFailed) Type() string {
130 return corev1.EventTypeWarning
131 }
132
133 func (it ChaosCustomResourceDeleteFailed) Reason() string {
134 return v1alpha1.ChaosCRDeleteFailed
135 }
136
137 func (it ChaosCustomResourceDeleteFailed) Message() string {
138 return fmt.Sprintf("chaos CR %s delete failed", it.Name)
139 }
140
141 type DeadlineExceed struct {
142 }
143
144 func (it DeadlineExceed) Type() string {
145 return corev1.EventTypeNormal
146 }
147
148 func (it DeadlineExceed) Reason() string {
149 return v1alpha1.NodeDeadlineExceed
150 }
151
152 func (it DeadlineExceed) Message() string {
153 return "deadline exceed"
154 }
155
156 type ParentNodeDeadlineExceed struct {
157 ParentNodeName string
158 }
159
160 func (it ParentNodeDeadlineExceed) Type() string {
161 return corev1.EventTypeNormal
162 }
163
164 func (it ParentNodeDeadlineExceed) Reason() string {
165 return v1alpha1.ParentNodeDeadlineExceed
166 }
167
168 func (it ParentNodeDeadlineExceed) Message() string {
169 return fmt.Sprintf("deadline exceed bscause parent node %s deadline exceed", it.ParentNodeName)
170 }
171
172 type WorkflowAccomplished struct {
173 }
174
175 func (it WorkflowAccomplished) Type() string {
176 return corev1.EventTypeNormal
177 }
178
179 func (it WorkflowAccomplished) Reason() string {
180 return v1alpha1.WorkflowAccomplished
181 }
182
183 func (it WorkflowAccomplished) Message() string {
184 return "workflow accomplished"
185 }
186
187 type NodeAccomplished struct {
188 }
189
190 func (it NodeAccomplished) Type() string {
191 return corev1.EventTypeNormal
192 }
193
194 func (it NodeAccomplished) Reason() string {
195 return v1alpha1.NodeAccomplished
196 }
197
198 func (it NodeAccomplished) Message() string {
199 return "node accomplished"
200 }
201
202 type TaskPodSpawned struct {
203 PodName string
204 }
205
206 func (it TaskPodSpawned) Type() string {
207 return corev1.EventTypeNormal
208 }
209
210 func (it TaskPodSpawned) Reason() string {
211 return v1alpha1.TaskPodSpawned
212 }
213
214 func (it TaskPodSpawned) Message() string {
215 return fmt.Sprintf("pod %s spawned for task", it.PodName)
216 }
217
218 type TaskPodSpawnFailed struct {
219 }
220
221 func (it TaskPodSpawnFailed) Type() string {
222 return corev1.EventTypeWarning
223 }
224
225 func (it TaskPodSpawnFailed) Reason() string {
226 return v1alpha1.TaskPodSpawnFailed
227 }
228
229 func (it TaskPodSpawnFailed) Message() string {
230 return "failed to create pod for task"
231 }
232
233 type TaskPodPodCompleted struct {
234 PodName string
235 }
236
237 func (it TaskPodPodCompleted) Type() string {
238 return corev1.EventTypeNormal
239 }
240
241 func (it TaskPodPodCompleted) Reason() string {
242 return v1alpha1.TaskPodPodCompleted
243 }
244
245 func (it TaskPodPodCompleted) Message() string {
246 return fmt.Sprintf("pod %s for task node completed", it.PodName)
247 }
248
249 type ConditionalBranchesSelected struct {
250 SelectedBranches []string
251 }
252
253 func (it ConditionalBranchesSelected) Type() string {
254 return corev1.EventTypeNormal
255 }
256
257 func (it ConditionalBranchesSelected) Reason() string {
258 return v1alpha1.ConditionalBranchesSelected
259 }
260
261 func (it ConditionalBranchesSelected) Message() string {
262 return fmt.Sprintf("selected branches: %s", it.SelectedBranches)
263 }
264
265 type RerunBySpecChanged struct {
266 CleanedChildrenNode []string
267 }
268
269 func (it RerunBySpecChanged) Type() string {
270 return corev1.EventTypeNormal
271 }
272
273 func (it RerunBySpecChanged) Reason() string {
274 return v1alpha1.RerunBySpecChanged
275 }
276
277 func (it RerunBySpecChanged) Message() string {
278 return fmt.Sprintf("rerun by spec changed, remove children nodes: %s", it.CleanedChildrenNode)
279 }
280
281 type StatusCheckCreated struct {
282 Name string
283 }
284
285 func (it StatusCheckCreated) Type() string {
286 return corev1.EventTypeNormal
287 }
288
289 func (it StatusCheckCreated) Reason() string {
290 return v1alpha1.StatusCheckCreated
291 }
292
293 func (it StatusCheckCreated) Message() string {
294 return fmt.Sprintf("status check %s created", it.Name)
295 }
296
297 type StatusCheckCreatedFailed struct {
298 Name string
299 }
300
301 func (it StatusCheckCreatedFailed) Type() string {
302 return corev1.EventTypeWarning
303 }
304
305 func (it StatusCheckCreatedFailed) Reason() string {
306 return v1alpha1.StatusCheckCreatedFailed
307 }
308
309 func (it StatusCheckCreatedFailed) Message() string {
310 return fmt.Sprintf("status check %s create failed", it.Name)
311 }
312
313 type StatusCheckDeleted struct {
314 Name string
315 }
316
317 func (it StatusCheckDeleted) Type() string {
318 return corev1.EventTypeNormal
319 }
320
321 func (it StatusCheckDeleted) Reason() string {
322 return v1alpha1.StatusCheckDeleted
323 }
324
325 func (it StatusCheckDeleted) Message() string {
326 return fmt.Sprintf("status check %s deleted", it.Name)
327 }
328
329 type StatusCheckDeletedFailed struct {
330 Name string
331 }
332
333 func (it StatusCheckDeletedFailed) Type() string {
334 return corev1.EventTypeWarning
335 }
336
337 func (it StatusCheckDeletedFailed) Reason() string {
338 return v1alpha1.StatusCheckDeletedFailed
339 }
340
341 func (it StatusCheckDeletedFailed) Message() string {
342 return fmt.Sprintf("status check %s delete failed", it.Name)
343 }
344
345 type ParentNodeAborted struct {
346 ParentNodeName string
347 }
348
349 func (it ParentNodeAborted) Type() string {
350 return corev1.EventTypeNormal
351 }
352
353 func (it ParentNodeAborted) Reason() string {
354 return v1alpha1.ParentNodeAborted
355 }
356
357 func (it ParentNodeAborted) Message() string {
358 return fmt.Sprintf("abort the node because parent node %s aborted", it.ParentNodeName)
359 }
360
361 type WorkflowAborted struct {
362 WorkflowName string
363 }
364
365 func (it WorkflowAborted) Type() string {
366 return corev1.EventTypeNormal
367 }
368
369 func (it WorkflowAborted) Reason() string {
370 return v1alpha1.WorkflowAborted
371 }
372
373 func (it WorkflowAborted) Message() string {
374 return fmt.Sprintf("abort the node because workflow %s aborted", it.WorkflowName)
375 }
376
377 func init() {
378 register(
379 InvalidEntry{},
380 EntryCreated{},
381 NodesCreated{},
382 ChaosCustomResourceCreated{},
383 ChaosCustomResourceCreateFailed{},
384 ChaosCustomResourceDeleted{},
385 ChaosCustomResourceDeleteFailed{},
386 DeadlineExceed{},
387 ParentNodeDeadlineExceed{},
388 WorkflowAccomplished{},
389 NodeAccomplished{},
390 TaskPodSpawned{},
391 TaskPodSpawnFailed{},
392 TaskPodPodCompleted{},
393 ConditionalBranchesSelected{},
394 RerunBySpecChanged{},
395 StatusCheckCreated{},
396 StatusCheckCreatedFailed{},
397 StatusCheckDeleted{},
398 StatusCheckDeletedFailed{},
399 ParentNodeAborted{},
400 )
401 }
402