Only check management interface when amphora is enabled
Only perform the management interface address check when the enable-amphora configuration option is enabled. This prevents unnecessary blocking status when amphora is not being used, such as when the environment is configured to exclusively use the OVN provider. Closes-Bug: #2121592 Change-Id: I3c12cdee79c0644535179ae62faa8b95fee33bea Signed-off-by: Felipe Reyes <felipe.reyes@canonical.com>
This commit is contained in:
@@ -493,8 +493,9 @@ class BaseOctaviaCharm(ch_plugins.PolicydOverridePlugin,
|
||||
|
||||
:returns: None, None - no action in this function.
|
||||
"""
|
||||
if not get_address_on_mgmt_interface():
|
||||
return ('blocked', 'no address on mgmt interface')
|
||||
if ch_core.hookenv.config('enable-amphora'):
|
||||
if not get_address_on_mgmt_interface():
|
||||
return ('blocked', 'no address on mgmt interface')
|
||||
return (None, None)
|
||||
|
||||
def get_amqp_credentials(self):
|
||||
|
@@ -209,3 +209,19 @@ class TestOctaviaCharm(Helper):
|
||||
self.target.configuration_class = configuration_class
|
||||
self.assertEqual(self.target.local_unit_name,
|
||||
configuration_class().local_unit_name)
|
||||
|
||||
@mock.patch.object(octavia, "get_address_on_mgmt_interface")
|
||||
def test_custom_assess_status_last_check(
|
||||
self,
|
||||
mock_get_address_on_mgmt_interface):
|
||||
self.patch('charmhelpers.core.hookenv.config', 'config')
|
||||
self.config.return_value = False
|
||||
c = octavia.VictoriaOctaviaCharm()
|
||||
self.assertEqual((None, None), c.custom_assess_status_last_check())
|
||||
mock_get_address_on_mgmt_interface.assert_not_called()
|
||||
mock_get_address_on_mgmt_interface.reset_mock()
|
||||
self.config.return_value = True
|
||||
mock_get_address_on_mgmt_interface.return_value = False
|
||||
self.assertEqual(('blocked', 'no address on mgmt interface'),
|
||||
c.custom_assess_status_last_check())
|
||||
mock_get_address_on_mgmt_interface.assert_called_once()
|
||||
|
Reference in New Issue
Block a user