diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-08-17 10:11:14 +0100 |
---|---|---|
committer | Martin Blanchard <martin.blanchard@codethink.co.uk> | 2018-09-07 13:57:29 +0100 |
commit | 89b29b8bcf9ce56dd8ee0161433a225acb786151 (patch) | |
tree | 43559692c7e2038ea7cb6274ce65193fe90d6caa | |
parent | c73896bb594b9ddb050d6935b205448004828386 (diff) | |
download | buildstream-89b29b8bcf9ce56dd8ee0161433a225acb786151.tar.gz |
element.py: Switch to SandboxRemote if config option is set
https://gitlab.com/BuildStream/buildstream/issues/454
-rw-r--r-- | buildstream/element.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index d41ebac76..dd7ccfed3 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -95,6 +95,7 @@ from . import _site from ._platform import Platform from .plugin import CoreWarnings from .sandbox._config import SandboxConfig +from .sandbox._sandboxremote import SandboxRemote from .storage.directory import Directory from .storage._filebaseddirectory import FileBasedDirectory @@ -2154,7 +2155,32 @@ class Element(Plugin): project = self._get_project() platform = Platform.get_platform() - if directory is not None and os.path.exists(directory): + 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)) + + sandbox = SandboxRemote(context, project, + directory, + stdout=stdout, + stderr=stderr, + config=config, + server_url=self.__remote_execution_url, + allow_real_directory=False) + yield sandbox + + elif directory is not None and os.path.exists(directory): + if self.__remote_execution_url: + self.warn("Artifact {} is configured to use remote execution but element plugin does not support it." + .format(self.name), detail="Element plugin '{kind}' does not support virtual directories." + .format(kind=self.get_kind()), warning_token="remote-failure") + + self.info("Falling back to local sandbox for artifact {}".format(self.name)) + sandbox = platform.create_sandbox(context, project, directory, stdout=stdout, |