[ARVADOS] updated: 49066b9e703b26671ad4635aa8c1dbb3776ac591
git at public.curoverse.com
git at public.curoverse.com
Thu May 15 08:50:12 EDT 2014
Summary of changes:
.../arvados/v1/keep_disks_controller.rb | 14 ++++++++++++-
services/api/test/integration/keep_proxy_test.rb | 24 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 services/api/test/integration/keep_proxy_test.rb
via 49066b9e703b26671ad4635aa8c1dbb3776ac591 (commit)
from e216c66870a913766fb7a7ab1e6c07cffa784321 (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 49066b9e703b26671ad4635aa8c1dbb3776ac591
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu May 15 08:50:01 2014 -0400
2776: Keep disks controller now looks for X-Need-Keep-Proxy header. If
present, and Rails.application.config.keep_proxy is defined, returns a single
keep disk record with the proxy information.
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 2908cbd..dd3ca3a 100644
--- a/services/api/app/controllers/arvados/v1/keep_disks_controller.rb
+++ b/services/api/app/controllers/arvados/v1/keep_disks_controller.rb
@@ -27,27 +27,39 @@ class Arvados::V1::KeepDisksController < ApplicationController
end
def find_objects_for_index
- # all users can list all keep disks
+ # X-Need-Keep-Proxy indicates the client is outside the cluster subnet and
+ # needs to communicate with Keep via the proxy.
if request.headers['X-Need-Keep-Proxy'] and Rails.application.config.keep_proxy
+ # Build a KeepDisk model from the rails keep_proxy configuration
require 'uri'
u = URI.parse(Rails.application.config.keep_proxy)
kd = KeepDisk.new
+ kd.uuid = "00000-penuu-000000000000000"
kd.service_host = u.hostname
kd.service_port = u.port
kd.service_ssl_flag = (u.scheme == 'https')
@objects = [kd]
+ # Downstream code expects an ActiveRecord model, but we're just providing
+ # an array, so monkeypatch in some stub methods onto @objects so it works
+ # out.
monkeyclass = (class << @objects; self; end)
monkeyclass.class_eval {
attr_accessor :table_name
def order x
+ self
end
def limit x
+ self
+ end
+ def offset x
+ self
end
}
@objects.table_name = table_name
else
+ # all users can list all keep disks
@objects = model_class.where('1=1')
end
diff --git a/services/api/test/integration/keep_proxy_test.rb b/services/api/test/integration/keep_proxy_test.rb
new file mode 100644
index 0000000..dc70f0f
--- /dev/null
+++ b/services/api/test/integration/keep_proxy_test.rb
@@ -0,0 +1,24 @@
+require 'test_helper'
+
+class KeepProxyTest < ActionDispatch::IntegrationTest
+ test "request keep disks" do
+ get "/arvados/v1/keep_disks", {:format => :json}, auth(:active)
+ assert_response :success
+ disks = json_response['items']
+
+ assert_equal 3, disks.length
+ puts "\n", at response.body
+
+ get "/arvados/v1/keep_disks", {:format => :json}, auth(:active).merge({'HTTP_X_NEED_KEEP_PROXY' => true})
+ assert_response :success
+ disks = json_response['items']
+
+ assert_equal 1, disks.length
+ puts "\n", @response.body
+
+ assert_equal disks[0]['uuid'], "00000-penuu-000000000000000"
+ assert_equal disks[0]['service_host'], "localhost"
+ assert_equal disks[0]['service_port'], 25333
+ assert_equal disks[0]['service_ssl_flag'], false
+ end
+end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list