Skip to content

Commit

Permalink
Fixed bug in EPUM instance state handling
Browse files Browse the repository at this point in the history
De-duped state comparision code to simplify
  • Loading branch information
labisso committed Feb 14, 2013
1 parent a88504a commit 877d797
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions epu/epumanagement/reactor.py
Expand Up @@ -246,10 +246,7 @@ def new_instance_state(self, content):
log.debug("Got state %s for instance '%s'", state, instance_id)

instance = domain.get_instance(instance_id)
instance_counter = instance.get('update_counter')
content_counter = content.get('update_counter')
if instance is None or instance_counter is None or instance_counter < content_counter:
domain.new_instance_state(content, previous=instance)
if domain.new_instance_state(content, previous=instance):

# The higher level clients of EPUM only see RUNNING or FAILED (or nothing)
if content['state'] < InstanceState.RUNNING:
Expand Down
5 changes: 5 additions & 0 deletions epu/epumanagement/store.py
Expand Up @@ -330,6 +330,8 @@ def get_engine_state(self):

def new_instance_state(self, content, timestamp=None, previous=None):
"""Introduce a new instance state from an incoming message
returns True/False indicating whether instance state was accepted
"""
instance_id = self.instance_parser.parse_instance_id(content)
if instance_id:
Expand All @@ -339,6 +341,9 @@ def new_instance_state(self, content, timestamp=None, previous=None):
timestamp=timestamp)
if instance:
self.update_instance(instance, previous=previous)
return True
# instance was probably a duplicate
return False

def new_instance_launch(self, deployable_type_id, instance_id, launch_id, site, allocation,
extravars=None, timestamp=None):
Expand Down

0 comments on commit 877d797

Please sign in to comment.