X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8994f77f368ee813738f4406f68239bc4013e20e..45da0e8226577f64ec397f0af03e6a46fc8cb386:/services/api/app/controllers/arvados/v1/keep_disks_controller.rb diff --git a/services/api/app/controllers/arvados/v1/keep_disks_controller.rb b/services/api/app/controllers/arvados/v1/keep_disks_controller.rb index 2b9d5b5db2..31327ad93b 100644 --- a/services/api/app/controllers/arvados/v1/keep_disks_controller.rb +++ b/services/api/app/controllers/arvados/v1/keep_disks_controller.rb @@ -5,32 +5,35 @@ class Arvados::V1::KeepDisksController < ApplicationController { uuid: false, ping_secret: true, - ec2_instance_id: false, - local_ipv4: false, + node_uuid: false, filesystem_uuid: false, + service_host: false, service_port: true, service_ssl_flag: true } end def ping - if !@object and params[:filesystem_uuid] and current_user and current_user.is_admin - if KeepDisk.where('filesystem_uuid=?', params[:filesystem_uuid]).empty? - @object = KeepDisk.new filesystem_uuid: params[:filesystem_uuid] + if !@object + if current_user.andand.is_admin + @object = KeepDisk.new(filesystem_uuid: params[:filesystem_uuid]) @object.save! + + # In the first ping from this new filesystem_uuid, we can't + # expect the keep node to know the ping_secret so we made sure + # we got an admin token. Here we add ping_secret to params so + # KeepNode.ping() understands this update is properly + # authenticated. params[:ping_secret] = @object.ping_secret else - raise "ping from keep_disk with existing filesystem_uuid #{params[:filesystem_uuid]} but wrong uuid #{params[:uuid]}" + return render_not_found "object not found" end end - if !@object + params[:service_host] ||= request.env['REMOTE_ADDR'] + if not @object.ping params return render_not_found "object not found" end - - params.merge!(service_host: - params[:local_ipv4] || request.env['REMOTE_ADDR']) - @object.ping params - show + render json: @object.as_api_response(:superuser) end def find_objects_for_index