<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14079</bug_id>
          
          <creation_ts>2020-10-07 19:21:04 +0000</creation_ts>
          <short_desc>Toaster fails to start a build with recent changes in when cookerdata is populated</short_desc>
          <delta_ts>2020-10-19 14:18:05 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>3.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>High</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>3.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Orling">tim.orling</reporter>
          <assigned_to name="Tim Orling">tim.orling</assigned_to>
          <cc>david.reyna</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.e.witt</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>Regression (Used to work)</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>88313</commentid>
    <comment_count>0</comment_count>
      <attachid>4735</attachid>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-07 19:21:04 +0000</bug_when>
    <thetext>Created attachment 4735
toaster_ui.log

In an effort to fix the CROPS toaster-container on current development (3.2) branch, we have uncovered a new failure mode that affects bare-metal Toaster as well.

The system is that when toaster starts a build, it cannot server.getEventHandle:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/ui/toasterui.py#n148

which is because in the following, self.event_handle has not been set yet:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/server/xmlrpcserver.py#n122

The bitbake-cookerdaemon.log shows the XMLRPC server exits almost immediately (this does not seem to be affected by changing maxuitimeout:

37145 18:20:07.173656 --- Starting bitbake server pid 37145 at 2020-10-06 18:20:07.173617 ---
37145 18:20:07.186763 Started bitbake server pid 37145
37145 18:20:07.187053 Bitbake XMLRPC server address: 0.0.0.0, server port: 37331
37145 18:20:07.187270 Entering server connection loop
XMLRPC Server triggering exit
37145 18:20:08.742198 Exiting
37145 18:20:08.742435 Original lockfile contents: [&apos;37145 0.0.0.0:37331\n&apos;]
37145 18:20:08.742707 Exiting as we could obtain the lock

In toaster_ui.log traceback captured from a run, we see that cookerdata.CookerConfiguration() seems to be the root cause. Meaning that cookerdata has not yet been populated/instantiated.


It helps to have a virtual environment setup. For instance:
0. pipenv install -r toaster-requirements.txt  
   pipenv shell

Steps to reproduce:
1. source poky/oe-init-build-env build-toaster
2. source toaster start webport=0.0.0.0:8000
3. Wait for the layers to be loaded from layer index and the &quot;Successful Start&quot; 
   message
4. Launch browser pointed to http://0.0.0.0:8000
5. Click &quot;New Project&quot; button in upper right corner
6. Give project a name (e.g. &quot;master&quot;), use Yocto Project master for &quot;Release&quot;
7. Click &quot;Create Project&quot;
   You should be in the Project view
6. On the left click &quot;Software Recipes&quot;
7. In the search box, type &quot;quilt-native&quot; and click Search
8. On the openembedded-core first hit, click the &quot;Build recipe&quot; button on the 
   right.
It will clone, then say &quot;Tasks starting&quot; but never complete.

cat ../build-toaster-2/toaster_ui.log (attached)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88314</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-07 19:24:07 +0000</bug_when>
    <thetext>I meant to say &quot;The symptom&quot; in Comment 1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88315</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-07 19:45:35 +0000</bug_when>
    <thetext>In Comment 1 I meant to say &quot;maxuiwait&quot; has no effect.

Question: what are the units on maxuiwait?
http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/server/process.py#n56


I realize I did not change the default server_timeout.

Question: what are the units on server_timeout?
http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/server/process.py#n66
http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/server/xmlrpcclient.py#n44

But this would only matter if we have a race condition or a slow process in XMLRPC protocol. More likely the problem is elswhere?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88370</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-12 13:00:29 +0000</bug_when>
    <thetext>The instrumentation I have so far is in this poky-contrib:
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=timo/fun-with-toaster-failures

What I am working on now is using pdb or other debugging to try to step through and figure out what is happening. But TBH, we had a 3 day weekend and I brewed an Oatmeal Cream Stout.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88402</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-16 06:40:22 +0000</bug_when>
    <thetext>With sufficient instrumentation, we determined that server.runCmd(&quot;setEventMask&quot;... threw BBHandledException in cookerdata.parseBaseConfiguration. This was the hint that was needed to realize the system was trying to parse before the environment was setup.

RP figured out that it was improper sequencing of events in toasterui.

diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index 9260f5d9d7..ec5bd4f105 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -131,6 +131,10 @@ def main(server, eventHandler, params):
 
     helper = uihelper.BBUIHelper()
 
+    if not params.observe_only:
+        params.updateToServer(server, os.environ.copy())
+        params.updateFromServer(server)
+
     # TODO don&apos;t use log output to determine when bitbake has started
     #
     # WARNING: this log handler cannot be removed, as localhostbecontroller
@@ -162,8 +166,6 @@ def main(server, eventHandler, params):
         logger.warning(&quot;buildstats is not enabled. Please enable INHERIT += \&quot;buildstats\&quot; to generate build statistics.&quot;)
 
     if not params.observe_only:
-        params.updateFromServer(server)
-        params.updateToServer(server, os.environ.copy())
         cmdline = params.parseActions()
         if not cmdline:
             print(&quot;Nothing to do.  Use &apos;bitbake world&apos; to build everything, or run &apos;bitbake --help&apos; for usage information.&quot;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88403</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-16 07:05:32 +0000</bug_when>
    <thetext>https://patchwork.openembedded.org/patch/177299/

https://lists.openembedded.org/g/bitbake-devel/message/11757</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88429</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-10-19 14:18:05 +0000</bug_when>
    <thetext>Merged:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=7cad26d585f67fa6bf873b8be361c6335a7db376

This fix also fixes CROPS toaster-container on &quot;master&quot;.
https://travis-ci.org/github/moto-timo/toaster-container/builds/736719631</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4735</attachid>
            <date>2020-10-07 19:21:04 +0000</date>
            <delta_ts>2020-10-07 19:21:04 +0000</delta_ts>
            <desc>toaster_ui.log</desc>
            <filename>file_14079.txt</filename>
            <type>text/plain</type>
            <size>1200</size>
            <attacher name="Tim Orling">tim.orling</attacher>
            
              <data encoding="base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