You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ak...@apache.org on 2022/06/17 06:11:32 UTC

[buildstream] branch dummy-sandbox created (now dfe1cebce)

This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a change to branch dummy-sandbox
in repository https://gitbox.apache.org/repos/asf/buildstream.git


      at dfe1cebce platform: return a dummy sandbox when the sandbox config can't be satisfied

This branch includes the following new commits:

     new 0c825fc63 platform: merge check_sandbox_config into create_sandbox
     new dfe1cebce platform: return a dummy sandbox when the sandbox config can't be satisfied

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/02: platform: merge check_sandbox_config into create_sandbox

Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a commit to branch dummy-sandbox
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 0c825fc6362e583f8722edec76f4cdd7d0e4dcd8
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Wed Jan 6 13:07:57 2021 +0100

    platform: merge check_sandbox_config into create_sandbox
    
    It's only called just before creating a sandbox
---
 src/buildstream/_platform/platform.py          | 17 +----------------
 src/buildstream/element.py                     |  1 -
 src/buildstream/sandbox/_sandboxbuildboxrun.py |  2 +-
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py
index e924f0bb8..6af8ebb22 100644
--- a/src/buildstream/_platform/platform.py
+++ b/src/buildstream/_platform/platform.py
@@ -161,42 +161,27 @@ class Platform:
     def create_sandbox(self, *args, **kwargs):  # pylint: disable=method-hidden
         raise ImplError("Platform {platform} does not implement create_sandbox()".format(platform=type(self).__name__))
 
-    def check_sandbox_config(self, config):  # pylint: disable=method-hidden
-        raise ImplError(
-            "Platform {platform} does not implement check_sandbox_config()".format(platform=type(self).__name__)
-        )
-
     # Buildbox run sandbox methods
-    def _check_sandbox_config_buildboxrun(self, config):
-        from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun  # pylint: disable=cyclic-import
-
-        SandboxBuildBoxRun.check_sandbox_config(self, config)
-
     @staticmethod
     def _create_buildboxrun_sandbox(*args, **kwargs):
         from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun  # pylint: disable=cyclic-import
 
+        SandboxBuildBoxRun.check_sandbox_config(kwargs['config'])
         return SandboxBuildBoxRun(*args, **kwargs)
 
     def _setup_buildboxrun_sandbox(self):
         from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun  # pylint: disable=cyclic-import
 
         self._check_sandbox(SandboxBuildBoxRun)
-        self.check_sandbox_config = self._check_sandbox_config_buildboxrun
         self.create_sandbox = self._create_buildboxrun_sandbox
         return True
 
     # Dummy sandbox methods
-    @staticmethod
-    def _check_dummy_sandbox_config(config):
-        pass
-
     def _create_dummy_sandbox(self, *args, **kwargs):
         dummy_reasons = " and ".join(self.dummy_reasons)
         kwargs["dummy_reason"] = dummy_reasons
         return SandboxDummy(*args, **kwargs)
 
     def _setup_dummy_sandbox(self):
-        self.check_sandbox_config = Platform._check_dummy_sandbox_config
         self.create_sandbox = self._create_dummy_sandbox
         return True
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index a53ab331f..0ca7f59b7 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -2707,7 +2707,6 @@ class Element(Plugin):
 
         elif directory is not None and os.path.exists(directory):
             platform = context.platform
-            platform.check_sandbox_config(config)
 
             sandbox = platform.create_sandbox(
                 context,
diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py
index 5bbe93f76..765caf166 100644
--- a/src/buildstream/sandbox/_sandboxbuildboxrun.py
+++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py
@@ -69,7 +69,7 @@ class SandboxBuildBoxRun(SandboxREAPI):
             cls._isas.add(Platform.get_host_arch())
 
     @classmethod
-    def check_sandbox_config(cls, platform, config):
+    def check_sandbox_config(cls, config):
         if config.build_os not in cls._osfamilies:
             raise SandboxError("OS '{}' is not supported by buildbox-run.".format(config.build_os))
         if config.build_arch not in cls._isas:


[buildstream] 02/02: platform: return a dummy sandbox when the sandbox config can't be satisfied

Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a commit to branch dummy-sandbox
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit dfe1cebced067587495281543d78fd52a131f360
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Sat Jan 16 10:09:20 2021 +0100

    platform: return a dummy sandbox when the sandbox config can't be satisfied
    
    Instead of an error, a dummy sandbox can be used for checking out an
    artifact for a different OS/arch if integration commands don't need to
    be run.
    
    Fixes #1352
---
 src/buildstream/_platform/platform.py | 37 ++++++++++++-----------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py
index 6af8ebb22..9ecfd26d9 100644
--- a/src/buildstream/_platform/platform.py
+++ b/src/buildstream/_platform/platform.py
@@ -22,7 +22,7 @@ import platform
 
 import psutil
 
-from .._exceptions import PlatformError, ImplError, SandboxError
+from .._exceptions import PlatformError, SandboxError
 from ..sandbox import SandboxDummy
 from .. import utils
 
@@ -39,11 +39,13 @@ class Platform:
         self._setup_sandbox()
 
     def _setup_sandbox(self):
+        from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun  # pylint: disable=cyclic-import
+
         # Try to setup buildbox-run sandbox, otherwise fallback to the dummy sandbox.
         try:
-            self._setup_buildboxrun_sandbox()
+            self._check_sandbox(SandboxBuildBoxRun)
         except (SandboxError, utils.ProgramNotFoundError):
-            self._setup_dummy_sandbox()
+            pass
 
     def _check_sandbox(self, Sandbox):
         Sandbox._dummy_reasons = []
@@ -159,29 +161,16 @@ class Platform:
     #     (Sandbox) A sandbox
     #
     def create_sandbox(self, *args, **kwargs):  # pylint: disable=method-hidden
-        raise ImplError("Platform {platform} does not implement create_sandbox()".format(platform=type(self).__name__))
-
-    # Buildbox run sandbox methods
-    @staticmethod
-    def _create_buildboxrun_sandbox(*args, **kwargs):
         from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun  # pylint: disable=cyclic-import
 
-        SandboxBuildBoxRun.check_sandbox_config(kwargs['config'])
-        return SandboxBuildBoxRun(*args, **kwargs)
-
-    def _setup_buildboxrun_sandbox(self):
-        from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun  # pylint: disable=cyclic-import
-
-        self._check_sandbox(SandboxBuildBoxRun)
-        self.create_sandbox = self._create_buildboxrun_sandbox
-        return True
+        if self.dummy_reasons:
+            dummy_reasons = " and ".join(self.dummy_reasons)
+        else:
+            try:
+                SandboxBuildBoxRun.check_sandbox_config(kwargs["config"])
+                return SandboxBuildBoxRun(*args, **kwargs)
+            except SandboxError as e:
+                dummy_reasons = str(e)
 
-    # Dummy sandbox methods
-    def _create_dummy_sandbox(self, *args, **kwargs):
-        dummy_reasons = " and ".join(self.dummy_reasons)
         kwargs["dummy_reason"] = dummy_reasons
         return SandboxDummy(*args, **kwargs)
-
-    def _setup_dummy_sandbox(self):
-        self.create_sandbox = self._create_dummy_sandbox
-        return True