[ARVADOS] created: 3bbe6cfeb45325554c97c674770ca64f2d367b83

Git user git at public.curoverse.com
Mon Jul 17 16:46:27 EDT 2017


        at  3bbe6cfeb45325554c97c674770ca64f2d367b83 (commit)


commit 3bbe6cfeb45325554c97c674770ca64f2d367b83
Author: radhika <radhika at curoverse.com>
Date:   Mon Jul 17 16:45:45 2017 -0400

    11906: add _health/ping to api server
    
    Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika at curoverse.com>

diff --git a/services/api/app/controllers/arvados/v1/healthcheck_controller.rb b/services/api/app/controllers/arvados/v1/healthcheck_controller.rb
new file mode 100644
index 0000000..41f7175
--- /dev/null
+++ b/services/api/app/controllers/arvados/v1/healthcheck_controller.rb
@@ -0,0 +1,37 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class Arvados::V1::HealthcheckController < ApplicationController
+  skip_before_filter :catch_redirect_hint
+  skip_before_filter :find_objects_for_index
+  skip_before_filter :find_object_by_uuid
+  skip_before_filter :load_filters_param
+  skip_before_filter :load_limit_offset_order_params
+  skip_before_filter :load_read_auths
+  skip_before_filter :load_where_param
+  skip_before_filter :render_404_if_no_object
+  skip_before_filter :require_auth_scope
+
+  before_filter :check_auth_header
+
+  def check_auth_header
+    mgmt_token = Rails.configuration.management_token
+
+    if !mgmt_token
+      send_error("disabled", status: 404)
+    else
+      auth_header = request.headers['Authorization']
+      if !auth_header
+        send_error("authorization required", status: 401)
+      elsif auth_header != 'Bearer '+mgmt_token
+        send_error("authorization error", status: 403)
+      end
+    end
+  end
+
+  def ping
+    resp = {"health": "OK"}
+    send_json resp
+  end
+end
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index 8f5c21a..8dafd1c 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -442,6 +442,10 @@ common:
   # Default value for keep_cache_ram of a container's runtime_constraints.
   container_default_keep_cache_ram: 268435456
 
+  # Token to be included in all healthcheck requests. Disabled by default.
+  # Server expects request header of the format "Authorization: Bearer xxx"
+  management_token: false
+
 development:
   force_ssl: false
   cache_classes: false
diff --git a/services/api/config/routes.rb b/services/api/config/routes.rb
index c030d42..2e9d618 100644
--- a/services/api/config/routes.rb
+++ b/services/api/config/routes.rb
@@ -104,6 +104,8 @@ Server::Application.routes.draw do
 
   match '/static/login_failure', to: 'static#login_failure', as: :login_failure, via: [:get, :post]
 
+  match '/_health/ping', to: 'arvados/v1/healthcheck#ping', via: [:get]
+
   # Send unroutable requests to an arbitrary controller
   # (ends up at ApplicationController#render_not_found)
   match '*a', to: 'static#render_not_found', via: [:get, :post, :put, :patch, :delete, :options]

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list