<?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>13803</bug_id>
          
          <creation_ts>2020-02-19 20:24:04 +0000</creation_ts>
          <short_desc>devtool setupClass file copying race</short_desc>
          <delta_ts>2020-09-30 14:26:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>QA/Testing</classification>
          <product>Functional (self) Testing</product>
          <component>oe-selftest</component>
          <version>unspecified</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>backport 3.1 AB-INT</status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>3.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Purdie">richard.purdie</reporter>
          <assigned_to name="Tim Orling">tim.orling</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>tim.orling</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>86491</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2020-02-19 20:24:04 +0000</bug_when>
    <thetext>https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/704

2020-02-19 20:07:20,543 - oe-selftest - INFO - ======================================================================
2020-02-19 20:07:20,709 - oe-selftest - INFO - ERROR: setUpModule (devtool) [ (subunit.RemotedTestCase)
2020-02-19 20:07:20,710 - oe-selftest - INFO - ----------------------------------------------------------------------
2020-02-19 20:07:20,710 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/selftest/cases/devtool.py&quot;, line 67, in setUpModule
    bb.utils.edit_bblayers_conf(bblayers_conf, None, None, bblayers_edit_cb)
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/bitbake/lib/bb/utils.py&quot;, line 1461, in edit_bblayers_conf
    (updated, newlines) = edit_metadata(newlines, [&apos;BBLAYERS&apos;], handle_bblayers)
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/bitbake/lib/bb/utils.py&quot;, line 1291, in edit_metadata
    if handle_var_end():
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/bitbake/lib/bb/utils.py&quot;, line 1216, in handle_var_end
    (newvalue, newop, indent, minbreak) = varfunc(in_var, full_value, op, newlines)
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/bitbake/lib/bb/utils.py&quot;, line 1426, in handle_bblayers
    res = edit_cb(layer, canonicalise_path(layer))
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/selftest/cases/devtool.py&quot;, line 59, in bblayers_edit_cb
    shutil.copytree(pth, destdir)
  File &quot;/opt/poky/3.0.1/sysroots/x86_64-pokysdk-linux/usr/lib/python3.7/shutil.py&quot;, line 368, in copytree
    raise Error(errors)
shutil.Error: [(&apos;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oe/__pycache__/classextend.cpython-37.pyc.139811433930384&apos;, &apos;/tmp/devtoolqa2ey8u4_m/core-copy/meta/lib/oe/__pycache__/classextend.cpython-37.pyc.139811433930384&apos;, &quot;[Errno 2] No such file or directory: &apos;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oe/__pycache__/classextend.cpython-37.pyc.139811433930384&apos;&quot;), (&apos;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oe/__pycache__/classextend.cpython-37.pyc.140620172132720&apos;, &apos;/tmp/devtoolqa2ey8u4_m/core-copy/meta/lib/oe/__pycache__/classextend.cpython-37.pyc.140620172132720&apos;, &quot;[Errno 2] No such file or directory: &apos;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oe/__pycache__/classextend.cpython-37.pyc.140620172132720&apos;&quot;)]

Files are being acessed/created whilst the copy takes place leading to failures.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86526</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-02-20 16:00:34 +0000</bug_when>
    <thetext>Only seen once so far.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87854</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-07-30 07:28:33 +0000</bug_when>
    <thetext>*** Bug 13421 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87872</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-08-03 09:14:18 +0000</bug_when>
    <thetext>We&apos;ve seen this same pattern in 13803, so more than once.

If it is indeed a race condition with .pyc files being used while they are being copied, then the ignore_pattern argument to copytree looks to be the solution [1]:

&quot;&quot;&quot;
Another example that uses the ignore_patterns() helper:

from shutil import copytree, ignore_patterns

copytree(source, destination, ignore=ignore_patterns(&apos;*.pyc&apos;, &apos;tmp*&apos;))
This will copy everything except .pyc files and files or directories whose name starts with tmp.
&quot;&quot;&quot;

[1] https://docs.python.org/3/library/shutil.html#copytree-example</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87873</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-08-03 09:22:57 +0000</bug_when>
    <thetext>The answers in this SO look promising:

https://stackoverflow.com/questions/7842044/filter-directory-when-using-shutil-copytree</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88241</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-09-25 10:38:57 +0000</bug_when>
    <thetext>subunit.RemotedTestCase Tells us the offending code (shutil.copytree) only occurs when running oe-selftest in parallel (-j), e.g.

oe-selftest -v -j 8 -r devtool

Note this requires python3-testtools and python3-subunit installed on the host (need to double check docs are calling that out).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88258</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-09-28 21:42:50 +0000</bug_when>
    <thetext>Yes, it&apos;s a one-liner solution, but testing it is non-trivial. oe-selftest assumes you have a large /tmp partition (which I do not), so I had to hack a local branch to use my large build partition. Also, as noted in previous comment, the code in question is only exercised in parallel oe-selftest operation.

With HIGHLY instrumented code, I have found no failures of the simple one-liner patch (other than the npm test case which is unrelated). I have also not found a smoking gun that proves I fixed it. But it **should** be the right fix.

So, submit and move on to the next bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88276</commentid>
    <comment_count>7</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-09-30 14:26:57 +0000</bug_when>
    <thetext>Merged to master:  http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=31d3042487c7e1d61bcde37801d17e518ca88da0</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>