Limit cpu and memory used by each storlet container
... to avoid overload caused by applications executed by users. Change-Id: I1157dabe476119af39604fdc30a30b63503ee46a
This commit is contained in:
parent
1a096cdad6
commit
ddf7d26259
|
@ -3,4 +3,4 @@ setuptools>=17.1
|
||||||
eventlet>=0.17.4 # MIT
|
eventlet>=0.17.4 # MIT
|
||||||
greenlet>=0.3.1
|
greenlet>=0.3.1
|
||||||
stevedore>=1.16.0 # Apache-2.0
|
stevedore>=1.16.0 # Apache-2.0
|
||||||
docker
|
docker>=1.5.0 # Apache-2.0
|
||||||
|
|
|
@ -247,6 +247,15 @@ class RunTimeSandbox(object):
|
||||||
self.max_containers_per_node = \
|
self.max_containers_per_node = \
|
||||||
int(conf.get('max_containers_per_node', 0))
|
int(conf.get('max_containers_per_node', 0))
|
||||||
|
|
||||||
|
self.container_cpu_period = int(conf.get('container_cpu_period', 0))
|
||||||
|
self.container_cpu_quota = int(conf.get('container_cpu_quota', 0))
|
||||||
|
self.container_mem_limit = conf.get('container_mem_limit', 0)
|
||||||
|
# NOTE(tkajinam): memory limit can be a string with unit like 1024m
|
||||||
|
try:
|
||||||
|
self.container_mem_limit = int(self.container_mem_limit)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
"""
|
"""
|
||||||
Ping to daemon factory process inside container
|
Ping to daemon factory process inside container
|
||||||
|
@ -348,6 +357,9 @@ class RunTimeSandbox(object):
|
||||||
name=docker_container_name, network_disabled=True,
|
name=docker_container_name, network_disabled=True,
|
||||||
mounts=mounts, user=os.getuid(),
|
mounts=mounts, user=os.getuid(),
|
||||||
auto_remove=True, stop_signal='SIGHUP',
|
auto_remove=True, stop_signal='SIGHUP',
|
||||||
|
cpu_period=self.container_cpu_period,
|
||||||
|
cpu_quota=self.container_cpu_quota,
|
||||||
|
mem_limit=self.container_mem_limit,
|
||||||
labels={'managed_by': 'storlets'})
|
labels={'managed_by': 'storlets'})
|
||||||
except docker.errors.ImageNotFound:
|
except docker.errors.ImageNotFound:
|
||||||
msg = "Image %s is not found" % docker_image_name
|
msg = "Image %s is not found" % docker_image_name
|
||||||
|
|
Loading…
Reference in New Issue