OVS agent should fail if it can't get DVR mac address
Currently agent will fall back to non-dvr mode in case it can't. However neutron server does not check dvr mode of ovs agents when scheduling routers. So in a DVR enabled cluster all ovs agents should run in DVR mode. Otherwise it will lead to undefined behavior which is hard to debug. Closes-Bug: #1536110 Change-Id: I6c31aabf1852c688e9c27fc1859d3fdd830caa68
This commit is contained in:

committed by
Brian Haley

parent
893961c0d3
commit
e2a37be73d
@@ -13,6 +13,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
@@ -165,20 +167,16 @@ class OVSDVRNeutronAgent(object):
|
|||||||
try:
|
try:
|
||||||
self.get_dvr_mac_address_with_retry()
|
self.get_dvr_mac_address_with_retry()
|
||||||
except oslo_messaging.RemoteError as e:
|
except oslo_messaging.RemoteError as e:
|
||||||
LOG.warning(_LW('L2 agent could not get DVR MAC address at '
|
LOG.error(_LE('L2 agent could not get DVR MAC address at '
|
||||||
'startup due to RPC error. It happens when the '
|
'startup due to RPC error. It happens when the '
|
||||||
'server does not support this RPC API. Detailed '
|
'server does not support this RPC API. Detailed '
|
||||||
'message: %s'), e)
|
'message: %s'), e)
|
||||||
except oslo_messaging.MessagingTimeout:
|
except oslo_messaging.MessagingTimeout:
|
||||||
LOG.error(_LE('DVR: Failed to obtain a valid local '
|
LOG.error(_LE('DVR: Failed to obtain a valid local '
|
||||||
'DVR MAC address - L2 Agent operating '
|
'DVR MAC address'))
|
||||||
'in Non-DVR Mode'))
|
|
||||||
|
|
||||||
if not self.in_distributed_mode():
|
if not self.in_distributed_mode():
|
||||||
# switch all traffic using L2 learning
|
sys.exit(1)
|
||||||
# REVISIT(yamamoto): why to install the same flow as
|
|
||||||
# setup_integration_br?
|
|
||||||
self.int_br.install_normal()
|
|
||||||
|
|
||||||
def get_dvr_mac_address_with_retry(self):
|
def get_dvr_mac_address_with_retry(self):
|
||||||
# Get the local DVR MAC Address from the Neutron Server.
|
# Get the local DVR MAC Address from the Neutron Server.
|
||||||
|
@@ -2599,10 +2599,10 @@ class TestOvsDvrNeutronAgent(object):
|
|||||||
side_effect=oslo_messaging.RemoteError),\
|
side_effect=oslo_messaging.RemoteError),\
|
||||||
mock.patch.object(self.agent, 'int_br', new=int_br),\
|
mock.patch.object(self.agent, 'int_br', new=int_br),\
|
||||||
mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br):
|
mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br):
|
||||||
self.agent.dvr_agent.get_dvr_mac_address()
|
with testtools.ExpectedException(SystemExit):
|
||||||
self.assertIsNone(self.agent.dvr_agent.dvr_mac_address)
|
self.agent.dvr_agent.get_dvr_mac_address()
|
||||||
self.assertFalse(self.agent.dvr_agent.in_distributed_mode())
|
self.assertIsNone(self.agent.dvr_agent.dvr_mac_address)
|
||||||
self.assertEqual([mock.call.install_normal()], int_br.mock_calls)
|
self.assertFalse(self.agent.dvr_agent.in_distributed_mode())
|
||||||
|
|
||||||
def test_get_dvr_mac_address_retried(self):
|
def test_get_dvr_mac_address_retried(self):
|
||||||
valid_entry = {'host': 'cn1', 'mac_address': 'aa:22:33:44:55:66'}
|
valid_entry = {'host': 'cn1', 'mac_address': 'aa:22:33:44:55:66'}
|
||||||
@@ -2633,11 +2633,12 @@ class TestOvsDvrNeutronAgent(object):
|
|||||||
mock.patch.object(utils, "execute"),\
|
mock.patch.object(utils, "execute"),\
|
||||||
mock.patch.object(self.agent, 'int_br', new=int_br),\
|
mock.patch.object(self.agent, 'int_br', new=int_br),\
|
||||||
mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br):
|
mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br):
|
||||||
self.agent.dvr_agent.get_dvr_mac_address()
|
with testtools.ExpectedException(SystemExit):
|
||||||
self.assertIsNone(self.agent.dvr_agent.dvr_mac_address)
|
self.agent.dvr_agent.get_dvr_mac_address()
|
||||||
self.assertFalse(self.agent.dvr_agent.in_distributed_mode())
|
self.assertIsNone(self.agent.dvr_agent.dvr_mac_address)
|
||||||
self.assertEqual(self.agent.dvr_agent.plugin_rpc.
|
self.assertFalse(self.agent.dvr_agent.in_distributed_mode())
|
||||||
get_dvr_mac_address_by_host.call_count, 5)
|
self.assertEqual(self.agent.dvr_agent.plugin_rpc.
|
||||||
|
get_dvr_mac_address_by_host.call_count, 5)
|
||||||
|
|
||||||
def test_dvr_mac_address_update(self):
|
def test_dvr_mac_address_update(self):
|
||||||
self._setup_for_dvr_test()
|
self._setup_for_dvr_test()
|
||||||
|
Reference in New Issue
Block a user