Commit 0ad81e0b authored by Swann Perarnau's avatar Swann Perarnau

[fix] export downstream_event_uri in container

If monitoring is active, make sure to export the
ARGO_NRM_DOWNSTREAM_EVENT_URI variable required by libnrm.

Fix #49.
parent e0d0abb4
......@@ -30,7 +30,8 @@ class ContainerManager(object):
def __init__(self, container_runtime, rm,
perfwrapper="nrm-perfwrapper",
linuxperf="perf",
pmpi_lib="/usr/lib/libnrm-pmpi.so"):
pmpi_lib="/usr/lib/libnrm-pmpi.so",
downstream_event_uri="ipc:///tmp/nrm-downstream-event"):
self.linuxperf = linuxperf
self.perfwrapper = perfwrapper
self.runtime = container_runtime
......@@ -40,6 +41,7 @@ class ContainerManager(object):
self.hwloc = rm.hwloc
self.chrt = ChrtClient()
self.pmpi_lib = pmpi_lib
self.downstream_event_uri = downstream_event_uri
def _get_container_tuple(self, container_name, manifest):
"""Retrieve a container tuple if the container exists, otherwise use
......@@ -133,6 +135,11 @@ class ContainerManager(object):
environ['ARGO_NRM_RATELIMIT'] = \
manifest.app.isolators.monitoring.ratelimit
if container.power.get('policy') or \
manifest.is_feature_enabled('monitoring'):
environ['ARGO_NRM_DOWNSTREAM_EVENT_URI'] = \
self.downstream_event_uri
# build prefix to the entire command based on enabled features
argv = []
if manifest.is_feature_enabled('scheduler'):
......
......@@ -321,7 +321,8 @@ class Daemon(object):
perfwrapper=self.config.argo_perf_wrapper,
linuxperf=self.config.perf,
pmpi_lib=self.config.pmpi_lib,
)
downstream_event_uri=downstream_event_param,
)
self.application_manager = ApplicationManager()
self.sensor_manager = SensorManager()
pa = PowerActuator(self.sensor_manager)
......
......@@ -154,8 +154,17 @@ class SingularityClient(object):
singularity exec --bind ... container.sif <command>"""
args = [self.prefix] # singularity
args.extend(['exec', '--bind', '/tmp/nrm-downstream-event',
container_image])
args.append('exec')
# if the monitoring is active, and is a file, we need to bind it into
# the container
uri = environ.get('ARGO_NRM_DOWNSTREAM_EVENT_URI')
if uri:
is_file = uri.startswith('ipc://')
if is_file:
bind_arg = uri[6:]
args.extend(['--bind', bind_arg])
args.append(container_image)
args.extend(argv)
return process.Subprocess(args, env=environ,
stdout=process.Subprocess.STREAM,
......
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