GitLab maintenance scheduled for Today, 2019-12-05, from 17:00 to 18:00 CT - Services will be unavailable during this time.

Commit dca6debb authored by Swann Perarnau's avatar Swann Perarnau

[fix] restore the use of resources tuple

!27 replaced the resource field of the `container` named tuple by a
dictionary. Restore the old type, a `resources` named tuple and make
sure to propagate this across all the code.
parent eb7c6380
......@@ -88,7 +88,7 @@ class ApplicationManager(object):
phase_contexts = dict()
phase_context_keys = ['set', 'aggregation', 'computetime', 'totaltime']
if container.power['policy']:
ids = container.resources['cpus']
ids = container.resources.cpus
for id in ids:
phase_contexts[id] = dict.fromkeys(phase_context_keys)
phase_contexts[id]['set'] = False
......
......@@ -46,11 +46,8 @@ class ContainerManager(object):
ncpus = int(manifest.app.isolators.container.cpus.value)
nmems = int(manifest.app.isolators.container.mems.value)
req = resources(ncpus, nmems)
alloc = self.resourcemanager.schedule(container_name, req)
logger.info("create: allocation: %r", alloc)
container_resources = dict()
container_resources['cpus'], container_resources['mems'] = alloc
allocated = self.resourcemanager.schedule(container_name, req)
logger.info("create: allocation: %r", allocated)
# Container power settings
container_power = dict()
......@@ -75,10 +72,9 @@ class ContainerManager(object):
hwbindings = dict()
if manifest.is_feature_enabled('hwbind'):
hwbindings['distrib'] = sorted(self.hwloc.distrib(
ncpus, alloc), key=operator.
ncpus, allocated), key=operator.
attrgetter('cpus'))
return (True, Container(container_name, manifest,
container_resources,
return (True, Container(container_name, manifest, allocated,
container_power, {}, {}, hwbindings))
def create(self, request):
......@@ -105,9 +101,7 @@ class ContainerManager(object):
manifest)
if creation_needed:
logger.info("Creating container %s", container_name)
req = resources(container.resources['cpus'],
container.resources['mems'])
self.nodeos.create(container_name, req)
self.nodeos.create(container_name, container.resources)
self.containers[container_name] = container
# build context to execute
......
......@@ -126,7 +126,7 @@ class Controller(object):
def run_policy_container(self, container, application):
"""Run policies on a container."""
ids = container.resources['cpus']
ids = container.resources.cpus
pcs = application.phase_contexts
# Run policy only if all phase contexts have been received
if not filter(lambda i: not pcs[i]['set'], ids):
......
......@@ -98,7 +98,7 @@ class Daemon(object):
if len(container.processes) == 1:
if container.power['policy']:
container.power['manager'] = PowerPolicyManager(
container.resources['cpus'],
container.resources.cpus,
container.power['policy'],
float(container.power['damper']),
float(container.power['slowdown']))
......
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