Add error log for SystemExit in l3-agent
The SystemExit exception should be logged in l3-agent, the operator may miss the useful exception messages to debug. * Add error log for SystemExit in l3-agent. * Add unit test for None and Wrong interface_driver. Closes-Bug #1229105 Change-Id: I9ac60a528c1e88827078d552a30c8d571066d21c
This commit is contained in:
parent
86feb8e4a8
commit
1387049bf0
@ -205,6 +205,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
||||
except Exception:
|
||||
msg = _("Error importing interface driver "
|
||||
"'%s'") % self.conf.interface_driver
|
||||
LOG.error(msg)
|
||||
raise SystemExit(msg)
|
||||
|
||||
self.context = context.get_admin_context_without_session()
|
||||
@ -228,7 +229,9 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
||||
The actual values are not verified for correctness.
|
||||
"""
|
||||
if not self.conf.interface_driver:
|
||||
raise SystemExit(_('An interface driver must be specified'))
|
||||
msg = _('An interface driver must be specified')
|
||||
LOG.error(msg)
|
||||
raise SystemExit(msg)
|
||||
|
||||
if not self.conf.use_namespaces and not self.conf.router_id:
|
||||
msg = _('Router id is required if not using namespaces.')
|
||||
|
@ -657,6 +657,21 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
self.assertEqual(['1234'], agent._router_ids())
|
||||
|
||||
def test_nonexistent_interface_driver(self):
|
||||
self.conf.set_override('interface_driver', None)
|
||||
with mock.patch.object(l3_agent, 'LOG') as log:
|
||||
self.assertRaises(SystemExit, l3_agent.L3NATAgent,
|
||||
HOSTNAME, self.conf)
|
||||
msg = 'An interface driver must be specified'
|
||||
log.error.assert_called_once_with(msg)
|
||||
|
||||
self.conf.set_override('interface_driver', 'wrong_driver')
|
||||
with mock.patch.object(l3_agent, 'LOG') as log:
|
||||
self.assertRaises(SystemExit, l3_agent.L3NATAgent,
|
||||
HOSTNAME, self.conf)
|
||||
msg = "Error importing interface driver 'wrong_driver'"
|
||||
log.error.assert_called_once_with(msg)
|
||||
|
||||
|
||||
class TestL3AgentEventHandler(base.BaseTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user