Commit a256027a authored by Daniele Venzano's avatar Daniele Venzano

Add optional field to specify amount of SHM in bytes

parent 07fdce15
...@@ -129,7 +129,12 @@ ...@@ -129,7 +129,12 @@
"min", "min",
"max" "max"
] ]
} },
"shm_size": {
"type": "number",
"multipleOf": 1.0,
"minimum": 0
},
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
......
...@@ -61,12 +61,17 @@ class ResourceReservation: ...@@ -61,12 +61,17 @@ class ResourceReservation:
def __init__(self, data): def __init__(self, data):
self.memory = ResourceLimits(data['memory'], "bytes") self.memory = ResourceLimits(data['memory'], "bytes")
self.cores = ResourceLimits(data['cores'], 'units') self.cores = ResourceLimits(data['cores'], 'units')
if 'shm' in data:
self.shm = data['shm_size']
else:
self.shm = 0
def __add__(self, other): def __add__(self, other):
if isinstance(other, ResourceReservation): if isinstance(other, ResourceReservation):
res = { res = {
'memory': self.memory + other.memory, 'memory': self.memory + other.memory,
'cores': self.cores + other.cores 'cores': self.cores + other.cores,
'shm': self.shm + other.shm
} }
return ResourceReservation(res) return ResourceReservation(res)
else: else:
......
...@@ -99,7 +99,7 @@ class DockerClient: ...@@ -99,7 +99,7 @@ class DockerClient:
for volume in service_instance.volumes: for volume in service_instance.volumes:
if volume.type == "host_directory": if volume.type == "host_directory":
assert isinstance(volume, VolumeDescriptionHostPath) assert isinstance(volume, VolumeDescriptionHostPath)
run_args['volumes'][volume.path] = {'bind': volume.mount_point, 'mode': ("ro" if volume.readonly else "rw")} run_args['volumes'][volume.path] = {'bi nd': volume.mount_point, 'mode': ("ro" if volume.readonly else "rw")}
else: else:
log.error('Docker backend does not support volume type {}'.format(volume.type)) log.error('Docker backend does not support volume type {}'.format(volume.type))
...@@ -112,6 +112,9 @@ class DockerClient: ...@@ -112,6 +112,9 @@ class DockerClient:
if service_instance.core_limit is not None: if service_instance.core_limit is not None:
run_args['cpu_quota'] = int(100000 * service_instance.core_limit.min) run_args['cpu_quota'] = int(100000 * service_instance.core_limit.min)
if service_instance.shm_size > 0:
run_args['shm_size'] = service_instance.shm_size
if get_conf().gelf_address != '': if get_conf().gelf_address != '':
run_args['log_config'] = { run_args['log_config'] = {
"type": "gelf", "type": "gelf",
......
...@@ -45,6 +45,8 @@ class ServiceInstance: ...@@ -45,6 +45,8 @@ class ServiceInstance:
if self.core_limit.max > get_conf().max_core_limit: if self.core_limit.max > get_conf().max_core_limit:
self.core_limit = get_conf().max_core_limit self.core_limit = get_conf().max_core_limit
self.shm_size = service.resource_reservation.shm
self.labels = { self.labels = {
'zoe.execution.name': execution.name, 'zoe.execution.name': execution.name,
'zoe.execution.id': str(execution.id), 'zoe.execution.id': str(execution.id),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment