Commit 64e2fa8d authored by Daniele Venzano's avatar Daniele Venzano

Add an option to the Zoe scheduler to configure container log message...

Add an option to the Zoe scheduler to configure container log message destination. GELF-formatted logs will be sent to the specified destination.
parent ddcbf9f3
......@@ -26,6 +26,7 @@ except ImportError:
import docker
import docker.errors
import docker.utils
from zoe_scheduler.stats import SwarmStats, SwarmNodeStats, ContainerStats
from zoe_lib.exceptions import ZoeException
......@@ -118,13 +119,19 @@ class SwarmClient:
for port in options.ports:
port_bindings[port] = None
if options.gelf_log_address != '':
log_config = docker.utils.LogConfig(type="gelf", config={'gelf-address': options.gelf_log_address, 'labels': ",".join(options.labels)})
else:
log_config = docker.utils.LogConfig(type="json-file")
try:
host_config = self.cli.create_host_config(network_mode=options.network_name,
binds=options.get_volume_binds(),
mem_limit=options.get_memory_limit(),
memswap_limit=options.get_memory_limit(),
restart_policy=options.restart_policy,
port_bindings=port_bindings)
port_bindings=port_bindings,
log_config=log_config)
cont = self.cli.create_container(image=image,
environment=options.environment,
network_disabled=False,
......@@ -287,6 +294,7 @@ class ContainerOptions:
self.network_name = 'bridge'
self.restart = True
self.labels = []
self.gelf_log_address = ''
def add_env_variable(self, name, value):
if value is not None:
......
......@@ -48,6 +48,7 @@ def load_configuration(test_conf=None):
argparser.add_argument('--influxdb-url', help='URL of the InfluxDB service (ex. http://localhost:8086)', default='http://localhost:8086')
argparser.add_argument('--influxdb-enable', action="store_true", help='Enable metric output toward influxDB')
argparser.add_argument('--passlib-rounds', type=int, help='Number of hashing rounds for passwords', default=60000)
argparser.add_argument('--gelf-address', help='Enable Docker GELF log output to this destination (ex. udp://1.2.3.4:1234)', default='')
opts = argparser.parse_args()
if opts.debug:
......
......@@ -59,6 +59,7 @@ class PlatformManager:
def _spawn_process(self, execution: execution_module.Execution, process_description: application_module.Process) -> bool:
copts = ContainerOptions()
copts.gelf_log_address = get_conf().gelf_address
copts.name = get_conf().container_name_prefix + '-' + process_description.name + "-{}".format(execution.owner.name)
copts.set_memory_limit(process_description.required_resources['memory'])
copts.network_name = '{}-usernet-{}'.format(get_conf().container_name_prefix, execution.owner.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