summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Benton <blak111@gmail.com>2014-10-02 11:26:50 -0700
committerKevin Benton <blak111@gmail.com>2014-11-18 21:41:13 -0800
commitba647cae2932cda338441bc1f47e0668bba6b555 (patch)
treee46f469255dbe882bff4e00aa830642da1da5a04
parent6c476224f62770679f779dc6c13be3879b3a5ed8 (diff)
downloadneutron-ba647cae2932cda338441bc1f47e0668bba6b555.tar.gz
BSN: Set inconsistency record on delete failure
Set a bad value in the consistency DB on a delete failure so a sync is triggered the next time the backend servers become available. This fixes the issue where the backend servers are unavailable when an object is deleted from ML2 but not deleted from the backend. Conflicts: neutron/tests/unit/bigswitch/test_servermanager.py Closes-Bug: #1377350 Change-Id: I24713a03af4d3499645241f900de1f572689c235 (cherry picked from commit e9f001a63a555f067c4567a88613d14853442524)
-rw-r--r--neutron/plugins/bigswitch/servermanager.py7
-rw-r--r--neutron/tests/unit/bigswitch/test_servermanager.py13
2 files changed, 20 insertions, 0 deletions
diff --git a/neutron/plugins/bigswitch/servermanager.py b/neutron/plugins/bigswitch/servermanager.py
index c10ce72bb5..7b43ccfbcd 100644
--- a/neutron/plugins/bigswitch/servermanager.py
+++ b/neutron/plugins/bigswitch/servermanager.py
@@ -473,6 +473,13 @@ class ServerPool(object):
'data': ret[3]})
active_server.failed = True
+ # A failure on a delete means the object is gone from Neutron but not
+ # from the controller. Set the consistency hash to a bad value to
+ # trigger a sync on the next check.
+ # NOTE: The hash must have a comma in it otherwise it will be ignored
+ # by the backend.
+ if action == 'DELETE':
+ hash_handler.put_hash('INCONSISTENT,INCONSISTENT')
# All servers failed, reset server list and try again next time
LOG.error(_('ServerProxy: %(action)s failure for all servers: '
'%(server)r'),
diff --git a/neutron/tests/unit/bigswitch/test_servermanager.py b/neutron/tests/unit/bigswitch/test_servermanager.py
index e8d15efa3b..c3ea3b887a 100644
--- a/neutron/tests/unit/bigswitch/test_servermanager.py
+++ b/neutron/tests/unit/bigswitch/test_servermanager.py
@@ -23,6 +23,7 @@ from neutron import context
from neutron import manager
from neutron.openstack.common import importutils
from neutron.openstack.common import jsonutils
+from neutron.plugins.bigswitch.db import consistency_db as cdb
from neutron.plugins.bigswitch import servermanager
from neutron.tests.unit.bigswitch import test_restproxy_plugin as test_rp
@@ -411,6 +412,18 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase):
sleep_call_count = rest_call_count - 1
tmock.assert_has_calls(sleep_call * sleep_call_count)
+ def test_delete_failure_sets_bad_hash(self):
+ pl = manager.NeutronManager.get_plugin()
+ hash_handler = cdb.HashHandler()
+ with mock.patch(
+ SERVERMANAGER + '.ServerProxy.rest_call',
+ return_value=(httplib.INTERNAL_SERVER_ERROR, 0, 0, 0)
+ ):
+ # a failed delete call should put a bad hash in the DB
+ pl.servers.rest_call('DELETE', '/', '', None, [])
+ self.assertEqual('INCONSISTENT,INCONSISTENT',
+ hash_handler.read_for_update())
+
def test_conflict_triggers_sync(self):
pl = manager.NeutronManager.get_plugin()
with mock.patch(