diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-10-29 10:08:49 +0000 |
---|---|---|
committer | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-10-29 17:28:48 +0000 |
commit | e29746c7493b69baa55e082bab55ac18523f1bfe (patch) | |
tree | d4ba60612d64303e6d2a9c16c912d0a300d6d5ab | |
parent | b01efd5b1a3875237df243cb3ee75b3feba5cb80 (diff) | |
download | buildstream-e29746c7493b69baa55e082bab55ac18523f1bfe.tar.gz |
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.
-rw-r--r-- | src/buildstream/_scheduler/jobs/jobpickler.py | 10 | ||||
-rw-r--r-- | 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 b0465ec9e..ce8e4a687 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 bd60eafc1..7911c59f9 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, |