diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-10-29 13:26:40 +0000 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-10-30 15:42:05 +0000 |
commit | 37afde0a6c6c48bfa18d9f8c495bd4d8bf1cece1 (patch) | |
tree | eb5b0fa5221ecda2d9dae50d93267ba4b33e0062 | |
parent | 09ef8b254342638e828378c2f785963bcf9487da (diff) | |
download | buildstream-37afde0a6c6c48bfa18d9f8c495bd4d8bf1cece1.tar.gz |
Element: Use cached buildtree in build shells and failure shells
This includes changes in app.py:
* Interactive failure shell no longer uses the failed build sysroot,
defaulting to the cached build tree.
Changes in element.py are:
* Errors caused by building don't store the failed build sysroot,
instead storing that a sandbox can be created to debug the error.
* When staging sources, will stage the element's cached build tree if it
exists.
Changes in _exceptions.py:
* BstError.sandbox is now a flag of whether a sandbox can be opened up
to debug the error.
Changes in widget.py:
* Don't try to print any information about the sandbox.
Changes in _message.py:
* Fix documentation so Message.sandbox is not a directory any more.
This is part of #539
-rw-r--r-- | buildstream/_exceptions.py | 6 | ||||
-rw-r--r-- | buildstream/_frontend/app.py | 2 | ||||
-rw-r--r-- | buildstream/_frontend/widget.py | 11 | ||||
-rw-r--r-- | buildstream/_message.py | 2 | ||||
-rw-r--r-- | buildstream/element.py | 12 |
5 files changed, 12 insertions, 21 deletions
diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py index 19606776e..a1c26d38c 100644 --- a/buildstream/_exceptions.py +++ b/buildstream/_exceptions.py @@ -111,10 +111,8 @@ class BstError(Exception): # self.detail = detail - # The build sandbox in which the error occurred, if the - # error occurred at element assembly time. - # - self.sandbox = None + # A sandbox can be created to debug this error + self.sandbox = False # When this exception occurred during the handling of a job, indicate # whether or not there is any point retrying the job. diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index eeb5f3eb2..87db8076a 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -597,7 +597,7 @@ class App(): click.echo("\nDropping into an interactive shell in the failed build sandbox\n", err=True) try: prompt = self.shell_prompt(element) - self.stream.shell(element, Scope.BUILD, prompt, directory=failure.sandbox, isolate=True) + self.stream.shell(element, Scope.BUILD, prompt, isolate=True) except BstError as e: click.echo("Error while attempting to create interactive shell: {}".format(e), err=True) elif choice == 'log': diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py index 478f0ff14..c0c45cec6 100644 --- a/buildstream/_frontend/widget.py +++ b/buildstream/_frontend/widget.py @@ -668,17 +668,6 @@ class LogLine(Widget): extra_nl = True - if message.sandbox is not None: - sandbox = self._indent + 'Sandbox directory: ' + message.sandbox - - text += '\n' - if message.message_type == MessageType.FAIL: - text += self._err_profile.fmt(sandbox, bold=True) - else: - text += self._detail_profile.fmt(sandbox) - text += '\n' - extra_nl = True - if message.scheduler and message.message_type == MessageType.FAIL: text += '\n' diff --git a/buildstream/_message.py b/buildstream/_message.py index 37630eb86..c2cdb8277 100644 --- a/buildstream/_message.py +++ b/buildstream/_message.py @@ -70,7 +70,7 @@ class Message(): self.elapsed = elapsed # The elapsed time, in timed messages self.depth = depth # The depth of a timed message self.logfile = logfile # The log file path where commands took place - self.sandbox = sandbox # The sandbox directory where an error occurred (if any) + self.sandbox = sandbox # The error that caused this message used a sandbox self.pid = os.getpid() # The process pid self.unique_id = unique_id # The plugin object ID issueing the message self.task_id = task_id # The plugin object ID of the task diff --git a/buildstream/element.py b/buildstream/element.py index 848730529..83d7f9705 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -1385,6 +1385,7 @@ class Element(Plugin): # the same filing system as the rest of our cache. temp_staging_location = os.path.join(self._get_context().artifactdir, "staging_temp") temp_staging_directory = tempfile.mkdtemp(prefix=temp_staging_location) + import_dir = temp_staging_directory try: workspace = self._get_workspace() @@ -1395,12 +1396,16 @@ class Element(Plugin): with self.timed_activity("Staging local files at {}" .format(workspace.get_absolute_path())): workspace.stage(temp_staging_directory) + elif self._cached(): + # We have a cached buildtree to use, instead + artifact_base, _ = self.__extract() + import_dir = os.path.join(artifact_base, 'buildtree') else: # No workspace, stage directly for source in self.sources(): source._stage(temp_staging_directory) - vdirectory.import_files(temp_staging_directory) + vdirectory.import_files(import_dir) finally: # Staging may produce directories with less than 'rwx' permissions @@ -1566,9 +1571,8 @@ class Element(Plugin): collect = self.assemble(sandbox) # pylint: disable=assignment-from-no-return self.__set_build_result(success=True, description="succeeded") except BstError as e: - # If an error occurred assembling an element in a sandbox, - # then tack on the sandbox directory to the error - e.sandbox = rootdir + # Shelling into a sandbox is useful to debug this error + e.sandbox = True # If there is a workspace open on this element, it will have # been mounted for sandbox invocations instead of being staged. |