@@ -245,50 +245,63 @@ func NewFrameworkController() *FrameworkController {
245
245
246
246
fInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
247
247
AddFunc : func (obj interface {}) {
248
- c .enqueueFrameworkObj (obj , "Framework Added" )
248
+ c .enqueueFrameworkObj (obj , "Framework Added" , nil )
249
249
},
250
250
UpdateFunc : func (oldObj , newObj interface {}) {
251
251
// FrameworkController only cares about Framework.Spec update
252
252
oldF := oldObj .(* ci.Framework )
253
253
newF := newObj .(* ci.Framework )
254
254
if ! reflect .DeepEqual (oldF .Spec , newF .Spec ) {
255
- c .enqueueFrameworkObj (newObj , "Framework.Spec Updated" )
255
+ c .enqueueFrameworkObj (newObj , "Framework.Spec Updated" , nil )
256
256
}
257
257
},
258
258
DeleteFunc : func (obj interface {}) {
259
- c .enqueueFrameworkObj (obj , "Framework Deleted" )
259
+ c .enqueueFrameworkObj (obj , "Framework Deleted" , func () string {
260
+ if * c .cConfig .LogObjectSnapshot .Framework .OnFrameworkDeletion {
261
+ return ": " + ci .GetFrameworkSnapshotLogTail (obj )
262
+ } else {
263
+ return ""
264
+ }
265
+ })
260
266
},
261
267
})
262
268
263
269
cmInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
264
270
AddFunc : func (obj interface {}) {
265
- c .enqueueFrameworkConfigMapObj (obj , "Framework ConfigMap Added" )
271
+ c .enqueueFrameworkConfigMapObj (obj , "Framework ConfigMap Added" , nil )
266
272
},
267
273
UpdateFunc : func (oldObj , newObj interface {}) {
268
- c .enqueueFrameworkConfigMapObj (newObj , "Framework ConfigMap Updated" )
274
+ c .enqueueFrameworkConfigMapObj (newObj , "Framework ConfigMap Updated" , nil )
269
275
},
270
276
DeleteFunc : func (obj interface {}) {
271
- c .enqueueFrameworkConfigMapObj (obj , "Framework ConfigMap Deleted" )
277
+ c .enqueueFrameworkConfigMapObj (obj , "Framework ConfigMap Deleted" , nil )
272
278
},
273
279
})
274
280
275
281
podInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
276
282
AddFunc : func (obj interface {}) {
277
- c .enqueueFrameworkPodObj (obj , "Framework Pod Added" )
283
+ c .enqueueFrameworkPodObj (obj , "Framework Pod Added" , nil )
278
284
},
279
285
UpdateFunc : func (oldObj , newObj interface {}) {
280
- c .enqueueFrameworkPodObj (newObj , "Framework Pod Updated" )
286
+ c .enqueueFrameworkPodObj (newObj , "Framework Pod Updated" , nil )
281
287
},
282
288
DeleteFunc : func (obj interface {}) {
283
- c .enqueueFrameworkPodObj (obj , "Framework Pod Deleted" )
289
+ c .enqueueFrameworkPodObj (obj , "Framework Pod Deleted" , func () string {
290
+ if * c .cConfig .LogObjectSnapshot .Pod .OnPodDeletion {
291
+ return ": " + ci .GetPodSnapshotLogTail (obj )
292
+ } else {
293
+ return ""
294
+ }
295
+ })
284
296
},
285
297
})
286
298
287
299
return c
288
300
}
289
301
290
302
// obj could be *ci.Framework or cache.DeletedFinalStateUnknown.
291
- func (c * FrameworkController ) enqueueFrameworkObj (obj interface {}, msg string ) {
303
+ func (c * FrameworkController ) enqueueFrameworkObj (
304
+ obj interface {}, logSfx string , logTailFunc func () string ) {
292
305
key , err := internal .GetKey (obj )
293
306
if err != nil {
294
307
klog .Errorf ("Failed to get key for obj %#v, skip to enqueue: %v" , obj , err )
@@ -302,23 +315,29 @@ func (c *FrameworkController) enqueueFrameworkObj(obj interface{}, msg string) {
302
315
}
303
316
304
317
c .fQueue .Add (key )
305
- klog .Infof ("[%v]: enqueueFrameworkObj: %v" , key , msg )
318
+
319
+ if logTailFunc != nil {
320
+ logSfx += logTailFunc ()
321
+ }
322
+ klog .Infof ("[%v]: enqueueFrameworkObj: %v" , key , logSfx )
306
323
}
307
324
308
325
// obj could be *core.ConfigMap or cache.DeletedFinalStateUnknown.
309
- func (c * FrameworkController ) enqueueFrameworkConfigMapObj (obj interface {}, msg string ) {
326
+ func (c * FrameworkController ) enqueueFrameworkConfigMapObj (
327
+ obj interface {}, logSfx string , logTailFunc func () string ) {
310
328
if cm := internal .ToConfigMap (obj ); cm != nil {
311
329
if f := c .getConfigMapOwner (cm ); f != nil {
312
- c .enqueueFrameworkObj (f , msg + ": " + cm .Name )
330
+ c .enqueueFrameworkObj (f , logSfx + ": " + cm .Name , logTailFunc )
313
331
}
314
332
}
315
333
}
316
334
317
335
// obj could be *core.Pod or cache.DeletedFinalStateUnknown.
318
- func (c * FrameworkController ) enqueueFrameworkPodObj (obj interface {}, msg string ) {
336
+ func (c * FrameworkController ) enqueueFrameworkPodObj (
337
+ obj interface {}, logSfx string , logTailFunc func () string ) {
319
338
if pod := internal .ToPod (obj ); pod != nil {
320
339
if cm := c .getPodOwner (pod ); cm != nil {
321
- c .enqueueFrameworkConfigMapObj (cm , msg + ": " + pod .Name )
340
+ c .enqueueFrameworkConfigMapObj (cm , logSfx + ": " + pod .Name , logTailFunc )
322
341
}
323
342
}
324
343
}
@@ -393,6 +412,8 @@ func (c *FrameworkController) Run(stopCh <-chan struct{}) {
393
412
c .cConfig .CRDEstablishedCheckIntervalSec ,
394
413
c .cConfig .CRDEstablishedCheckTimeoutSec )
395
414
415
+ // The recovery order is not important, since all Frameworks will be enqueued
416
+ // to sync in any case.
396
417
go c .fInformer .Run (stopCh )
397
418
go c .cmInformer .Run (stopCh )
398
419
go c .podInformer .Run (stopCh )
@@ -669,9 +690,9 @@ func (c *FrameworkController) enqueueTaskRetryDelayTimeoutCheck(
669
690
return true
670
691
}
671
692
672
- func (c * FrameworkController ) enqueueFramework (f * ci.Framework , msg string ) {
693
+ func (c * FrameworkController ) enqueueFramework (f * ci.Framework , logSfx string ) {
673
694
c .fQueue .Add (f .Key ())
674
- klog .Infof ("[%v]: enqueueFramework: %v" , f .Key (), msg )
695
+ klog .Infof ("[%v]: enqueueFramework: %v" , f .Key (), logSfx )
675
696
}
676
697
677
698
func (c * FrameworkController ) syncFrameworkStatus (f * ci.Framework ) error {
@@ -847,6 +868,14 @@ func (c *FrameworkController) syncFrameworkState(f *ci.Framework) (err error) {
847
868
848
869
// retryFramework
849
870
klog .Infof (logPfx + "Retry Framework" )
871
+
872
+ // The completed FrameworkAttempt has been persisted, so it is safe to also
873
+ // expose it as one history snapshot.
874
+ if * c .cConfig .LogObjectSnapshot .Framework .OnFrameworkRetry {
875
+ klog .Infof (logPfx +
876
+ "Framework will be retried: %v" , ci .GetFrameworkSnapshotLogTail (f ))
877
+ }
878
+
850
879
f .Status .RetryPolicyStatus .TotalRetriedCount ++
851
880
if retryDecision .IsAccountable {
852
881
f .Status .RetryPolicyStatus .AccountableRetriedCount ++
@@ -1232,9 +1261,9 @@ func (c *FrameworkController) syncTaskState(
1232
1261
terminated := containerStatus .State .Terminated
1233
1262
if terminated != nil && terminated .ExitCode != 0 {
1234
1263
allContainerDiags = append (allContainerDiags , fmt .Sprintf (
1235
- "[Container %v, ExitCode: %v, Reason: %v, Message: %v]" ,
1236
- containerStatus .Name , terminated .ExitCode , terminated .Reason ,
1237
- terminated .Message ))
1264
+ "[Container: %v, ExitCode: %v, Signal : %v, Reason: %v, Message: %v]" ,
1265
+ containerStatus .Name , terminated .ExitCode , terminated .Signal ,
1266
+ terminated .Reason , common . ToJson ( terminated . Message ) ))
1238
1267
1239
1268
if lastContainerExitCode == nil ||
1240
1269
lastContainerCompletionTime .Before (terminated .FinishedAt .Time ) {
@@ -1323,6 +1352,14 @@ func (c *FrameworkController) syncTaskState(
1323
1352
1324
1353
// retryTask
1325
1354
klog .Infof (logPfx + "Retry Task" )
1355
+
1356
+ // The completed TaskAttempt has been persisted, so it is safe to also
1357
+ // expose it as one history snapshot.
1358
+ if * c .cConfig .LogObjectSnapshot .Framework .OnTaskRetry {
1359
+ klog .Infof (logPfx +
1360
+ "Task will be retried: %v" , ci .GetFrameworkSnapshotLogTail (f ))
1361
+ }
1362
+
1326
1363
taskStatus .RetryPolicyStatus .TotalRetriedCount ++
1327
1364
if retryDecision .IsAccountable {
1328
1365
taskStatus .RetryPolicyStatus .AccountableRetriedCount ++
0 commit comments