[ARVADOS] updated: de4cfeaab629e99014deb10792637649511c91d0
Git user
git at public.curoverse.com
Fri Sep 9 15:17:43 EDT 2016
Summary of changes:
services/api/app/models/container.rb | 28 +++++++-----
services/api/test/fixtures/container_requests.yml | 53 +++++++++++++++++++++++
services/api/test/unit/container_request_test.rb | 2 +-
3 files changed, 70 insertions(+), 13 deletions(-)
via de4cfeaab629e99014deb10792637649511c91d0 (commit)
via f72506f1056aa4e867c6a0ff68a815bd55244536 (commit)
via 1b4bfe1a002732b1e9246be8b2679fec0a262202 (commit)
from 4eef0a298418a751b5941fd6f4bf32d91b817d54 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit de4cfeaab629e99014deb10792637649511c91d0
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Fri Sep 9 12:35:45 2016 -0300
9623: Added CR fixtures to make services/crunch-dispatch-local tests run OK again.
diff --git a/services/api/test/fixtures/container_requests.yml b/services/api/test/fixtures/container_requests.yml
index 433aff2..aa0a125 100644
--- a/services/api/test/fixtures/container_requests.yml
+++ b/services/api/test/fixtures/container_requests.yml
@@ -16,6 +16,59 @@ queued:
runtime_constraints:
vcpus: 1
ram: 123
+ mounts:
+ test:
+ kind: json
+ environment:
+ var: queued
+
+queued_higher_priority:
+ uuid: zzzzz-xvhdp-cr4queuedcontnrhigher
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ name: queued_hp
+ state: Committed
+ priority: 2
+ created_at: 2016-01-11 11:11:11.111111111 Z
+ updated_at: 2016-01-11 11:11:11.111111111 Z
+ modified_at: 2016-01-11 11:11:11.111111111 Z
+ modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ container_image: test
+ cwd: test
+ output_path: test
+ command: ["echo", "hello"]
+ container_uuid: zzzzz-dz642-queuedcontainerhigher
+ runtime_constraints:
+ vcpus: 1
+ ram: 123
+ mounts:
+ test:
+ kind: json
+ environment:
+ var: queued
+
+locked_vs_queued_loser:
+ uuid: zzzzz-xvhdp-cr4lockedvsqueuedloser
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ name: lockedvqueuedloser
+ state: Committed
+ priority: 2
+ created_at: 2016-01-11 11:11:11.111111111 Z
+ updated_at: 2016-01-11 11:11:11.111111111 Z
+ modified_at: 2016-01-11 11:11:11.111111111 Z
+ modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ container_image: test
+ cwd: test
+ output_path: test
+ command: ["echo", "hello"]
+ container_uuid: zzzzz-dz642-lvqloser
+ runtime_constraints:
+ vcpus: 1
+ ram: 123
+ mounts:
+ test:
+ kind: json
+ environment:
+ var: locked_vs_queued
running:
uuid: zzzzz-xvhdp-cr4runningcntnr
commit f72506f1056aa4e867c6a0ff68a815bd55244536
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Thu Sep 8 18:54:41 2016 -0300
9623: Fixed test by avoiding Container reusability when calling create_minimal_req! multiple times with the same attributes.
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 3ab4a89..a92663e 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -242,7 +242,7 @@ class ContainerRequestTest < ActiveSupport::TestCase
c = Container.find_by_uuid cr.container_uuid
assert_equal 5, c.priority
- cr2 = create_minimal_req!(priority: 10, state: "Committed", requesting_container_uuid: c.uuid)
+ cr2 = create_minimal_req!(priority: 10, state: "Committed", requesting_container_uuid: c.uuid, command: ["echo", "foo2"])
c2 = Container.find_by_uuid cr2.container_uuid
assert_equal 10, c2.priority
commit 1b4bfe1a002732b1e9246be8b2679fec0a262202
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Thu Sep 8 18:52:50 2016 -0300
9623: Cleaned up references to local constants about Container's states. Added optimizations on the serialized attributes sorting.
diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index 2d3402f..558e8d1 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -86,11 +86,9 @@ class Container < ArvadosModel
where('container_image = ?', attrs[:container_image]).
where('mounts = ?', self.deep_sort_hash(attrs[:mounts]).to_yaml).
where('runtime_constraints = ?', self.deep_sort_hash(attrs[:runtime_constraints]).to_yaml).
- where('state in (?)', [Container::Queued, Container::Locked,
- Container::Running, Container::Complete]).
- reject {|c| c.state == Container::Complete and (c.exit_code != 0 or
- c.output.nil? or
- c.log.nil?)}
+ where('state in (?)', [Queued, Locked, Running, Complete]).
+ reject {|c| c.state == Complete and
+ (c.exit_code != 0 or c.output.nil? or c.log.nil?)}
if candidates.empty?
nil
elsif candidates.count == 1
@@ -98,19 +96,19 @@ class Container < ArvadosModel
else
# Multiple candidates found, search for the best one:
# The most recent completed container
- winner = candidates.select {|c| c.state == Container::Complete}.
+ winner = candidates.select {|c| c.state == Complete}.
sort_by {|c| c.finished_at}.last
return winner if not winner.nil?
# The running container that's most likely to finish sooner.
- winner = candidates.select {|c| c.state == Container::Running}.
+ winner = candidates.select {|c| c.state == Running}.
sort {|a, b| [b.progress, a.started_at] <=> [a.progress, b.started_at]}.first
return winner if not winner.nil?
# The locked container that's most likely to start sooner.
- winner = candidates.select {|c| c.state == Container::Locked}.
+ winner = candidates.select {|c| c.state == Locked}.
sort {|a, b| [b.priority, a.created_at] <=> [a.priority, b.created_at]}.first
return winner if not winner.nil?
# The queued container that's most likely to start sooner.
- winner = candidates.select {|c| c.state == Container::Queued}.
+ winner = candidates.select {|c| c.state == Queued}.
sort {|a, b| [b.priority, a.created_at] <=> [a.priority, b.created_at]}.first
return winner if not winner.nil?
end
@@ -253,9 +251,15 @@ class Container < ArvadosModel
end
def sort_serialized_attrs
- self.environment = self.class.deep_sort_hash(self.environment)
- self.mounts = self.class.deep_sort_hash(self.mounts)
- self.runtime_constraints = self.class.deep_sort_hash(self.runtime_constraints)
+ if self.environment_changed?
+ self.environment = self.class.deep_sort_hash(self.environment)
+ end
+ if self.mounts_changed?
+ self.mounts = self.class.deep_sort_hash(self.mounts)
+ end
+ if self.runtime_constraints_changed?
+ self.runtime_constraints = self.class.deep_sort_hash(self.runtime_constraints)
+ end
end
def handle_completed
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list