Remove exit_on_stop from Watcher
We don't need exit_on_stop option now as we always set it to True. This commit removes it to simplify the code. Change-Id: I258709095727d87ede66ad6846c6e56ebdabec91
This commit is contained in:
@@ -192,7 +192,7 @@ class CNIDaemonWatcherService(cotyledon.Service):
|
|||||||
self.pipeline = h_cni.CNIPipeline()
|
self.pipeline = h_cni.CNIPipeline()
|
||||||
self.pipeline.register(h_cni.CallbackHandler(self.on_done,
|
self.pipeline.register(h_cni.CallbackHandler(self.on_done,
|
||||||
self.on_deleted))
|
self.on_deleted))
|
||||||
self.watcher = k_watcher.Watcher(self.pipeline, exit_on_stop=True)
|
self.watcher = k_watcher.Watcher(self.pipeline)
|
||||||
self.watcher.add(
|
self.watcher.add(
|
||||||
"%(base)s/pods?fieldSelector=spec.nodeName=%(node_name)s" % {
|
"%(base)s/pods?fieldSelector=spec.nodeName=%(node_name)s" % {
|
||||||
'base': k_const.K8S_API_BASE,
|
'base': k_const.K8S_API_BASE,
|
||||||
|
@@ -84,7 +84,7 @@ class KuryrK8sService(six.with_metaclass(KuryrK8sServiceMeta,
|
|||||||
|
|
||||||
objects.register_locally_defined_vifs()
|
objects.register_locally_defined_vifs()
|
||||||
pipeline = h_pipeline.ControllerPipeline(self.tg)
|
pipeline = h_pipeline.ControllerPipeline(self.tg)
|
||||||
self.watcher = watcher.Watcher(pipeline, self.tg, exit_on_stop=True)
|
self.watcher = watcher.Watcher(pipeline, self.tg)
|
||||||
self.health_manager = health.HealthServer()
|
self.health_manager = health.HealthServer()
|
||||||
self.current_leader = None
|
self.current_leader = None
|
||||||
self.node_name = utils.get_node_name()
|
self.node_name = utils.get_node_name()
|
||||||
|
@@ -211,8 +211,7 @@ class TestWatcher(test_base.TestCase):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _test_watch_create_watcher(path, handler, timeout=0):
|
def _test_watch_create_watcher(path, handler, timeout=0):
|
||||||
watcher_obj = watcher.Watcher(handler, timeout=timeout,
|
watcher_obj = watcher.Watcher(handler, timeout=timeout)
|
||||||
exit_on_stop=True)
|
|
||||||
watcher_obj._running = True
|
watcher_obj._running = True
|
||||||
watcher_obj._resources.add(path)
|
watcher_obj._resources.add(path)
|
||||||
watcher_obj._idle[path] = True
|
watcher_obj._idle[path] = True
|
||||||
|
@@ -56,8 +56,7 @@ class Watcher(health.HealthHandler):
|
|||||||
graceful=False)` for asynchronous `Watcher`).
|
graceful=False)` for asynchronous `Watcher`).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, handler, thread_group=None, timeout=None,
|
def __init__(self, handler, thread_group=None, timeout=None):
|
||||||
exit_on_stop=False):
|
|
||||||
"""Initializes a new Watcher instance.
|
"""Initializes a new Watcher instance.
|
||||||
|
|
||||||
:param handler: a `callable` object to be invoked for each observed
|
:param handler: a `callable` object to be invoked for each observed
|
||||||
@@ -84,7 +83,6 @@ class Watcher(health.HealthHandler):
|
|||||||
if timeout is None:
|
if timeout is None:
|
||||||
timeout = CONF.kubernetes.watch_retry_timeout
|
timeout = CONF.kubernetes.watch_retry_timeout
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
self._exit_on_stop = exit_on_stop
|
|
||||||
|
|
||||||
def add(self, path):
|
def add(self, path):
|
||||||
"""Adds ths K8s resource to the Watcher.
|
"""Adds ths K8s resource to the Watcher.
|
||||||
@@ -161,11 +159,8 @@ class Watcher(health.HealthHandler):
|
|||||||
finally:
|
finally:
|
||||||
if not self._watching and not self._idle:
|
if not self._watching and not self._idle:
|
||||||
self.stop()
|
self.stop()
|
||||||
if self._exit_on_stop:
|
LOG.info("No remaining active watchers, Exiting...")
|
||||||
LOG.info("No remaining active watchers, Exiting...")
|
sys.exit(1)
|
||||||
# TODO(dulek): This complicates things, remove once we
|
|
||||||
# don't support running without kuryr-daemon.
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def _watch(self, path):
|
def _watch(self, path):
|
||||||
attempts = 0
|
attempts = 0
|
||||||
|
Reference in New Issue
Block a user