[Notes] [Git][BuildStream/buildstream][bschubert/dont-cache-errors-from-host-tools] element.py: Only cache on element error or success



Title: GitLab

Benjamin Schubert pushed to branch bschubert/dont-cache-errors-from-host-tools at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/element.py
    ... ... @@ -86,7 +86,7 @@ from . import _yaml
    86 86
     from ._variables import Variables
    
    87 87
     from ._versions import BST_CORE_ARTIFACT_VERSION
    
    88 88
     from ._exceptions import BstError, LoadError, LoadErrorReason, ImplError, \
    
    89
    -    ErrorDomain, SandboxError
    
    89
    +    ErrorDomain
    
    90 90
     from .utils import UtilError
    
    91 91
     from . import Plugin, Consistency, Scope
    
    92 92
     from . import SandboxFlags
    
    ... ... @@ -1554,9 +1554,6 @@ class Element(Plugin):
    1554 1554
                     self.__dynamic_public = _yaml.node_copy(self.__public)
    
    1555 1555
     
    
    1556 1556
                     # Call the abstract plugin methods
    
    1557
    -                collect = None
    
    1558
    -                save_artifacts = True
    
    1559
    -
    
    1560 1557
                     try:
    
    1561 1558
                         # Step 1 - Configure
    
    1562 1559
                         self.configure_sandbox(sandbox)
    
    ... ... @@ -1567,10 +1564,9 @@ class Element(Plugin):
    1567 1564
                         # Step 4 - Assemble
    
    1568 1565
                         collect = self.assemble(sandbox)  # pylint: disable=assignment-from-no-return
    
    1569 1566
                         self.__set_build_result(success=True, description="succeeded")
    
    1570
    -                except BstError as e:
    
    1571
    -                    if isinstance(e, SandboxError):
    
    1572
    -                        save_artifacts = False
    
    1573 1567
     
    
    1568
    +                    return self._cache_artifact(rootdir, sandbox, collect)
    
    1569
    +                except ElementError as e:
    
    1574 1570
                         # Shelling into a sandbox is useful to debug this error
    
    1575 1571
                         e.sandbox = True
    
    1576 1572
     
    
    ... ... @@ -1592,22 +1588,13 @@ class Element(Plugin):
    1592 1588
                                 self.warn("Failed to preserve workspace state for failed build sysroot: {}"
    
    1593 1589
                                           .format(e))
    
    1594 1590
     
    
    1595
    -                    if isinstance(e, ElementError):
    
    1596
    -                        collect = e.collect  # pylint: disable=no-member
    
    1597
    -
    
    1598 1591
                         self.__set_build_result(success=False, description=str(e), detail=e.detail)
    
    1592
    +                    self._cache_artifact(rootdir, sandbox, e.collect)
    
    1593
    +
    
    1599 1594
                         raise
    
    1600 1595
                     finally:
    
    1601
    -                    if save_artifacts:
    
    1602
    -                        artifact_size = self._cache_artifact(rootdir, sandbox, context, collect)
    
    1603
    -                    else:
    
    1604
    -                        artifact_size = None
    
    1605
    -
    
    1606
    -                    # Finally cleanup the build dir
    
    1607 1596
                         cleanup_rootdir()
    
    1608 1597
     
    
    1609
    -        return artifact_size
    
    1610
    -
    
    1611 1598
         def _cache_artifact(self, rootdir, sandbox, collect):
    
    1612 1599
             if collect is not None:
    
    1613 1600
                 try:
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]