Bug 11185

Summary: selftest/devtool: failing when parsing “mraa” recipe
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Juan Ramos <juan.fernandox.ramos.frayle>
Component: devtools / tool chainAssignee: Paul Eggleton <bluelightning>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: brian.avery, jose.perez.carranza, meta.mr.watcher, meta.watcher, ross.burton, sgw
Version: 2.3   
Target Milestone: 2.3 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
parsing mraa recipe log
none
Devtool manual test
none
Devtool tests fail log
none
Complete debug log none

Description Juan Ramos 2017-03-17 21:21:30 UTC
Created attachment 3655 [details]
parsing mraa recipe log

STATUS: IDLE
BUILD: 2.3 M3: rc1-6e20b31d5d17133e0fca086e12a0ad06ab5c4cc8
ENVIRONMENT: ubuntu 16.04 x86_64

======================================================================
FAIL [54.210s]: test_devtool_add_fetch_git (oeqa.selftest.devtool.DevtoolTests)
----------------------------------------------------------------------
Command 'devtool add mraa /tmp/devtoolqafelavfgj/mraa -a -f gitsm://git.yoctoproject.org/mraa' returned non-zero exit status 1:
NOTE: Creating workspace layer in /home/ab/autobuilder/yocto-worker/nightly-oe-selftest-ubuntu1604/build/build/workspace
NOTE: Enabling workspace layer in bblayers.conf
WARNING: -f/--fetch option is deprecated - you can now simply specify the URL to fetch as a positional argument instead
NOTE: Fetching gitsm://git.yoctoproject.org/mraa...
ERROR: 
ERROR: Parsing newly created recipe failed, moving recipe to /home/ab/autobuilder/yocto-worker/nightly-oe-selftest-ubuntu1604/build/build/workspace/recipes/mraa/mraa_git.bb.parsefailed for reference. If this looks to be caused by the recipe itself, please report this error.
  
Log Attached.
Comment 1 Paul Eggleton 2017-03-21 01:18:39 UTC
So unfortunately I can't get much from this - the actual parse failure wasn't displayed (which itself is a bug), and I can't reproduce the issue testing locally.

Are you able to reproduce this manually on the autobuilder, or otherwise provide me with any other information that would help me reproduce it?
Comment 2 Juan Ramos 2017-03-21 20:30:27 UTC
Created attachment 3658 [details]
Devtool manual test
Comment 3 Juan Ramos 2017-03-21 20:30:58 UTC
(In reply to comment #2)
> Created attachment 3658 [details]
> Devtool manual test

Hi, I tried manually in my pc and failed, this happens only in Ubuntu 16.04, all other OS passed the test.

Log attached.
Comment 4 Saul Wold 2017-03-22 17:42:13 UTC
I am not sure this is correct, your command is not correct and the output shows that the command did not run

Can you please confirm 14.04 vs 16.04, I tried 16.04 and it worked, I could not get it to fail on the direct run of devtool, only through oe-selftest.  I have been running it thought the crops/poky container
Comment 5 Juan Ramos 2017-03-22 18:30:39 UTC
Created attachment 3660 [details]
Devtool tests fail log
Comment 6 Juan Ramos 2017-03-22 18:42:09 UTC
(In reply to comment #4)
> I am not sure this is correct, your command is not correct and the output
> shows that the command did not run
> 
> Can you please confirm 14.04 vs 16.04, I tried 16.04 and it worked, I could
> not get it to fail on the direct run of devtool, only through oe-selftest. 
> I have been running it thought the crops/poky container

Hi, I attached a new log with the correct command, this executed in Ubuntu 16.04 in commit 6e20b31d5d17133e0fca086e12a0ad06ab5c4cc8, retested with commit 7e0985bab68547f946163828a16beab7542fca2e the test pass.
Comment 7 Paul Eggleton 2017-03-22 23:09:33 UTC
Wait a second - from your log:

/usr/local/bin/git-proxy: 18: exec: socat: not found

Is socat installed on the machine you're testing? Also, this doesn't look like the same error as the one in comment #1 on this bug.

I guess this could be related to the new HOSTTOOLS handling - socat is listed in HOSTTOOLS_NONFATAL, but maybe the HOSTTOOLS processing code isn't being run within devtool for some reason.
Comment 8 Paul Eggleton 2017-03-22 23:11:12 UTC
FWIW so far I've not been able to reproduce this issue in a container running Ubuntu 16.04. Saul reports that he can intermittently though.
Comment 9 brian avery 2017-03-22 23:38:28 UTC
exact command sequence to reproduce this?
Comment 10 Paul Eggleton 2017-03-23 02:36:51 UTC
When I tried it I simply did:

1) . ./oe-init-build-env

2) Edit local.conf, change MACHINE to "qemux86-64" - however perhaps I should have used "genericx86-64" since that's what Juan used)

3) bitbake core-image-minimal

4) oe-selftest -r devtool.DevtoolTests.test_devtool_add_fetch_git
Comment 11 Paul Eggleton 2017-03-23 09:05:14 UTC
Switched to genericx86-64 - still no failures.
Comment 12 Saul Wold 2017-03-23 16:16:17 UTC
Ok, I have been able to reproduce this with the crops/poky-ubuntu-16.04 container with a simple script that I have in my mounted poky clone.

#!/bin/sh

cd poky
rm -rf build

. ./oe-init-build-env $HOME/build

#oe-selftest -r devtool.DevtoolTests.test_devtool_add_fetch_git

devtool add mraa /tmp/devtoolqaip85n8ad/mraa -a -f  gitsm://git.yoctoproject.org/mraa

