Set cache expiry time on discovery document.
[arvados.git] / services / api / app / controllers / arvados / v1 / nodes_controller.rb
index 33c7ea7e240102ffca6cec91cb5c934d4eeb5d7c..d04448229cd7e6de158970aa7fd0fbf32eb7c358 100644 (file)
@@ -15,15 +15,20 @@ class Arvados::V1::NodesController < ApplicationController
     @object.ping({ ip: params[:local_ipv4] || request.env['REMOTE_ADDR'],
                    ping_secret: params[:ping_secret],
                    ec2_instance_id: params[:instance_id] })
-    show
+    if @object.info[:ping_secret] == params[:ping_secret]
+      render json: @object.as_api_response(:superuser)
+    else
+      raise "Invalid ping_secret after ping"
+    end
   end
 
-  def index
-    if current_user.andand.is_admin
+  def find_objects_for_index
+    if current_user.andand.is_admin || !current_user.andand.is_active
       super
     else
+      # active non-admin users can list nodes that are (or were
+      # recently) working
       @objects = model_class.where('last_ping_at >= ?', Time.now - 1.hours)
-      render_list
     end
   end
 end