Skip to content

Commit

Permalink
Possible fix for node exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
oldpatricka committed Dec 21, 2012
1 parent 671a665 commit 5c6632f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions epu/processdispatcher/core.py
Expand Up @@ -507,41 +507,43 @@ def ee_heartbeat(self, sender, beat):
new_assigned.append(key)

if len(new_assigned) != len(resource.assigned):
log.debug("updating resource %s assignments. was %s, now %s",
resource.resource_id, resource.assigned, new_assigned)
resource.assigned = new_assigned
try:
self.store.update_resource(resource)
except (WriteConflictError, NotFoundError):
#TODO? right now this will just wait for the next heartbeat
pass

node = self.store.get_node(resource.node_id)
if not node:
msg = "Node %s doesn't exist, but you want to set node_exclusive?" % (
resource.node_id)
log.warning(msg)
return


new_node_exclusive = []
for resource_id in node.resources:
resource = self.store.get_resource(resource_id)
for owner, upid, round in resource.assigned:
for owner, upid, round in new_assigned:
process = self.store.get_process(owner, upid)
if process.node_exclusive:
new_node_exclusive.append(process.node_exclusive)

log.debug("PDA: updating node %s node_exclusive. was %s, now %s" %
log.debug("updating node %s node_exclusive. was %s, now %s" %
(node.node_id, node.node_exclusive, new_node_exclusive))

node.node_exclusive = new_node_exclusive

try:
self.store.update_node(node)
except (WriteConflictError, NotFoundError):
#TODO? right now this will just wait for the next heartbeat
pass

log.debug("updating resource %s assignments. was %s, now %s",
resource.resource_id, resource.assigned, new_assigned)

resource.assigned = new_assigned
try:
self.store.update_resource(resource)
except (WriteConflictError, NotFoundError):
#TODO? right now this will just wait for the next heartbeat
pass


def _first_heartbeat(self, sender, beat):

node_id = beat.get('node_id')
Expand Down

0 comments on commit 5c6632f

Please sign in to comment.