Merge "Fail ironic startup if no protocol prefix in ironic api address"

This commit is contained in:
Jenkins 2016-12-15 19:11:50 +00:00 committed by Gerrit Code Review
commit cb70ac001d
4 changed files with 22 additions and 6 deletions

View File

@ -918,7 +918,8 @@
#heartbeat_interval = 10
# URL of Ironic API service. If not set ironic can get the
# current value from the keystone service catalog. (string
# current value from the keystone service catalog. If set, the
# value must start with either http:// or https://. (string
# value)
#api_url = <None>
@ -2506,6 +2507,11 @@
# Minimum value: 5
#default_notify_timeout = 30
# The duration to schedule a purge of idle sender links.
# Detach link after expiry. (integer value)
# Minimum value: 1
#default_sender_link_timeout = 600
# Indicates the addressing mode used by the driver.
# Permitted values:
# 'legacy' - use legacy non-routable addressing

View File

@ -29,9 +29,11 @@ opts = [
default=10,
help=_('Seconds between conductor heart beats.')),
cfg.StrOpt('api_url',
regex='^http(s?):\/\/.+',
help=_('URL of Ironic API service. If not set ironic can '
'get the current value from the keystone service '
'catalog.')),
'catalog. If set, the value must start with either '
'http:// or https://.')),
cfg.IntOpt('heartbeat_timeout',
default=60,
help=_('Maximum time (in seconds) since the last check-in '

View File

@ -1588,19 +1588,19 @@ class AgentMethodsTestCase(db_base.DbTestCase):
self._test_tear_down_inband_cleaning(manage_boot=False)
def test_build_agent_options_conf(self):
self.config(api_url='api-url', group='conductor')
self.config(api_url='https://api-url', group='conductor')
options = utils.build_agent_options(self.node)
self.assertEqual('api-url', options['ipa-api-url'])
self.assertEqual('https://api-url', options['ipa-api-url'])
self.assertEqual(0, options['coreos.configdrive'])
@mock.patch.object(utils, '_get_ironic_session')
def test_build_agent_options_keystone(self, session_mock):
self.config(api_url=None, group='conductor')
sess = mock.Mock()
sess.get_endpoint.return_value = 'api-url'
sess.get_endpoint.return_value = 'https://api-url'
session_mock.return_value = sess
options = utils.build_agent_options(self.node)
self.assertEqual('api-url', options['ipa-api-url'])
self.assertEqual('https://api-url', options['ipa-api-url'])
self.assertEqual(0, options['coreos.configdrive'])

View File

@ -0,0 +1,8 @@
---
fixes:
- Accepting ``[conductor]/api_url`` value specified in the configuration
file that does not start with either ``https://`` or ``http://``.
Such value leads to deployment failure on ironic-python-agent side.
This misconfiguration will be detected during ironic-conductor
and ironic-api start. An exception will be raised and an error about
the invalid value will be logged.