From 709b83b390a747beb55b08c6cf3477a5ca231264 Mon Sep 17 00:00:00 2001 From: Trygve Vea Date: Mon, 22 Aug 2022 15:35:07 +0200 Subject: [PATCH] Add new option for api: public_endpoint When running glance-api behind a proxy or load balancer that hides glance behind an extended base URL, it is necessary to provide information about the base URL to glance-api to ensure that clients know where to pass subsequent requests. Change-Id: I9bebee01c2580f0500a069f5ab57ac2a8c329389 --- manifests/api.pp | 10 ++++++++++ .../new_option_public_endpoint-26ba31afc09cabf0.yaml | 9 +++++++++ spec/classes/glance_api_spec.rb | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 releasenotes/notes/new_option_public_endpoint-26ba31afc09cabf0.yaml diff --git a/manifests/api.pp b/manifests/api.pp index 6dd0ceb2..d6221c43 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -225,6 +225,14 @@ # by the user executing the agent # Defaults to: $::glance::params::lock_path # +# [*public_endpoint*] +# (optional) Public url endpoint to use for Glance versions response. +# Change the endpoint to represent the proxy URL if the API service is +# running behind a proxy. This is especially useful if the public endpoint +# is advertised with a base URL not pointing to the server root in Keystone. +# ie. https://cloud.acme.org/api/image +# Default: $::os_service_default. +# # DEPRECATED PARAMETERS # # [*stores*] @@ -342,6 +350,7 @@ class glance::api( $limit_param_default = $::os_service_default, $api_limit_max = $::os_service_default, $lock_path = $::glance::params::lock_path, + $public_endpoint = $::os_service_default, # DEPRECATED PARAMETERS $stores = undef, $default_store = undef, @@ -435,6 +444,7 @@ class glance::api( 'DEFAULT/user_storage_quota': value => $user_storage_quota; 'DEFAULT/limit_param_default': value => $limit_param_default; 'DEFAULT/api_limit_max': value => $api_limit_max; + 'DEFAULT/public_endpoint': value => $public_endpoint; } if $show_multiple_locations { diff --git a/releasenotes/notes/new_option_public_endpoint-26ba31afc09cabf0.yaml b/releasenotes/notes/new_option_public_endpoint-26ba31afc09cabf0.yaml new file mode 100644 index 00000000..d3d7b5c2 --- /dev/null +++ b/releasenotes/notes/new_option_public_endpoint-26ba31afc09cabf0.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + The ``glance::api`` class accepts a new parameter ``public_endpoint``. + This is especially useful if you have a proxy or load balancer that + rewrites the base URL of the image API. If the image API is advertised as + ``https://cloud.acme.org/api/image`` in Keystone, you will need to set + this option to the full value of the endpoint to have glance API + advertise the correct URLs to clients. diff --git a/spec/classes/glance_api_spec.rb b/spec/classes/glance_api_spec.rb index 3596e0f7..1040c4f5 100644 --- a/spec/classes/glance_api_spec.rb +++ b/spec/classes/glance_api_spec.rb @@ -54,6 +54,7 @@ describe 'glance::api' do :sync_db => true, :limit_param_default => '', :api_limit_max => '', + :public_endpoint => '', } end @@ -96,6 +97,7 @@ describe 'glance::api' do :sync_db => false, :limit_param_default => '10', :api_limit_max => '10', + :public_endpoint => 'https://cloud.acme.org/api/image', } ].each do |param_set| @@ -155,6 +157,7 @@ describe 'glance::api' do 'user_storage_quota', 'limit_param_default', 'api_limit_max', + 'public_endpoint', ].each do |config| is_expected.to contain_glance_api_config("DEFAULT/#{config}").with_value(param_hash[config.intern]) end