diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2018-11-19 10:40:34 +0000 |
---|---|---|
committer | Benjamin Schubert <ben.c.schubert@gmail.com> | 2018-11-19 11:38:57 +0000 |
commit | 438ab5e048b65791f500e0e4e46c5ac4d27f7a2f (patch) | |
tree | 16f0a88c0b19a040ba088000059b9f5881b21f30 | |
parent | c0c97ea863fe407256fe2ec419147836a4a1d912 (diff) | |
download | buildstream-bschubert/dont-cache-errors-from-host-tools.tar.gz |
element.py: Only cache on element error or successbschubert/dont-cache-errors-from-host-tools
Reverse the way we were handling caching by only caching
when we know it's a problem with the build or the build is a
success in order not to cache transient errors.
-rw-r--r-- | buildstream/element.py | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 5bcc0151d..eef9eb94d 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -86,7 +86,7 @@ from . import _yaml from ._variables import Variables from ._versions import BST_CORE_ARTIFACT_VERSION from ._exceptions import BstError, LoadError, LoadErrorReason, ImplError, \ - ErrorDomain, SandboxError + ErrorDomain from .utils import UtilError from . import Plugin, Consistency, Scope from . import SandboxFlags @@ -1554,9 +1554,6 @@ class Element(Plugin): self.__dynamic_public = _yaml.node_copy(self.__public) # Call the abstract plugin methods - collect = None - save_artifacts = True - try: # Step 1 - Configure self.configure_sandbox(sandbox) @@ -1567,10 +1564,9 @@ class Element(Plugin): # Step 4 - Assemble collect = self.assemble(sandbox) # pylint: disable=assignment-from-no-return self.__set_build_result(success=True, description="succeeded") - except BstError as e: - if isinstance(e, SandboxError): - save_artifacts = False + return self._cache_artifact(rootdir, sandbox, collect) + except ElementError as e: # Shelling into a sandbox is useful to debug this error e.sandbox = True @@ -1592,22 +1588,13 @@ class Element(Plugin): self.warn("Failed to preserve workspace state for failed build sysroot: {}" .format(e)) - if isinstance(e, ElementError): - collect = e.collect # pylint: disable=no-member - self.__set_build_result(success=False, description=str(e), detail=e.detail) + self._cache_artifact(rootdir, sandbox, e.collect) + raise finally: - if save_artifacts: - artifact_size = self._cache_artifact(rootdir, sandbox, context, collect) - else: - artifact_size = None - - # Finally cleanup the build dir cleanup_rootdir() - return artifact_size - def _cache_artifact(self, rootdir, sandbox, collect): if collect is not None: try: |