[ARVADOS] created: 874c563b85eaa144930dd0c25dcc0b455003a867
git at public.curoverse.com
git at public.curoverse.com
Sat Nov 29 21:06:06 EST 2014
at 874c563b85eaa144930dd0c25dcc0b455003a867 (commit)
commit 874c563b85eaa144930dd0c25dcc0b455003a867
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Nov 29 21:05:45 2014 -0500
4595: Fix nodes.list?select=[...] crash when is_admin. Also, do not ignore where/limit/order.
diff --git a/services/api/app/controllers/arvados/v1/nodes_controller.rb b/services/api/app/controllers/arvados/v1/nodes_controller.rb
index 0ca5886..efee982 100644
--- a/services/api/app/controllers/arvados/v1/nodes_controller.rb
+++ b/services/api/app/controllers/arvados/v1/nodes_controller.rb
@@ -38,17 +38,16 @@ class Arvados::V1::NodesController < ApplicationController
end
def find_objects_for_index
- if current_user.andand.is_admin || !current_user.andand.is_active
- super
- else
+ if !current_user.andand.is_admin && current_user.andand.is_active
# active non-admin users can list nodes that are (or were
# recently) working
@objects = model_class.where('last_ping_at >= ?', Time.now - 1.hours)
end
- assigned_nodes = @objects.select(&:job_uuid)
- assoc_jobs = readable_job_uuids(*assigned_nodes.map(&:job_uuid))
- assigned_nodes.each do |node|
- node.job_readable = assoc_jobs.include?(node.job_uuid)
+ super
+ job_uuids = @objects.map { |n| n[:job_uuid] }.compact
+ assoc_jobs = readable_job_uuids(job_uuids)
+ @objects.each do |node|
+ node.job_readable = assoc_jobs.include?(node[:job_uuid])
end
end
diff --git a/services/api/test/functional/arvados/v1/nodes_controller_test.rb b/services/api/test/functional/arvados/v1/nodes_controller_test.rb
index d744505..7ea231e 100644
--- a/services/api/test/functional/arvados/v1/nodes_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/nodes_controller_test.rb
@@ -108,6 +108,14 @@ class Arvados::V1::NodesControllerTest < ActionController::TestCase
assert_nil(json_response["job"], "spectator can see node's assigned job")
end
+ [:admin, :spectator].each do |user|
+ test "select param does not break node list for #{user}" do
+ authorize_with user
+ get :index, {select: ['domain']}
+ assert_response :success
+ end
+ end
+
test "admin can associate a job with a node" do
changed_node = nodes(:idle)
assigned_job = jobs(:queued)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list