Bug 8373 - Toaster in analysis mode downloads the wrong cooker logs
Summary: Toaster in analysis mode downloads the wrong cooker logs
Status: VERIFIED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: 1.8
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.1 M1
Assignee: Elliot Smith
QA Contact: Alexandru Roman
URL:
Whiteboard:
Depends on: 8411
Blocks:
  Show dependency tree
 
Reported: 2015-09-22 12:56 UTC by Belen Barros Pena
Modified: 2016-02-15 14:56 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Design - Displaying failed build requests (858.34 KB, application/pdf)
2015-10-05 13:22 UTC, Belen Barros Pena
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Belen Barros Pena 2015-09-22 12:56:58 UTC
Found in master:7b86c771c80d0759c2ca0e57c46c4c966f89c49e

Steps to reproduce:

* Source the build environment script and start Toaster in analysis mode with 'source toaster start'

* Run a couple of builds from the command line. For example:

bitbake core-image-minimal
bitbake -c clean core-image-minimal

* Check that the 2 builds generate 2 separate log files inside build/tmp/log/cooker

* When both builds finish, go to Toaster, select the first build and click the 'Download build log' button. Then select the second build and click the 'Download build log' button.

Compare the logs: they are the same one. Toaster seems to download the same log file for both builds, instead of the correct build log.
Comment 1 Elliot Smith 2015-09-24 15:35:26 UTC
I tested this in analysis mode.

The cooker_log_path field in the db orm_build table for each build isn't being updated correctly, so all the builds point to the same log file.

I confirmed this by looking at the SQLite db.

In managed/build mode, the log file paths are correct.
Comment 2 Elliot Smith 2015-09-28 13:04:55 UTC
I made some changes to pass the log file location as part of the BuildStarted event. I used BB_CONSOLELOG, which should contain the build's log file path.

Using this approach, the build name and the output log file path correspond, e.g.

build name|cooker_log_path
20150928123720|/home/ell/toaster-run/build/tmp/log/cooker/qemux86/20150928123720.log
20150928123726|/home/ell/toaster-run/build/tmp/log/cooker/qemux86/20150928123726.log

But the actual logs generated have different paths, e.g. for the above two builds, the paths were:

/home/ell/toaster-run/build/tmp/log/cooker/qemux86/20150928123716.log
/home/ell/toaster-run/build/tmp/log/cooker/qemux86/20150928123720.log

Note that the path of the log for the second build (/home/ell/toaster-run/build/tmp/log/cooker/qemux86/20150928123720.log) corresponds with the expected path for the first build (20150928123720). This suggests that when the BuildStarted event occurs, the timestamp for the build start has been reset and is no longer correct: the actual log file path has been set before BuildStarted occurs and doesn't seem to be readily accessible when that event is constructed.

After speaking to Paul Eggleton, he suggested this is a bug, and that we could work around it by looking at the log file directory when the build starts, and find the latest-dated log file, then associating that with the build.
Comment 3 Elliot Smith 2015-09-29 09:12:25 UTC
Submitted to toaster mailing list for review.
Comment 4 Elliot Smith 2015-10-02 07:17:11 UTC
Brian has identified an additional situation not covered by this bug during review, so moving back to implementation.
Comment 5 brian avery 2015-10-02 14:00:55 UTC
to reproduce the additional situation:
new proj - master
Add meta-iv layer from the layer index
build ecryptfs-utils
bitbake dies on parsing one of the recipe files in the layer.
The "download build log" button for the failed build results in a "The
build artifact you are trying to download no longer exists."


Pretty sure this is because bb dies during parsing and b4 any events come in.
Comment 6 Belen Barros Pena 2015-10-05 13:22:39 UTC
Created attachment 2781 [details]
Design - Displaying failed build requests

The attached design document describes the build dashboard page for builds that fail at the build request state, for which we have no build log and no data.
Comment 7 Elliot Smith 2015-10-05 13:42:47 UTC
Brian: for now, I've simply hidden the "Download build log" button for builds which fail before the BuildStarted event, and for which we have no cooker_log_path.

Belen raised an issue for us to deal with builds which fail early: bug 8440.

I've resubmitted this branch with the additional patch

  elliot/toaster/wrong_log-8373

