From b781e22ea6be76ece696c80de6b59ae223f3a06f Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 9 Dec 2015 16:02:53 -0500 Subject: [PATCH] 6429: Don't update priority if the container is already in Complete or Cancelled state. --- services/api/app/models/container.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index 79c9868189..903f392dd6 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -57,16 +57,18 @@ class Container < ArvadosModel end def update_priority! - # Update the priority of this container to the maximum priority of any of - # its committed container requests and save the record. - max = 0 - ContainerRequest.where(container_uuid: uuid).each do |cr| - if cr.state == ContainerRequest::Committed and cr.priority > max - max = cr.priority + if [Queued, Running].include? self.state + # Update the priority of this container to the maximum priority of any of + # its committed container requests and save the record. + max = 0 + ContainerRequest.where(container_uuid: uuid).each do |cr| + if cr.state == ContainerRequest::Committed and cr.priority > max + max = cr.priority + end end + self.priority = max + self.save! end - self.priority = max - self.save! end protected -- 2.30.2