[ARVADOS] created: 74b5dd2b6f4a33b06b136fd587408ec3d4e42ec0
Git user
git at public.curoverse.com
Wed Aug 24 15:08:18 EDT 2016
at 74b5dd2b6f4a33b06b136fd587408ec3d4e42ec0 (commit)
commit 74b5dd2b6f4a33b06b136fd587408ec3d4e42ec0
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Wed Aug 24 16:05:27 2016 -0300
9687: For a ContainerRequest being committed, if its container has the state "Complete" but exit_code not zero, return "Failed" as a state_label so that Workbench won't render its status as "Complete". Added fixture & test to check for this correction.
diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb
index 4f4c915..43871c5 100644
--- a/apps/workbench/app/models/container_work_unit.rb
+++ b/apps/workbench/app/models/container_work_unit.rb
@@ -75,7 +75,14 @@ class ContainerWorkUnit < ProxyWorkUnit
end
def state_label
- get_combined(:state)
+ if @proxied.is_a? ContainerRequest and
+ get(:state) == "Committed" and
+ get(:state, @container) == "Complete" and
+ get(:exit_code, @container) != 0
+ "Failed"
+ else
+ get_combined(:state)
+ end
end
def docker_image
diff --git a/apps/workbench/test/unit/work_unit_test.rb b/apps/workbench/test/unit/work_unit_test.rb
index c737982..236e7a2 100644
--- a/apps/workbench/test/unit/work_unit_test.rb
+++ b/apps/workbench/test/unit/work_unit_test.rb
@@ -35,6 +35,13 @@ class WorkUnitTest < ActiveSupport::TestCase
end
end
+ test "state_label should be Failed if container exit_code not 0" do
+ use_token 'active'
+ obj = find_fixture(ContainerRequest, 'cr_for_failed')
+ wu = obj.work_unit
+ assert_equal "Failed", wu.state_label
+ end
+
[
[Job, 'running_job_with_components', 1, 1, nil],
[Job, 'queued', nil, nil, 1],
diff --git a/services/api/test/fixtures/container_requests.yml b/services/api/test/fixtures/container_requests.yml
index de41ff0..e9b3fd4 100644
--- a/services/api/test/fixtures/container_requests.yml
+++ b/services/api/test/fixtures/container_requests.yml
@@ -151,6 +151,25 @@ running_anonymous_accessible:
vcpus: 1
ram: 123
+cr_for_failed:
+ uuid: zzzzz-xvhdp-cr4failedcontnr
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ name: cr for container exit code not 0
+ state: Committed
+ priority: 1
+ 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-failedcntnr
+ runtime_constraints:
+ vcpus: 1
+ ram: 123
+
# Test Helper trims the rest of the file
# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 79e472b..f9d18be 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -134,3 +134,20 @@ requester_container:
ram: 12000000000
vcpus: 4
auth_uuid: zzzzz-gj3su-077z32aux8dg2s1
+
+failed_container:
+ uuid: zzzzz-dz642-failedcntnr
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ state: Complete
+ exit_code: 33
+ priority: 1
+ created_at: 2016-01-11 11:11:11.111111111 Z
+ updated_at: 2016-01-11 11:11:11.111111111 Z
+ container_image: test
+ cwd: test
+ output: test
+ output_path: test
+ command: ["echo", "hello"]
+ runtime_constraints:
+ ram: 12000000000
+ vcpus: 4
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list