Skip to content

Commit 6eaa6db

Browse files
committed
Pass on region when we don't have a valid ironic endpoint
If for some reason we don't have a valid endpoint to provide the Ironic client, we should at the very least provide the information it needs to make an informed decision. Change-Id: I31fa1c6fb0b224fbb02f9ebf68abc6a3728e9389 Partial-Bug: #1825583
1 parent 13278be commit 6eaa6db

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def setUp(self):
4242
self.ironicclient = client_wrapper.IronicClientWrapper()
4343
# Do not waste time sleeping
4444
cfg.CONF.set_override('api_retry_interval', 0, 'ironic')
45+
cfg.CONF.set_override('region_name', 'RegionOne', 'ironic')
4546
get_ksa_adapter_p = mock.patch('nova.utils.get_ksa_adapter')
4647
self.addCleanup(get_ksa_adapter_p.stop)
4748
self.get_ksa_adapter = get_ksa_adapter_p.start()
@@ -115,6 +116,7 @@ def test__get_client_session_service_not_found(self, mock_ir_cli,
115116
'retry_interval': CONF.ironic.api_retry_interval,
116117
'os_ironic_api_version': ['1.46', '1.38'],
117118
'endpoint': None,
119+
'region_name': CONF.ironic.region_name,
118120
'interface': ['internal', 'public']}
119121
mock_ir_cli.assert_called_once_with(1, **expected)
120122

nova/virt/ironic/client_wrapper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def _get_client(self, retry_on_conflict=True):
131131
if ironic_url is None:
132132
LOG.warning("Could not discover ironic_url via keystoneauth1: "
133133
"Adapter.get_endpoint %s", ironic_url_none_reason)
134+
# NOTE(eandersson): We pass in region here to make sure
135+
# that the Ironic client can make an educated decision when
136+
# we don't have a valid endpoint to pass on.
137+
kwargs['region_name'] = ironic_conf.region_name
134138

135139
try:
136140
cli = ironic.client.get_client(IRONIC_API_VERSION[0],

0 commit comments

Comments
 (0)