_sandboxbwrap.py: Post-bwrap cleanup shouldn't attempt to remove preexisting folders
Problem: According to comments here and here, Bubblewrap-sandbox shouldn't try to remove some special folders (dev,tmp,proc) if they already exist before
run_bwrap(). In other words, it only should remove (as cleanup) if those folders get created during bubblewraping. But, the
if condition here seems to be doing the opposite and one can get errors like this:
[00:00:05][febd1eb1][build:rhel6-base/rhel6-build-base.bst] BUG Build An unhandled exception occured: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/buildstream/_scheduler/job.py", line 320, in _child_action result = self._action_cb(element) File "/usr/local/lib/python3.6/dist-packages/buildstream/_scheduler/buildqueue.py", line 34, in process element._assemble() File "/usr/local/lib/python3.6/dist-packages/buildstream/element.py", line 1396, in _assemble collect = self.assemble(sandbox) File "/usr/local/lib/python3.6/dist-packages/buildstream/buildelement.py", line 186, in assemble self.__run_command(sandbox, cmd, command_name) File "/usr/local/lib/python3.6/dist-packages/buildstream/buildelement.py", line 242, in __run_command SandboxFlags.ROOT_READ_ONLY) File "/usr/local/lib/python3.6/dist-packages/buildstream/sandbox/_sandboxbwrap.py", line 231, in run os.rmdir(base_directory) OSError: [Errno 39] Directory not empty: '/root/.cache/buildstream/build/rhel6-base-rhel6-build-base-4gxmx90l/root/dev'
In our case, this happened while running
bst build on an
kind: manual element that depends on an import element (a base image with non-empty /dev/ folder).
Solution: According to clarification on IRC, the negation in the if clause should be removed and having an integration test to verify the behaviour should be added.