Files
ceilometer/releasenotes/notes/dynamic-pollster-url-joins-6cdb01c4015976f7.yaml
Callum Dickinson 0468126182 Dynamic pollsters: Append relative url_path to URLs
When generating OpenStack API query URLs for dynamic pollsters,
Ceilometer uses urllib.parse.urljoin to append url_path to the
endpoint URL.

If an API endpoint URL returned by Keystone does not have a
trailing slash and the specified url_path value is a relative
path (e.g. does not start with /), urljoin will replace the
final segment of the base URL instead of appending url_path to it.

This breaks generating links in dynamic pollsters for OpenStack services
if the endpoint URL in the Keystone service catalog does not have a trailing
slash. This is particularly relevant for OpenStack services that incorporate
the project ID into the API endpoint URL, such as Trove as shown below.

>>> urljoin("http://example.com:8779/v1.0/12345678", "mgmt/instances")
'http://example.com:8779/v1.0/mgmt/instances'

If there is a trailing slash on the end of the base URL,
url_path will be appended to the end of the URL as expected.

>>> urljoin("http://example.com:8779/v1.0/12345678/", "mgmt/instances")
'http://example.com:8779/v1.0/12345678/mgmt/instances'

This commit changes the behaviour of the dynamic pollster URL joins
by making sure there is a trailing slash on the endpoint URLs when
appending the defined url_path to them.

This may break existing dynamic pollster configurations that rely
on this behaviour, but given that most OpenStack services probably
wouldn't, there shouldn't be too many changes that would be required.

Change-Id: I367d299df85676472c7e1a922d08971810f2ba9f
2025-01-30 19:52:45 +13:00

15 lines
749 B
YAML

---
upgrade:
- |
When using dynamic pollsters to query OpenStack APIs, if the endpoint URL
returned by Keystone does not have a trailing slash and ``url_path`` is
a relative path, the ``url_path`` configured in the dynamic pollster would
replace sections of the endpoint URL instead of being appended to the end
of the URL. This behaviour has now been changed so that ``url_path``
values that do not start with a ``/`` are always appended to the end of
endpoint URLs.
This change may require existing dynamic pollsters that rely on this
behaviour to be changed, but this allows dynamic pollsters to be added
for OpenStack services that append the active project ID to the API
endpoint URL (e.g. Trove).