Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Disable GLambda for a misconfigured platform (#4449)
Browse files Browse the repository at this point in the history
  • Loading branch information
mplebanski authored Jul 10, 2019
1 parent b9ca5e1 commit f45c31a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
31 changes: 27 additions & 4 deletions apps/glambda/glambdaenvironment.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import filecmp
import logging
import shutil
from typing import Dict

from golem.core.common import is_linux
from golem.docker.environment import DockerEnvironment
from golem.environments.environment import SupportStatus, UnsupportReason

logger = logging.getLogger(__name__)


class GLambdaTaskEnvironment(DockerEnvironment):
DOCKER_IMAGE = "golemfactory/glambda"
Expand All @@ -14,12 +18,31 @@ class GLambdaTaskEnvironment(DockerEnvironment):

def check_support(self) -> SupportStatus:
GVISOR_SECURE_RUNTIME = 'runsc'
if is_linux() and not shutil.which(GVISOR_SECURE_RUNTIME):
return SupportStatus.err({
UnsupportReason.ENVIRONMENT_NOT_SECURE: self.ENV_ID
})
if is_linux():
if not shutil.which(GVISOR_SECURE_RUNTIME):
return SupportStatus.err({
UnsupportReason.ENVIRONMENT_NOT_SECURE: self.ENV_ID
})
if not GLambdaTaskEnvironment._is_cgroup_cpuset_cfg_correct():
logger.warning('Unable to start GLambda app. Setting '
'`cgroup.cpuset.cpus` does not match `docker.'
'cpuset.cpus`. Potential fix: `cat /sys/fs/'
'cgroup/cpuset/cpuset.cpus > /sys/fs/cgroup/'
'cpuset/docker/cpuset.cpus`.')
return SupportStatus.err({
UnsupportReason.ENVIRONMENT_MISCONFIGURED: self.ENV_ID
})
return super().check_support()

@staticmethod
def _is_cgroup_cpuset_cfg_correct():
try:
res = filecmp.cmp('/sys/fs/cgroup/cpuset/cpuset.cpus',
'/sys/fs/cgroup/cpuset/docker/cpuset.cpus')
except FileNotFoundError:
return False
return res

def get_container_config(self) -> Dict:
return dict(
runtime='runsc' if is_linux() else None,
Expand Down
1 change: 1 addition & 0 deletions golem/environments/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class UnsupportReason(enum.Enum):
ENVIRONMENT_UNSUPPORTED = 'environment_unsupported'
ENVIRONMENT_NOT_ACCEPTING_TASKS = 'environment_not_accepting_tasks'
ENVIRONMENT_NOT_SECURE = 'environment_not_secure'
ENVIRONMENT_MISCONFIGURED = 'environment_misconfigured'
MAX_PRICE = 'max_price'
APP_VERSION = 'app_version'
DENY_LIST = 'deny_list'
Expand Down

0 comments on commit f45c31a

Please sign in to comment.