From 557e0c0a4c95c4b1e556f8aaf351937a237c7cd9 Mon Sep 17 00:00:00 2001 From: Andreas Scheuring Date: Tue, 31 May 2016 15:54:38 +0200 Subject: [PATCH] Terminate macvtap agent when physical_interface_mapping config not present Starting the macvtap agent without specifying at least one physical_interface_mappings does not make sense. As it only supports layer2 networks (flat, vlan) an interface mapping is mandatory. An existing agent deployment without an interface mapping can not serve any networks to instances! This patch terminates the agent when no mapping is provided. As without this mapping the agent cannot serve any networks for instances, this patch can't really break existing deployments. UpgradeImpact Agent terminates when no physical_interface_mapping configuration is provided. Change-Id: I647cf4da55fda54e32b7047b84e0d7f671629fa7 Closes-Bug: #1587444 --- .../ml2/drivers/macvtap/agent/macvtap_neutron_agent.py | 5 +++++ .../ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py | 5 +++++ ...when-interface_mapping-not-present-3109faf3b44d366a.yaml | 6 ++++++ 3 files changed, 16 insertions(+) create mode 100644 releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml diff --git a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py index 41115f8d394..a14480e6cc8 100644 --- a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py @@ -173,6 +173,11 @@ class MacvtapManager(amb.CommonAgentManagerBase): def parse_interface_mappings(): + if not cfg.CONF.macvtap.physical_interface_mappings: + LOG.error(_LE("No physical_interface_mappings provided, but at least " + "one mapping is required. Agent terminated!")) + sys.exit(1) + try: interface_mappings = n_utils.parse_mappings( cfg.CONF.macvtap.physical_interface_mappings) diff --git a/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py index 0101b491889..b91857a0139 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py @@ -191,6 +191,11 @@ class TestMacvtapMain(base.BaseTestCase): macvtap_neutron_agent.parse_interface_mappings() mock_exit.assert_called_with(1) + def test_parse_interface_mappings_no_mapping(self): + with mock.patch.object(sys, 'exit') as mock_exit: + macvtap_neutron_agent.parse_interface_mappings() + mock_exit.assert_called_with(1) + def test_validate_firewall_driver_noop_long(self): cfg.CONF.set_override('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', diff --git a/releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml b/releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml new file mode 100644 index 00000000000..c912ea2cf3d --- /dev/null +++ b/releasenotes/notes/terminate-macvtap-agt-when-interface_mapping-not-present-3109faf3b44d366a.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - After upgrade, a macvtap agent without + physical_interface_mappings configured can not + be started. Specify a valid mapping to be able + to start and use the macvtap agent.