I see the clone of mraa occur and then get the following error:
ERROR:
ERROR: Parsing newly created recipe failed, moving recipe to /home/pokyuser/poky/build/workspace/recipes/mraa/mraa_git.bb.parsefailed for reference. If this looks to be caused by the recipe itself, please report this error.

If I move the parsefailed recipe to mraa_git.bb and try to bitbake -n mraa_git, it works correctly.

I have started to look at devtool's standard.py and where it calls tinfoil's parse_recipe_file() in order to see if there is more debugging I can do in tinfoil.
Comment 13 brian avery 2017-03-23 17:22:08 UTC
My setup:
Host= ubuntu:14.04 (hopefully irrelevant)
Container image:  crops/poky:ubuntu-14.04
"Id": "sha256:d499b0209cb31f77cdad1fb7e020a14b0e767cf50ea523a2cddd73c83f568d8c", from docker inspect crops/poky:ubuntu-14.04

1) . ./oe-init-build-env

2) Edit local.conf, change MACHINE to "qemux86-64" 

3) bitbake core-image-minimal

----
I then took the devtool add in the test apart and tried some variations
These worked:
devtool add   git://git.yoctoproject.org/mraa
devtool add mraa  gitsm://git.yoctoproject.org/mraa
devtool add mraa  /tmp/cowXX1234 -f gitsm://git.yoctoproject.org/mraa

This failed (this is what the test actually does...):
add mraa  /tmp/cowXX123x4 -a  -f gitsm://git.yoctoproject.org/mraa

----
I did a devtool reset mraa and  a manual rm -rf of the mraa-source between each variation .

So, it looks like it is having difficulty with the -a, at least on my setup.
Comment 14 brian avery 2017-03-23 17:31:34 UTC
Same error if I don't have a build/tmp and just do
 . poky/oe-init-buildenv 
followed by
devtool add mraa  /tmp/cowXX123x4 -a  -f gitsm://git.yoctoproject.org/mraa
in a fresh container.
Comment 15 Saul Wold 2017-03-23 18:50:53 UTC
Oh, I missed this hint from the previous errors, but noticed it when I started adding debugs.

There is an empty ERROR: line, turns out this is from the try/except section

rd = tinfoil.parse_recipe_file(recipefile, False)                                               logger.debug("parse returned: %s" %rd)
        except Exception as e:
            logger.error(str(e))

We are getting an empty Exception e from the parse_reciple_file(), this is helpful.

Not sure what I did, but I managed to get bitbake to become more verbose, I was adding logger debugs and then bitbake became more verbose, but I did get this on one of the failures:

                                                                      WARNING:BitBake.Main:Timeout while attempting to communicate with bitbake server          CRITICAL:BitBake.Main:Gave up; Too many tries: timeout while attempting to communicate with bitbake server
Comment 16 Saul Wold 2017-03-23 21:02:46 UTC
Created attachment 3667 [details]
Complete debug log

This is a complete debug log that I captured, like I said, not exactly sure how the addition of this code caused it to enable debugging:  I did also add the -d flag to devtool, but initially it only added debugging for devtool, it was not until I added this change that debugging enabled for all of bitbake!


diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py          index c3c1450..61970c9 100644                                                             --- a/bitbake/lib/bb/server/process.py                                                    +++ b/bitbake/lib/bb/server/process.py                                                    @@ -45,7 +45,11 @@ class ServerCommunicator():                                                                                                                                           def runCommand(self, command):                                                                # @todo try/except                                                               -        self.connection.send(command)                                                    +        logging.debug("Process")                                                         +        try:                                                                             +            self.connection.send(command)
+        except Exception as err:
+            logging.warn("Process: %s" % err)
 
         if not self.server.is_alive():
             raise SystemExit
Comment 17 Paul Eggleton 2017-03-23 23:01:03 UTC
I've finally managed to reproduce this in a container on my own machine rather than a powerful server. Will try to debug.
Comment 18 Paul Eggleton 2017-03-24 04:25:54 UTC
So I now have a much clearer picture of what's going on. There are several  things at work here:

1) We're calling git ls-remote, but the code we use to do it ends up in a recursive loop, so it is called 30 times before it stops. I believe this is because of the code in runfetchcmd() which tries to prevent recursion - it does so by trying to simply get the value of PV, which is set to "${SRCPV}", which triggers runfetchcmd("git ls-remote ...") again. Surely there must be a more efficient way of doing this, but I don't yet have a fix.

2) Because we're doing ls-remote 30 times, it takes a while for the server to return from the parseRecipeFile RPC command, and the command times out. It actually times out three times with a warning before returning successfully on Fedora, but we don't see those warnings (see below). For whatever reason on Ubuntu it must be taking fractionally longer to do the git ls-remote operations and thus there it usually times out a fourth time and gives up.

3) bitbake logging on the *client* side isn't being handled within devtool, thus we don't see the timeout messages. Instead if it fails what we get is a BBHandledException with no text, since when the final timeout occurs we call bb.fatal() which logs the message and then raises BBHandledException(), and we don't see the log message. I have a patch to fix this, which will fix all tinfoil-using scripts and allow us to tidy up the code a bit for some of those scripts as well.
Comment 19 Paul Eggleton 2017-03-27 00:18:17 UTC
I've sent patches to the bitbake-devel list for both the recursion and the logging issues.
Comment 20 Ross Burton 2017-04-13 16:19:02 UTC
Those patches are merged in bitbake 824e73e0f3eaa96b4d84da7e31f9a17ce5c5d7ee.

Paul, does this mean the bug can be closed?
Comment 22 Juan Ramos 2017-04-18 18:36:49 UTC
Verified, in ccommit 415b72ffcbd26e5f3664370d8b2a9b8105fb6342

test_devtool_add_fetch_git (oeqa.selftest.devtool.DevtoolTests) ... OK (50.127s)