to the toaster mailing list.
Comment 8 Elliot Smith 2015-10-12 13:31:34 UTC
I'm reopening this, as it didn't make it to bitbake master and needs reworking.
Comment 9 Elliot Smith 2015-10-13 08:31:14 UTC
The proper fix for this will be provided by bug 8411, which is slated for 2.1.
Comment 10 Elliot Smith 2015-10-13 09:06:30 UTC
RP has already posted a series of patches which should enable this to be fixed properly:

http://lists.openembedded.org/pipermail/bitbake-devel/2015-October/006544.html
http://lists.openembedded.org/pipermail/bitbake-devel/2015-October/006546.html
http://lists.openembedded.org/pipermail/bitbake-devel/2015-October/006545.html

I'll keep an eye on where they get to; hopefully we can get the proper fix in before 2.1.
Comment 11 Elliot Smith 2015-10-13 10:39:00 UTC
Note that the work-around in my original patch was not accepted by RP (http://lists.openembedded.org/pipermail/bitbake-devel/2015-October/006540.html).

I agree with his conclusions, but it does mean that this bug is now effectively blocked by bug 8411.
Comment 12 Elliot Smith 2015-10-20 06:51:34 UTC
Sent an RFC to mailing list (2015-10-20):
https://lists.yoctoproject.org/pipermail/toaster/2015-October/003179.html
Comment 13 Elliot Smith 2015-10-21 13:26:19 UTC
Note that my proposed solution (on branch poky-contrib, elliot/toaster/wrong_log-8373-v2) isn't blocked by bug 8411, as it creates a parallel log file owned by Toaster.

RP was OK with how I did this, but wasn't keen on the way it duplicates writing the "Build Configuration" section rather than reusing the output from bitbake.

I've investigated and can't find an easy way to capture bitbake's output of the build configuration in our log files, as it happens before the BuildStarted event. (We use the BuildStarted event as the trigger to start writing to a new build log file.)

Here are some alternative solutions (there may be others):

1. Spend more time figuring out whether we can capture bitbake's output of the build configuration.
2. Use existing bitbake code to output the build configuration to our log.
3. Don't include the build configuration in our logs.

With (1), I'm not sure how much work is involved; after my research, (2) looks difficult and painful (it doesn't look easy to reuse the code which writes the build configuration, as it's in bbclass files); (3) can be done immediately and painlessly, but means our build logs are less useful.
Comment 14 Elliot Smith 2015-10-21 13:31:44 UTC
Also note that once bug 8411 is fixed, log paths will be broken for analysis AND build modes.
Comment 15 Elliot Smith 2015-10-21 13:41:27 UTC
One other option I missed is for bitbake to create per-build logs.
Comment 16 brian avery 2015-10-21 17:50:08 UTC
The BuildStarted event is probably not the correct event to use for starting our logs. For instance, I have routinely tried to build odd (i.e. not core-image-[minimal|sato] and had dependencies missing from the layers included.  This pops out during parsing and should be part of our logs I would think.   Would starting the logging earlier help with capturing the build configuration?  It would help with some of the unexplained build errors w/o much/any info attached.  It would also allow us to do things like have the parsing,setting up runquee, etc. be in the progress bar so that it doesn't just st at 0% for so long that the user begins to wonder if it crashed.
Comment 17 Elliot Smith 2015-10-22 09:50:17 UTC
Thanks Brian, using ParseStarted actually solved all the issues I was having and simplified things.

Submitted to toaster mailing list for review:
https://lists.yoctoproject.org/pipermail/toaster/2015-October/003196.html

See branch:
elliot/toaster/wrong_log-8373-v2
Comment 18 Elliot Smith 2015-10-28 14:11:36 UTC
I submitted another version of this patch to the toaster mailing list:
https://lists.yoctoproject.org/pipermail/toaster/2015-October/003238.html

See branch:
elliot/toaster/wrong_log-8373-v2

ParseStarted can't be used to initiate logs for cli builds, as we don't get that event for those builds. I'm not sure if this event is fired and we're missing it somehow, or if it just doesn't fire (needs some more investigation). I will open a bug to track that.
Comment 19 Elliot Smith 2015-10-28 14:21:20 UTC
I opened a separate build to investigate/fix the issue where we don't get "Build configuration" for cli builds: bug 8604.
Comment 20 Elliot Smith 2015-11-04 14:27:27 UTC
Waiting for bug 8411 to be closed.
Comment 21 Alexandru Roman 2016-02-15 14:56:10 UTC
Verified on master: 36b43b233c841b3c09fc17e04686b4b758780963