diff options
author | Jim MacArthur <jim+gitlab@mode7.co.uk> | 2018-09-21 11:26:55 +0000 |
---|---|---|
committer | Jim MacArthur <jim+gitlab@mode7.co.uk> | 2018-09-21 11:26:55 +0000 |
commit | 55c93a82ecea4f7bf35c5367408ef5c3696560b5 (patch) | |
tree | 06be3a907dfbd8767a38e3285885f67f0f2d646d | |
parent | 662c729fa32489312beed6318956ba9ce94e685f (diff) | |
parent | ca1bb72cc098febfd1194c001f6db2a1d18cbaea (diff) | |
download | buildstream-55c93a82ecea4f7bf35c5367408ef5c3696560b5.tar.gz |
Merge branch 'jmac/remote_exec_checkout_fix' into 'master'
Remote exec: Remove early warning and check directory is not None
See merge request BuildStream/buildstream!800
-rw-r--r-- | buildstream/_artifactcache/cascache.py | 16 | ||||
-rw-r--r-- | buildstream/element.py | 13 | ||||
-rw-r--r-- | buildstream/sandbox/_sandboxremote.py | 4 | ||||
-rw-r--r-- | tests/artifactcache/push.py | 4 |
4 files changed, 22 insertions, 15 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py index 840e190f1..50f74a927 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -348,19 +348,29 @@ class CASCache(ArtifactCache): return pushed def push_directory(self, project, directory): + """ Push the given virtual directory to all remotes. + + Args: + project (Project): The current project + directory (Directory): A virtual directory object to push. + + Raises: ArtifactError if no push remotes are configured. + """ push_remotes = [r for r in self._remotes[project] if r.spec.push] + if not push_remotes: + raise ArtifactError("CASCache: push_directory was called, but no remote artifact " + + "servers are configured as push remotes.") + if directory.ref is None: - return None + return for remote in push_remotes: remote.init() self._send_directory(remote, directory.ref) - return directory.ref - def push_message(self, project, message): push_remotes = [r for r in self._remotes[project] if r.spec.push] diff --git a/buildstream/element.py b/buildstream/element.py index 6bc400bb9..602bf01cc 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2137,14 +2137,11 @@ class Element(Plugin): project = self._get_project() platform = Platform.get_platform() - if self.__remote_execution_url and self.BST_VIRTUAL_DIRECTORY: - if not self.__artifacts.has_push_remotes(element=self): - # Give an early warning if remote execution will not work - raise ElementError("Artifact {} is configured to use remote execution but has no push remotes. " - .format(self.name) + - "The remote artifact server(s) may not be correctly configured or contactable.") - - self.info("Using a remote sandbox for artifact {}".format(self.name)) + if (directory is not None and + self.__remote_execution_url and + self.BST_VIRTUAL_DIRECTORY): + + self.info("Using a remote sandbox for artifact {} with directory '{}'".format(self.name, directory)) sandbox = SandboxRemote(context, project, directory, diff --git a/buildstream/sandbox/_sandboxremote.py b/buildstream/sandbox/_sandboxremote.py index 82968ecb0..2fca53a96 100644 --- a/buildstream/sandbox/_sandboxremote.py +++ b/buildstream/sandbox/_sandboxremote.py @@ -173,8 +173,8 @@ class SandboxRemote(Sandbox): platform = Platform.get_platform() cascache = platform.artifactcache # Now, push that key (without necessarily needing a ref) to the remote. - vdir_digest = cascache.push_directory(self._get_project(), upload_vdir) - if not vdir_digest or not cascache.verify_digest_pushed(self._get_project(), vdir_digest): + cascache.push_directory(self._get_project(), upload_vdir) + if not cascache.verify_digest_pushed(self._get_project(), upload_vdir.ref): raise SandboxError("Failed to verify that source has been pushed to the remote artifact cache.") # Set up environment and working directory diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py index bdeb86862..faf6a6980 100644 --- a/tests/artifactcache/push.py +++ b/tests/artifactcache/push.py @@ -228,9 +228,9 @@ def _test_push_directory(user_config_file, project_dir, artifact_dir, artifact_d directory = CasBasedDirectory(context, ref=artifact_digest) # Push the CasBasedDirectory object - directory_digest = cas.push_directory(project, directory) + cas.push_directory(project, directory) - queue.put(directory_digest.hash) + queue.put(directory.ref.hash) else: queue.put("No remote configured") |