<?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>13923</bug_id>
          
          <creation_ts>2020-05-29 01:14:35 +0000</creation_ts>
          <short_desc>OE-Core not compatible with Docker overlayfs and pre-built images</short_desc>
          <delta_ts>2020-06-05 01:19:00 +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>OE-Core</product>
          <component>core</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>3.2 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tobias Hagelborn">tobias.hagelborn</reporter>
          <assigned_to name="Joshua Watt">JPEWhacker</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>87363</commentid>
    <comment_count>0</comment_count>
    <who name="Tobias Hagelborn">tobias.hagelborn</who>
    <bug_when>2020-05-29 01:14:35 +0000</bug_when>
    <thetext>oe-core is incompatible with Docker overlay(2) storage driver some files are in another overlay layer. Something that happens if parts of the build directory is pre-populated in a pre-built Docker image.

Scenario:
- Run bitbake --setscene-only &lt;IMAGE&gt;
- Add the resulting build directory to a Docker image
  (The purpose is to make a prebuilt image for faster build times)
- Use the image to build a newer image (including new external sstate changes and code changes)

With pre-populated docker mage content there is a risk of ERRNO 18 &quot;Invalid cross-device link&quot; even if being on the same mount point.
Docker are very clear about this limitation (https://docs.docker.com/storage/storagedriver/overlayfs-driver/) and states it is up to the application (bitbake / oe) to solve the issue.
- overlay(2) storage driver is the promoted and preferred solution from Docker over AUFS and other storage drivers.

Example from an image pre-populated via a bitbake --setscene &lt;image&gt;
file: &apos;&lt;builddir&gt;/build/meta/classes/sstate.bbclass&apos;, lineno: 637, function: sstate_package
     0633:                if not link.startswith(tmpdir):
     0634:                    continue
     0635:                bb.error(&quot;sstate found an absolute path symlink %s pointing at %s. Please replace this with a relative link.&quot; % (srcpath, link))
     0636:        bb.debug(2, &quot;Preparing tree %s for packaging at %s&quot; % (state[1], sstatebuild + state[0]))
 *** 0637:        os.rename(state[1], sstatebuild + state[0])
     0638:
     0639:    workdir = d.getVar(&apos;WORKDIR&apos;)
     0640:    sharedworkdir = os.path.join(d.getVar(&apos;TMPDIR&apos;), &quot;work-shared&quot;)
     0641:    for plain in ss[&apos;plaindirs&apos;]:
Exception: OSError: [Errno 18] Invalid cross-device link: &apos;&lt;builddir&gt;/build/tmp/work/&lt;machine&gt;-poky-linux-gnueabi/busybox/1.31.0-r0/pkgdata-pdata-input&apos; -&gt; &apos;/home/svcj-build/build/build/tmp/work/&lt;machine&gt;-poky-linux-gnueabi/busybox/1.31.0-r0/sstate-build-packagedata/pkgdata-pdata-input&apos;

According to Docker, the proper solution is to have a move fallback and not just relay on os.rename (python) and any other rename function.

Unfortunately, Bitbake/Poky uses os.rename and os.link heavily and this, appears to be incompatible with this way of working.

This may be a deliberate design choice and then this is no bug but I want to make you aware that it is not possible to have any performance gains by using a pre-populated /pre-built Docker image as a base for building with bitbake.

Unfortunately, there are some steps to create the docker image so I can&apos;t give a nice &quot;steps-to-reproduce&quot;. Thus, this is more of an awareness issue.


Solution:
- It might be possible to replace all os.rename with bb.utils.movefile to avoid the error given above. There might be more issues though with os.link operations etc.

However, I am concerned that the way recipe-specific-sysroot works with hardlinks might prevent this use-case all together.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87423</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Watt">JPEWhacker</who>
    <bug_when>2020-06-04 11:23:08 +0000</bug_when>
    <thetext>bitbake and OE make the assumption that TMPDIR is one a single filesystem, and changing that is not something we really want to fix.

A different way to solve this might be instead to include the initial sstate cache in the docker image so that the first time the user runs a command, it restores (quickly) from sstate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87424</commentid>
    <comment_count>2</comment_count>
    <who name="Joshua Watt">JPEWhacker</who>
    <bug_when>2020-06-04 11:24:52 +0000</bug_when>
    <thetext>To clarify: we don&apos;t want to fix it because it would be quite disruptive and likely to easily break again without ongoing effort to test and maintain.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87431</commentid>
    <comment_count>3</comment_count>
    <who name="Tobias Hagelborn">tobias.hagelborn</who>
    <bug_when>2020-06-05 01:19:00 +0000</bug_when>
    <thetext>Thanks for having a look at this Joshua and I fully understand that you have to make this kind of assumptions on the underlying file system.
It is unfortunate that Docker overlayfs has this kind of limitation.

Unfortunately in-image sstate cache is not an option for us, I wanted to avoid the setscene procedure all together since it is actually very CPU intensive and takes 5 minutes for us with 16 active cores.
(We do 10K+ builds like this every day)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>