Skip to content

Commit e6ca383

Browse files
author
Eric Fried
committed
Fix {min|max}_version in ironic Adapter setup
Change If625411f40be0ba642baeb02950f568f43673655 introduced nova.utils.get_ksa_adapter, which accepts min_version and max_version kwargs to be passed through to the ksa Adapter constructor. These are supposed to represent minimum and maximum *major* API versions, min_version was erroneously set to *microversions* when setting up the Adapter for ironicclient. This commit changes it to a major version. (Microversion negotiation is done within ironicclient itself.) Also, this bug went latent for several releases because a) it only seems to be triggered when region_name is given in the conf; but also b) ironicclient has code to discover a reasonable endpoint if passed None. So this change also adds a warning log if we try and fail to discover the endpoint via ksa. Change-Id: I34a3f8d4a496217eb01790e2d124111625bf5f85 Closes-Bug: #1825583 (cherry picked from commit 13278be)
1 parent 2888bc6 commit e6ca383

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

nova/tests/unit/virt/ironic/test_client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test__get_client_session(self, mock_ir_cli, mock_session):
8181
# nova.utils.get_ksa_adapter().get_endpoint()
8282
self.get_ksa_adapter.assert_called_once_with(
8383
'baremetal', ksa_auth=self.get_auth_plugin.return_value,
84-
ksa_session='session', min_version=(1, 46),
84+
ksa_session='session', min_version=(1, 0),
8585
max_version=(1, ksa_disc.LATEST))
8686
expected = {'session': 'session',
8787
'max_retries': CONF.ironic.api_max_retries,
@@ -107,7 +107,7 @@ def test__get_client_session_service_not_found(self, mock_ir_cli,
107107
# nova.utils.get_endpoint_data
108108
self.get_ksa_adapter.assert_called_once_with(
109109
'baremetal', ksa_auth=self.get_auth_plugin.return_value,
110-
ksa_session='session', min_version=(1, 46),
110+
ksa_session='session', min_version=(1, 0),
111111
max_version=(1, ksa_disc.LATEST))
112112
# When get_endpoint_data raises any ServiceNotFound, None is returned.
113113
expected = {'session': 'session',

nova/virt/ironic/client_wrapper.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,20 @@ def _get_client(self, retry_on_conflict=True):
117117
ksa_adap = utils.get_ksa_adapter(
118118
nova.conf.ironic.DEFAULT_SERVICE_TYPE,
119119
ksa_auth=auth_plugin, ksa_session=sess,
120-
min_version=IRONIC_API_VERSION,
120+
min_version=(IRONIC_API_VERSION[0], 0),
121121
max_version=(IRONIC_API_VERSION[0], ks_disc.LATEST))
122122
ironic_url = ksa_adap.get_endpoint()
123+
ironic_url_none_reason = 'returned None'
123124
except exception.ServiceNotFound:
124125
# NOTE(efried): No reason to believe service catalog lookup
125126
# won't also fail in ironic client init, but this way will
126127
# yield the expected exception/behavior.
127128
ironic_url = None
129+
ironic_url_none_reason = 'raised ServiceNotFound'
130+
131+
if ironic_url is None:
132+
LOG.warning("Could not discover ironic_url via keystoneauth1: "
133+
"Adapter.get_endpoint %s", ironic_url_none_reason)
128134

129135
try:
130136
cli = ironic.client.get_client(IRONIC_API_VERSION[0],

0 commit comments

Comments
 (0)