From cad79840f20a8ab64b3281a081f7f2162fad9b31 Mon Sep 17 00:00:00 2001 From: d064310 Date: Thu, 9 May 2024 06:31:38 +0200 Subject: [PATCH] object_storage: (fix) implemented switch from internal to public endpoint when internal is unavailable. --- app/controllers/os_api_controller.rb | 9 +-------- app/services/service_layer/os_api_service.rb | 11 +++++++++-- .../views/object_storage/application/show.html.haml | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/os_api_controller.rb b/app/controllers/os_api_controller.rb index 8516932a1e..1a04619481 100644 --- a/app/controllers/os_api_controller.rb +++ b/app/controllers/os_api_controller.rb @@ -41,14 +41,7 @@ def reverse_proxy # byebug # get api client for the given service name - service = services.os_api.service(service_name,interface: "internal") - # check if internal interface is available - begin - service.endpoint_url(interface: "internal") - rescue Elektron::Errors::ServiceEndpointUnavailable - service = services.os_api.service(service_name,interface: "public") - end - + service = services.os_api.service(service_name) # filter the relevant params for the api client elektron_params = request.query_parameters diff --git a/app/services/service_layer/os_api_service.rb b/app/services/service_layer/os_api_service.rb index 4029bc913e..515cd97d27 100644 --- a/app/services/service_layer/os_api_service.rb +++ b/app/services/service_layer/os_api_service.rb @@ -2,8 +2,15 @@ # Use case rever_proxy (see os_api_controller.rb) module ServiceLayer class OsApiService < Core::ServiceLayer::Service - def service(name,options={}) - elektron.service(name,options) + def service(name) + begin + service = elektron.service(name,interface: "internal") + # check if internal interface is available + service.endpoint_url(interface: "internal") + rescue Elektron::Errors::ServiceEndpointUnavailable + service = elektron.service(name,interface: "public") + end + service end end end diff --git a/plugins/object_storage/app/views/object_storage/application/show.html.haml b/plugins/object_storage/app/views/object_storage/application/show.html.haml index a26983e2c1..3a98a387ec 100644 --- a/plugins/object_storage/app/views/object_storage/application/show.html.haml +++ b/plugins/object_storage/app/views/object_storage/application/show.html.haml @@ -2,7 +2,6 @@ -# service_endpoint: is used by the app to determine the endpoint to use in api client -# project_path: is used by the app to determine the project path to use in api client -# resources_path: is used by the app to link to the resources app - = javascript_include_tag "object_storage_app_widget", data: { | base_name: plugin('object_storage').service_path(@service_name), | service_endpoint: services.os_api.service("#{@service_name}").endpoint_url, |