Commit 93ae9144 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[fix] ensure container has single owner

Ensure that the client that created the container is considered as the
one owning it, with the consequence that if its command exits, the
container is destroyed. Also deals with the race issue we had on the cmd
parent 6e0c1e7a
......@@ -25,6 +25,7 @@ logger = logging.getLogger('nrm')
class Daemon(object):
def __init__(self): = 100.0
self.container_owner = dict()
def do_downstream_receive(self, parts):"receiving downstream message: %r", parts)
......@@ -107,6 +108,7 @@ class Daemon(object):
self.container_owner[container.uuid] = client
# now deal with the process itself
update = {'api': 'up_rpc_rep',
......@@ -213,7 +215,9 @@ class Daemon(object):"Process %s in Container %s has finised.",
pid, container.uuid)
if not container.processes:
# if this process was owner of the container,
# kill everything
if self.container_owner[container.uuid] == clientid:
# deal with container exit
msg = {'api': 'up_rpc_rep',
'type': 'exit',
......@@ -240,6 +244,7 @@ class Daemon(object):
RPC_MSG['exit'](**msg), clientid)
del self.container_owner[container.uuid]
logger.debug("child update ignored")
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