From 59824da6c71053d1181833c084b67f30a61fcfe1 Mon Sep 17 00:00:00 2001 From: Johannes Kulik Date: Fri, 11 Jul 2025 10:54:20 +0200 Subject: [PATCH] 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 Closes-Bug: #1998596 --- cinderclient/shell.py | 8 ++++---- releasenotes/notes/bug-1998596-5cac70cc68b3d6a5.yaml | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1998596-5cac70cc68b3d6a5.yaml diff --git a/cinderclient/shell.py b/cinderclient/shell.py index b8aa28c4f..ae473839b 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -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 diff --git a/releasenotes/notes/bug-1998596-5cac70cc68b3d6a5.yaml b/releasenotes/notes/bug-1998596-5cac70cc68b3d6a5.yaml new file mode 100644 index 000000000..781e11907 --- /dev/null +++ b/releasenotes/notes/bug-1998596-5cac70cc68b3d6a5.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + `Bug #1998596 `_: + fixed version discovery if the server was older than the maximum supported + version defined in python-cinderclient.