未验证 提交 ba19398e 编写于 作者: K kuizhiqing 提交者: GitHub

fix force kill for elastic (#34488)

* fix force kill for elastic
上级 6c09496a
...@@ -133,6 +133,7 @@ class ElasticManager(object): ...@@ -133,6 +133,7 @@ class ElasticManager(object):
self.stopped = False self.stopped = False
self.sigint = 0 self.sigint = 0
self.need_sync = False
if not server or ':' not in server or not name or not np: if not server or ':' not in server or not name or not np:
logger.info( logger.info(
...@@ -177,6 +178,7 @@ class ElasticManager(object): ...@@ -177,6 +178,7 @@ class ElasticManager(object):
logger.info('register host again {}'.format(self.host)) logger.info('register host again {}'.format(self.host))
self.etcd.put(self.host_path, six.b(self.host)) self.etcd.put(self.host_path, six.b(self.host))
self.need_sync = True
host_watch = self.etcd.add_watch_callback(self.host_path, host_watch = self.etcd.add_watch_callback(self.host_path,
host_call_back) host_call_back)
...@@ -254,6 +256,7 @@ class ElasticManager(object): ...@@ -254,6 +256,7 @@ class ElasticManager(object):
return int(self.etcd.get(self.prefix)[0]) == 1 return int(self.etcd.get(self.prefix)[0]) == 1
def _match(self): def _match(self):
self.hosts = [ self.hosts = [
six.ensure_str(i[0]) for i in self.etcd.get_prefix(self.node_prefix) six.ensure_str(i[0]) for i in self.etcd.get_prefix(self.node_prefix)
] ]
...@@ -307,7 +310,8 @@ class ElasticManager(object): ...@@ -307,7 +310,8 @@ class ElasticManager(object):
self.hosts)) self.hosts))
idx += 1 idx += 1
time.sleep(3) time.sleep(2)
return return
def run(self, launcher): def run(self, launcher):
...@@ -319,6 +323,9 @@ class ElasticManager(object): ...@@ -319,6 +323,9 @@ class ElasticManager(object):
def watch(self): def watch(self):
if self.need_sync:
self.need_sync = False
while not self.stopped: while not self.stopped:
ret = self.launcher.watch() ret = self.launcher.watch()
...@@ -334,7 +341,7 @@ class ElasticManager(object): ...@@ -334,7 +341,7 @@ class ElasticManager(object):
else: else:
return ElasticStatus.ERROR return ElasticStatus.ERROR
if not self._completed() and not self._match(): if not self._completed() and (not self._match() or self.need_sync):
self.launcher.stop() self.launcher.stop()
return ElasticStatus.HOLD return ElasticStatus.HOLD
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册