Merge "Retry Coordinator start indefinitely"

This commit is contained in:
Jenkins 2016-01-14 15:19:09 +00:00 committed by Gerrit Code Review
commit 7a8869ae92
2 changed files with 12 additions and 6 deletions

View File

@ -17,6 +17,7 @@
# under the License.
import math
import time
import uuid
from oslo_config import cfg
@ -79,12 +80,17 @@ class CoordinationMixin(object):
super(CoordinationMixin, self).start()
if self._coordinator is not None:
self._coordinator.start()
while not self._coordination_started:
try:
self._coordinator.start()
self._coordinator.create_group(self.service_name)
self._coordinator.join_group(self.service_name)
self._coordination_started = True
self._coordinator.create_group(self.service_name)
self._coordinator.join_group(self.service_name)
self._coordination_started = True
except Exception:
LOG.warn(_LW("Failed to start Coordinator:"),
exc_info=True)
time.sleep(15)
def stop(self):
if self._coordinator is not None:

View File

@ -47,7 +47,7 @@ class TestCoordinationMixin(TestCase):
service._coordinator.get_groups().get())
self.assertIn(service._coordination_id.encode('utf-8'),
service._coordinator.get_members(
service.service_name).get())
service.service_name).get())
service.stop()
def test_stop(self):