Skip to content

Commit 30383af

Browse files
author
Jan Wozniak
committed
WIP debug statements
1 parent 3ce641c commit 30383af

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

pkg/build/builder/cmd/builder.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func (c *builderConfig) clone() error {
175175
c.build.Status.Phase = buildapiv1.BuildPhaseFailed
176176
c.build.Status.Reason = buildapiv1.StatusReasonFetchSourceFailed
177177
c.build.Status.Message = builderutil.StatusMessageFetchSourceFailed
178+
fmt.Println("# builder 178")
178179
return err
179180
}
180181

@@ -187,6 +188,7 @@ func (c *builderConfig) clone() error {
187188
c.build.Status.Phase = buildapiv1.BuildPhaseFailed
188189
c.build.Status.Reason = buildapiv1.StatusReasonFetchSourceFailed
189190
c.build.Status.Message = builderutil.StatusMessageFetchSourceFailed
191+
fmt.Println("# builder 191")
190192
return err
191193
}
192194

pkg/build/controller/build/build_controller.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,75 @@ func parseBuildConfigKey(key string) (string, string, error) {
322322
return parts[0], parts[1], nil
323323
}
324324

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+
325394
// handleBuild retrieves the build's corresponding pod and calls the appropriate
326395
// handle function based on the build's current state. Each handler returns a buildUpdate
327396
// 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 {
344413

345414
pod, podErr := bc.podStore.Pods(build.Namespace).Get(buildapi.GetBuildPodName(build))
346415

416+
printPre(pod, build)
347417
// Technically the only error that is returned from retrieving the pod is the
348418
// NotFound error so this check should not be needed, but leaving here in case
349419
// that changes in the future.
@@ -365,6 +435,7 @@ func (bc *BuildController) handleBuild(build *buildapi.Build) error {
365435
case buildutil.IsBuildComplete(build):
366436
update, err = bc.handleCompletedBuild(build, pod)
367437
}
438+
printPost(pod, build, update, err, updateErr)
368439
if update != nil && !update.isEmpty() {
369440
updateErr = bc.updateBuild(build, update, pod)
370441
}
@@ -1354,6 +1425,7 @@ func buildDesc(build *buildapi.Build) string {
13541425
// transitionToPhase returns a buildUpdate object to transition a build to a new
13551426
// phase with the given reason and message
13561427
func transitionToPhase(phase buildapi.BuildPhase, reason buildapi.StatusReason, message string) *buildUpdate {
1428+
glog.Infof("### transitioning to %v %v", phase, reason)
13571429
update := &buildUpdate{}
13581430
update.setPhase(phase)
13591431
update.setReason(reason)

vendor/github.com/openshift/source-to-image/pkg/build/strategies/sti/sti.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)