@@ -322,6 +322,75 @@ func parseBuildConfigKey(key string) (string, string, error) {
322
322
return parts [0 ], parts [1 ], nil
323
323
}
324
324
325
+ func getState (cs v1.ContainerState ) string {
326
+ if cs .Waiting != nil {
327
+ return "WAITING(" + cs .Waiting .Reason + ")"
328
+ }
329
+ if cs .Running != nil {
330
+ return "RUNNING()"
331
+ }
332
+ if cs .Terminated != nil {
333
+ return "TERMINATED(" + cs .Terminated .Reason + ")"
334
+ }
335
+ return ""
336
+ }
337
+
338
+ func getStatus (pod * v1.Pod ) string {
339
+ str := "[" + string (pod .Status .Phase ) + "]" + " init: ["
340
+ for _ , c := range pod .Status .InitContainerStatuses {
341
+ str += getState (c .State ) + ", "
342
+ }
343
+ str += "], cont: ["
344
+ for _ , c := range pod .Status .ContainerStatuses {
345
+ str += getState (c .State ) + ", "
346
+ }
347
+ str += "]"
348
+ return str
349
+ }
350
+
351
+ func printPod (o interface {}) string {
352
+ pod := o .(* v1.Pod )
353
+ if pod != nil {
354
+ return "POD " + pod .Name + getStatus (pod ) + "\n "
355
+ }
356
+ return "POD nil"
357
+ }
358
+
359
+ func printBuild (o interface {}) string {
360
+ build := o .(* buildapi.Build )
361
+ if build != nil {
362
+ return "BUILD " + build .Name + "[" + string (build .Status .Phase ) + "] [" + string (build .Status .Reason ) + "]" + "\n "
363
+ }
364
+ return "BUILD nil"
365
+ }
366
+
367
+ func printUpdate (update * buildUpdate ) string {
368
+ if update != nil && update .isEmpty () {
369
+ return "UPDATE nil"
370
+ }
371
+ return "UPDATE " + update .String ()
372
+ }
373
+
374
+ var i int
375
+
376
+ func printPre (pod * v1.Pod , build * buildapi.Build ) {
377
+ glog .Infof ("### PRE %d %v" , i , printPod (pod ))
378
+ glog .Infof ("### PRE %d %v" , i , printBuild (build ))
379
+ }
380
+ func printPost (pod * v1.Pod , build * buildapi.Build , update * buildUpdate , err , updateErr error ) {
381
+ glog .Infof ("### POST %d %v" , i , printPod (pod ))
382
+ glog .Infof ("### POST %d %v" , i , printUpdate (update ))
383
+ glog .Infof ("### POST %d %v" , i , printBuild (build ))
384
+ if err != nil {
385
+ glog .Infof ("### POST %d %v" , i , err )
386
+ }
387
+ if updateErr != nil {
388
+ glog .Infof ("### POST %d %v" , i , updateErr )
389
+ }
390
+ glog .Infof ("###" )
391
+ i ++
392
+ }
393
+
325
394
// handleBuild retrieves the build's corresponding pod and calls the appropriate
326
395
// handle function based on the build's current state. Each handler returns a buildUpdate
327
396
// object that includes any updates that need to be made on the build.
@@ -344,6 +413,7 @@ func (bc *BuildController) handleBuild(build *buildapi.Build) error {
344
413
345
414
pod , podErr := bc .podStore .Pods (build .Namespace ).Get (buildapi .GetBuildPodName (build ))
346
415
416
+ printPre (pod , build )
347
417
// Technically the only error that is returned from retrieving the pod is the
348
418
// NotFound error so this check should not be needed, but leaving here in case
349
419
// that changes in the future.
@@ -365,6 +435,7 @@ func (bc *BuildController) handleBuild(build *buildapi.Build) error {
365
435
case buildutil .IsBuildComplete (build ):
366
436
update , err = bc .handleCompletedBuild (build , pod )
367
437
}
438
+ printPost (pod , build , update , err , updateErr )
368
439
if update != nil && ! update .isEmpty () {
369
440
updateErr = bc .updateBuild (build , update , pod )
370
441
}
@@ -1354,6 +1425,7 @@ func buildDesc(build *buildapi.Build) string {
1354
1425
// transitionToPhase returns a buildUpdate object to transition a build to a new
1355
1426
// phase with the given reason and message
1356
1427
func transitionToPhase (phase buildapi.BuildPhase , reason buildapi.StatusReason , message string ) * buildUpdate {
1428
+ glog .Infof ("### transitioning to %v %v" , phase , reason )
1357
1429
update := & buildUpdate {}
1358
1430
update .setPhase (phase )
1359
1431
update .setReason (reason )
0 commit comments