Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1809862

Summary: builds do not report lastlogsnippet from init containers
Product: OpenShift Container Platform Reporter: Ben Parees <bparees>
Component: BuildAssignee: Gabe Montero <gmontero>
Status: CLOSED ERRATA QA Contact: wewang <wewang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.4CC: aos-bugs, gmontero, wewang, wzheng
Target Milestone: ---   
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: build error handling was only attaching the last few lines of error logs to the build if the failure occurred in a build pod continer, and not if the failure occurred a build pod init container Consequence: build errors occurring in the init containers, like extraction of source from git, were harder to diagnose without some of the error logs attached to the build object Fix: the build controller was updated to attach error logs when failures occur in the init containers Result: build failures like malformed git URLs are much easier for users to diagnose now.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-13 17:17:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ben Parees 2020-03-04 03:37:52 UTC
Description of problem:
if the build fails during an init container we do not grab the last failure log message from the init container and put it in the build's logsnippet.  We only do it for the "main" container:

https://github.com/openshift/openshift-controller-manager/blob/5306fa200517c3026064576c45160d9f0ba0eadd/pkg/build/controller/build/build_controller.go#L2358-L2375


We should also be doing this if we fail in an init container.

How reproducible:
always


Steps to Reproduce:
1. run a build that fails in an init container such as by providing an invalid git url
2. oc describe the build


Actual results:
logSnippet is empty

Expected results:
logSnippet contains the last log line of the init container that failed from pod.status.initContainerStatuses[n].state.terminated.message

Comment 3 wewang 2020-03-23 09:20:59 UTC
Verified in version:
4.5.0-0.nightly-2020-03-22-175100

[wewang@wangwen Downloads]$ oc get builds
NAME           TYPE     FROM   STATUS                       STARTED          DURATION
ruby-hello-1   Source   Git    Failed (FetchSourceFailed)   11 seconds ago   10s

Comment 4 Ben Parees 2020-03-23 20:37:57 UTC
I can't tell from the verification report, were you able to confirm that the LogSnippet value was populated in the build yaml and that it showed some sort of error message from the git clone operation?

Comment 5 wewang 2020-03-24 07:13:14 UTC
Oh, yes I should paste build yaml, here is content of build:
 $oc get build -n wewang -o yaml
    logSnippet: |-
      Cloning "https://github.com/openshift/ruby-hello-world1" ...
      error: failed to fetch requested repository "https://github.com/openshift/ruby-hello-world1" with provided credentials
    message: Failed to fetch the input source.

Comment 6 Ben Parees 2020-03-24 15:04:37 UTC
Perfect, thanks!

Comment 8 errata-xmlrpc 2020-07-13 17:17:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:2409