Skip to content

Commit

Permalink
ceph: switch to public endpoint if internal endpoint is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
andypf committed May 8, 2024
1 parent d1302e9 commit 92d42f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/controllers/os_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def reverse_proxy
# byebug

# get api client for the given service name
service = services.os_api.service(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

# filter the relevant params for the api client
elektron_params = request.query_parameters

Expand Down
4 changes: 2 additions & 2 deletions app/services/service_layer/os_api_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Use case rever_proxy (see os_api_controller.rb)
module ServiceLayer
class OsApiService < Core::ServiceLayer::Service
def service(name)
elektron.service(name)
def service(name,options={})
elektron.service(name,options)
end
end
end

0 comments on commit 92d42f4

Please sign in to comment.