Fix talking to older servers

Cinderclient currently supports version 3.71 as defined in
`cinderclient.api_versions.MAX_VERSION`. When doing version discovery,
we create a temporary client with the MAX_VERSION and use this client to
fetch the available versions. If the server doesn't support 3.71, yet,
the version discovery request fails with:

	cinderclient.exceptions.NotAcceptable: Version 3.71 is not supported by the API. Minimum is 3.0 and maximum is 3.70. (HTTP 406)
	ERROR: Version 3.71 is not supported by the API. Minimum is 3.0 and maximum is 3.70. (HTTP 406)

To fix this, we instead create a client with the MIN_VERSION, because
the versions endpoint should be available there already.

NOTE: Even when specifying an `--os-volume-api-version 3.70` the request
fails, because version discovery still takes place in case we have to
downgrade from the requested version.

Change-Id: I38b71cea6b92da7f451e2a02d55900fe18e9aab0
Signed-off-by: Johannes Kulik <johannes.kulik@sap.com>
Closes-Bug: #1998596
This commit is contained in:
Johannes Kulik
2025-07-11 10:54:20 +02:00
parent 018955c310
commit 59824da6c7
2 changed files with 10 additions and 4 deletions

View File

@@ -771,11 +771,11 @@ class OpenStackCinderShell(object):
"using --os-volume-api-version option.")
raise exc.UnsupportedVersion(msg)
API_MAX_VERSION = api_versions.APIVersion(api_versions.MAX_VERSION)
API_MIN_VERSION = api_versions.APIVersion(api_versions.MIN_VERSION)
# FIXME: the endpoint_api_version[0] can ONLY be '3' now, so the
# above line should probably be ripped out and this condition removed
if endpoint_api_version[0] == '3':
disc_client = client.Client(API_MAX_VERSION,
disc_client = client.Client(API_MIN_VERSION,
os_username,
os_password,
os_project_name,
@@ -840,9 +840,9 @@ class OpenStackCinderShell(object):
if not os_service_type:
os_service_type = self._discover_service_type(discovered_version)
API_MAX_VERSION = api_versions.APIVersion(api_versions.MAX_VERSION)
API_MIN_VERSION = api_versions.APIVersion(api_versions.MIN_VERSION)
if (discovered_version != API_MAX_VERSION or
if (discovered_version != API_MIN_VERSION or
os_service_type != 'volume' or
os_endpoint_type != DEFAULT_CINDER_ENDPOINT_TYPE):
client_args['service_type'] = os_service_type

View File

@@ -0,0 +1,6 @@
---
fixes:
- |
`Bug #1998596 <https://bugs.launchpad.net/python-cinderclient/+bug/1998596>`_:
fixed version discovery if the server was older than the maximum supported
version defined in python-cinderclient.