<?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>9937</bug_id>
          
          <creation_ts>2016-07-14 13:04:12 +0000</creation_ts>
          <short_desc>Make use of pseudo optional, under certain conditions</short_desc>
          <delta_ts>2016-09-15 12:45:40 +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>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>enhancement</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Igor Stoppa">igor.stoppa</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>sgw</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>63972</commentid>
    <comment_count>0</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-07-14 13:04:12 +0000</bug_when>
    <thetext>Premise
-------
* Bitbake expects to be used as regular user and relies on pseudo to simulate various activity that would be possible only if it was running as root.

* This makes sense when running a build natively, to prevent, among other things, that a broken recipe damages the host installation.

* the price paid is that pseudo will introduce an overhead whenever it hijacks a call that would otherwise fail because it would require root privileges.


Problems
--------
* In some cases, the overhead is just too much.
* One might prefer to run bitbake _anyway_ inside a VM or a container, for example for ensuring that the host environment is stable. Or to have an easy way to replicate builder instances. In this case one would easily afford to run as root, because the VM/container can/will be trashed and restored. So the overhead introduced by pseudo is completely unnecessary.


Proposal
--------

Allow users to run bitbake as root, without pseudo.
This can be gated by a liberal amount of checks/warnings, but it should be available for power users who do know what they are doing.
It could be even conditioned to the presence of telltales that clearly let the bitbake instance to identify itself as running in a VM/container and therefore accept that they are run as root user.

The execution of pseudo could be conditioned to the user running bitbake: keep it if the user is not root, drop it if the user is root.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64167</commentid>
    <comment_count>1</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-07-19 16:20:45 +0000</bug_when>
    <thetext>Based on bug #9449 I would propose to increase the importance of this feature and to take it in consideration for implementation, instead of leaving it parked for &quot;future&quot; releases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65917</commentid>
    <comment_count>2</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-09-08 11:44:55 +0000</bug_when>
    <thetext>Here are some numbers that back the request.

Building an Ostro image with support for swupd took multiple hours, even if the entire content of the image was available already as part of the SSTATE.

This was caused mostly by pseudo and the way it handles concurrent accesse to its internal database.

After using a hacked version of pseudo that doesn&apos;t hijack ownership, the very same build process, run inside a container, took about 20 minutes.

The improvement is about 2 orders of magnitude, on a time scale that is very relevant for human beings.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65918</commentid>
    <comment_count>3</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-09-08 11:46:08 +0000</bug_when>
    <thetext>Sorry, 1 order of magnitude.
Still quite dramatic, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66052</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-09-12 20:51:32 +0000</bug_when>
    <thetext>Didn&apos;t this issue get fixed by some of the changes to pseudo internals?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66069</commentid>
    <comment_count>5</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-09-13 07:22:13 +0000</bug_when>
    <thetext>AFAIK no, it&apos;s still open.
At least, we could reproduce it about 1 month ago with the latest Ostro.
Is there any specific patch/revision we should aim for?

As generic comment: as long as the issue persist (pseudo queuing parallel access to the filesystem because of the DB handling), it will not only affect swupd, but any attempt of generating updates for YP, because of the intrinsic nature of the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66075</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-09-13 09:00:43 +0000</bug_when>
    <thetext>Sadly, even if you allow bitbake to run as root you have several problems:

a) recipes need to create their own users which they do with adduser/deluser. In the root model, this would have to be reflected in the underlying user accounts, meaning that a given system had to be dedicated to a given build.

b) You can&apos;t really obtain a &quot;clean&quot; set of base user/group files since most distros do already have some underlying users which could conflict with those setup by the build.

c) You&apos;d have to be very sure that the filesystem you were building on supported things like xattr to match the requirements of the build exactly.

Whilst many of these are surmountable by using a specifically developed VM image, it would require very precise setup from the user with a much greater potential for errors. It would go against the ethos of not requiring root access and it would introduce two different ways of running a build, meaning we&apos;d have to double our QA test plan to test everything in both scenarios.

For all those reasons, I think we&apos;ll have to find a way to fix pseudo to perform better, or swupd to have some pseudo knowledge to help it avoid the performance issues (run different commands in separate pseudo instances?) and that we will not be supporting builds as root, if for no other reason that the impact on the testing matrix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66078</commentid>
    <comment_count>7</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-09-13 10:43:18 +0000</bug_when>
    <thetext>I won&apos;t reopen this, because we clearly have different perspective about what would be more user-friendly and the discussion would not be technical anymore.

But I personally think the container based solution would be preferable.

Example:

It might be by design, yet I find it confusing, that when I build -native packages, they are *not* built with a -native bootstrapped compiler.
Instead they are built with the host compiler, leading to any sort of different outcome when 2 people have different host distros.

The container approach would put everyone on the same ground and make much more effective use of the SSTATE for -native component.

Right now, if I happen to have a host distro which is different from the one used to populate a shared SSTATE, I&apos;m left out in the cold and I have to rebuild all the -native components that are affected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66192</commentid>
    <comment_count>8</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-09-15 10:19:49 +0000</bug_when>
    <thetext>(In reply to comment #7)

&gt; It might be by design, yet I find it confusing, that when I build -native
&gt; packages, they are *not* built with a -native bootstrapped compiler.
&gt; Instead they are built with the host compiler, leading to any sort of
&gt; different outcome when 2 people have different host distros.
&gt; 
&gt; The container approach would put everyone on the same ground and make much
&gt; more effective use of the SSTATE for -native component.
&gt; 
&gt; Right now, if I happen to have a host distro which is different from the one
&gt; used to populate a shared SSTATE, I&apos;m left out in the cold and I have to
&gt; rebuild all the -native components that are affected.

We do have the concept of &quot;uninative&quot; which does in fact allow one sstate feed to feed native sstate objects to all users. This problem you describe of sstate reuse for native objects therefore doesn&apos;t exist any more.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66198</commentid>
    <comment_count>9</comment_count>
    <who name="Igor Stoppa">igor.stoppa</who>
    <bug_when>2016-09-15 12:45:40 +0000</bug_when>
    <thetext>&gt; We do have the concept of &quot;uninative&quot; which does in fact allow one sstate feed to 
&gt; feed native sstate objects to all users. This problem you describe of sstate 
&gt; reuse for native objects therefore doesn&apos;t exist any more.

Yes, I&apos;m aware of uninative, however it doesn&apos;t seem to work on my setup.
My host distro is SUSE 42.1 (yes, I do get the warning that it&apos;s not officially supported) and other people in my team use typically RedHat.

According to my understanding, even if the sstate claims that native files built on different hosts are compatible, because they use the same uninative libraries, in place of those coming with the host compiler, yet the compilers used are different (because different distros ship different compilers, usually) and they do produce different binary files.

A recent example of this, I believe, is how OTMPFILE is handled.

On my SUSE42.1, running code from ostree on the host was generating an error saying that OTMPFILE was not supported. Running basically the same command in a recipe was instead showing that OTMPFILE was supported, but it failed halfway.

On fedora, the detection succeeded consistently both in the host and in the pseudo environment.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>