Skip to content
Snippets Groups Projects
Commit 49020b32 authored by knownexus's avatar knownexus Committed by Phillip Smyth
Browse files

Artifact caches are now defined in platform.py

This was done so a default exists, but allows platforms to override as needed

_platform/platform.py: Added CAS call function

_platform/linux.py: Added override to CAS call
_platform/unix.py: Remove CAS call
parent 454b1aaf
No related branches found
No related tags found
No related merge requests found
......@@ -33,15 +33,16 @@ class Linux(Platform):
def __init__(self, context):
super().__init__(context)
self._die_with_parent_available = _site.check_bwrap_version(0, 1, 8)
if self._local_sandbox_available():
self._user_ns_available = self._check_user_ns_available(context)
else:
self._user_ns_available = False
self._artifact_cache = CASCache(context, enable_push=self._user_ns_available)
# _user_ns_available needs to be set before chaining up to the super class
# This is because it will call create_artifact_cache()
super().__init__(context)
@property
def artifactcache(self):
......@@ -53,6 +54,9 @@ class Linux(Platform):
kwargs['die_with_parent_available'] = self._die_with_parent_available
return SandboxBwrap(*args, **kwargs)
def create_artifact_cache(self, context, *, enable_push):
return super().create_artifact_cache(context=context, enable_push=self._user_ns_available)
################################################
# Private Methods #
################################################
......
......@@ -22,6 +22,7 @@ import sys
import resource
from .._exceptions import PlatformError, ImplError
from .._artifactcache.cascache import CASCache
class Platform():
......@@ -39,6 +40,7 @@ class Platform():
def __init__(self, context):
self.context = context
self.set_resource_limits()
self._artifact_cache = self.create_artifact_cache(context, enable_push=True)
@classmethod
def create_instance(cls, *args, **kwargs):
......@@ -109,3 +111,6 @@ class Platform():
if hard_limit is None:
hard_limit = limits[1]
resource.setrlimit(resource.RLIMIT_NOFILE, (soft_limit, hard_limit))
def create_artifact_cache(self, context, *, enable_push=True):
return CASCache(context=context, enable_push=enable_push)
......@@ -31,7 +31,6 @@ class Unix(Platform):
def __init__(self, context):
super().__init__(context)
self._artifact_cache = CASCache(context)
# Not necessarily 100% reliable, but we want to fail early.
if os.geteuid() != 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment