diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-05-06 19:36:47 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-05-06 20:59:23 +0900 |
commit | 7c58d8aca51e10efbe9aacbf5df5ee11195dcc36 (patch) | |
tree | d712c4966d82c26125346835b10715b35280a73c | |
parent | cae0f60cfdc1c1c4a69d2b3ea133840c2c5a4d78 (diff) | |
download | buildstream-7c58d8aca51e10efbe9aacbf5df5ee11195dcc36.tar.gz |
element.py: Reset workspace state if last successful build is missing.
If the artifact referred to by the last successful build in the
workspace state no longer exists, reset the workspace state and
do not attempt to perform an incremental build instead of crashing.
This fixes #1017
-rw-r--r-- | buildstream/element.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 898ff0784..b98675720 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -699,9 +699,26 @@ class Element(Plugin): old_dep_keys = {} workspace = self._get_workspace() project = self._get_project() + context = self._get_context() if self.__can_build_incrementally() and workspace.last_successful: - old_dep_keys = self.__get_artifact_metadata_dependencies(workspace.last_successful) + + # Try to perform an incremental build if the last successful + # build is still in the artifact cache + # + if self.__artifacts.contains(self, workspace.last_successful): + old_dep_keys = self.__get_artifact_metadata_dependencies(workspace.last_successful) + else: + # Last successful build is no longer in the artifact cache, + # so let's reset it and perform a full build now. + workspace.prepared = False + workspace.last_successful = None + + self.info("Resetting workspace state, last successful build is no longer in the cache") + + # In case we are staging in the main process + if utils._is_main_process(): + context.get_workspaces().save_config() for dep in self.dependencies(scope): # If we are workspaced, and we therefore perform an @@ -726,7 +743,7 @@ class Element(Plugin): # In case we are running `bst shell`, this happens in the # main process and we need to update the workspace config if utils._is_main_process(): - self._get_context().get_workspaces().save_config() + context.get_workspaces().save_config() result = dep.stage_artifact(sandbox, path=path, |