summaryrefslogtreecommitdiff
path: root/buildstream/element.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-06 19:36:47 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2019-05-06 11:10:12 +0000
commit8f76b75f1991d4438542c04012ee286c702cd1cb (patch)
tree291da65d7a56915e3f991da597fc42ca182c91dd /buildstream/element.py
parent230c749e085374e8ab252c234f623dc346863926 (diff)
downloadbuildstream-8f76b75f1991d4438542c04012ee286c702cd1cb.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
Diffstat (limited to 'buildstream/element.py')
-rw-r--r--buildstream/element.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 8cc25fec6..cc31d3f02 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -738,8 +738,24 @@ class Element(Plugin):
context = self._get_context()
if self.__can_build_incrementally() and workspace.last_successful:
- last_successful = Artifact(self, context, strong_key=workspace.last_successful)
- old_dep_keys = last_successful.get_metadata_dependencies()
+
+ # 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):
+ last_successful = Artifact(self, context, strong_key=workspace.last_successful)
+ old_dep_keys = last_successful.get_metadata_dependencies()
+ 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
@@ -764,7 +780,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,