This is an automated email from the ASF dual-hosted git repository. not-in-ldap pushed a commit to branch aevri/enable_spawn_ci_7 in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit e29746c7493b69baa55e082bab55ac18523f1bfe Author: Angelos Evripiotis <[email protected]> AuthorDate: Tue Oct 29 10:08:49 2019 +0000 WIP: sandbox bwrap state This is probably going to need a more substantial refactor - the job pickler probably shouldn't be reaching into the individual sandboxes classes like this. Ideally the state would be stored somewhere more accessible than class attributes. --- src/buildstream/_scheduler/jobs/jobpickler.py | 10 ++++++-- src/buildstream/sandbox/_sandboxbwrap.py | 34 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/buildstream/_scheduler/jobs/jobpickler.py b/src/buildstream/_scheduler/jobs/jobpickler.py index b0465ec..ce8e4a6 100644 --- a/src/buildstream/_scheduler/jobs/jobpickler.py +++ b/src/buildstream/_scheduler/jobs/jobpickler.py @@ -56,9 +56,11 @@ def pickle_child_job(child_job, projects): # Note that we need to consider all the state of the program that's # necessary for the job, this includes e.g. the global state of the node # module. + from ...sandbox._sandboxbwrap import SandboxBwrap + sandbox_bwrap_state = SandboxBwrap.save_check_available_status() node_module_state = node._get_state_for_pickling() return _pickle_child_job_data( - (child_job, node_module_state), + (child_job, node_module_state, sandbox_bwrap_state), projects, ) @@ -77,8 +79,12 @@ def pickle_child_job(child_job, projects): def do_pickled_child_job(pickled, *child_args): utils._is_main_process = _not_main_process - child_job, node_module_state = pickle.load(pickled) + child_job, node_module_state, sandbox_bwrap_state = pickle.load(pickled) node._set_state_from_pickling(node_module_state) + + from ...sandbox._sandboxbwrap import SandboxBwrap + SandboxBwrap.load_check_available_status(sandbox_bwrap_state) + return child_job.child_action(*child_args) diff --git a/src/buildstream/sandbox/_sandboxbwrap.py b/src/buildstream/sandbox/_sandboxbwrap.py index bd60eaf..7911c59 100644 --- a/src/buildstream/sandbox/_sandboxbwrap.py +++ b/src/buildstream/sandbox/_sandboxbwrap.py @@ -92,6 +92,40 @@ class SandboxBwrap(Sandbox): cls.user_ns_available = cls._check_user_ns_available() + @classmethod + def save_check_available_status(cls): + # Note, these ones only get set if bwrap is available: + # + # cls._uid = os.geteuid() + # cls._gid = os.getegid() + # cls.user_ns_available = cls._check_user_ns_available() + # + return ( + cls._bwrap_exists, + cls._die_with_parent_available, + cls._dummy_reasons, + cls._gid, + cls._have_fuse, + cls._have_good_bwrap, + cls._json_status_available, + cls._uid, + cls.user_ns_available, + ) + + @classmethod + def load_check_available_status(cls, state): + ( + cls._bwrap_exists, + cls._die_with_parent_available, + cls._dummy_reasons, + cls._gid, + cls._have_fuse, + cls._have_good_bwrap, + cls._json_status_available, + cls._uid, + cls.user_ns_available, + ) = state + @staticmethod def _check_user_ns_available(): # Here, lets check if bwrap is able to create user namespaces,
