Set neutron-keepalived-state-change proctitle

Then we can count the process correctly.

Related-Bug: #1798475
Change-Id: I9c6651ed192669b91a4683f5f3bd2795e8d8276a
This commit is contained in:
LIU Yulong 2019-05-23 15:19:56 +08:00
parent 0c87350a94
commit 26388a9952
3 changed files with 16 additions and 3 deletions

View File

@ -36,6 +36,9 @@ HA_DEV_PREFIX = 'ha-'
IP_MONITOR_PROCESS_SERVICE = 'ip_monitor' IP_MONITOR_PROCESS_SERVICE = 'ip_monitor'
SIGTERM_TIMEOUT = 10 SIGTERM_TIMEOUT = 10
# TODO(liuyulong): move to neutron-lib?
STATE_CHANGE_PROC_NAME = 'neutron-keepalived-state-change'
# The multiplier is used to compensate execution time of function sending # The multiplier is used to compensate execution time of function sending
# SIGHUP to keepalived process. The constant multiplies ha_vrrp_advert_int # SIGHUP to keepalived process. The constant multiplies ha_vrrp_advert_int
# config option and the result is the throttle delay. # config option and the result is the throttle delay.
@ -368,7 +371,7 @@ class HaRouter(router.RouterInfo):
def callback(pid_file): def callback(pid_file):
cmd = [ cmd = [
'neutron-keepalived-state-change', STATE_CHANGE_PROC_NAME,
'--router_id=%s' % self.router_id, '--router_id=%s' % self.router_id,
'--namespace=%s' % self.ha_namespace, '--namespace=%s' % self.ha_namespace,
'--conf_dir=%s' % config_dir, '--conf_dir=%s' % config_dir,

View File

@ -23,6 +23,7 @@ from oslo_log import log as logging
from neutron._i18n import _ from neutron._i18n import _
from neutron.agent.l3 import ha from neutron.agent.l3 import ha
from neutron.agent.l3 import ha_router
from neutron.agent.linux import daemon from neutron.agent.linux import daemon
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import ip_monitor from neutron.agent.linux import ip_monitor
@ -54,8 +55,10 @@ class MonitorDaemon(daemon.Daemon):
self.interface = interface self.interface = interface
self.cidr = cidr self.cidr = cidr
self.monitor = None self.monitor = None
super(MonitorDaemon, self).__init__(pidfile, uuid=router_id, super(MonitorDaemon, self).__init__(
user=user, group=group) pidfile, uuid=router_id,
user=user, group=group,
procname=ha_router.STATE_CHANGE_PROC_NAME)
def run(self, run_as_root=False): def run(self, run_as_root=False):
self.monitor = ip_monitor.IPMonitor(namespace=self.namespace, self.monitor = ip_monitor.IPMonitor(namespace=self.namespace,

View File

@ -24,6 +24,7 @@ import sys
from neutron_lib import exceptions from neutron_lib import exceptions
from oslo_log import log as logging from oslo_log import log as logging
import setproctitle
import six import six
from neutron._i18n import _ from neutron._i18n import _
@ -238,6 +239,7 @@ class Daemon(object):
def start(self): def start(self):
"""Start the daemon.""" """Start the daemon."""
self._parent_proctitle = setproctitle.getproctitle()
if self.pidfile is not None and self.pidfile.is_running(): if self.pidfile is not None and self.pidfile.is_running():
self.pidfile.unlock() self.pidfile.unlock()
LOG.error('Pidfile %s already exist. Daemon already ' LOG.error('Pidfile %s already exist. Daemon already '
@ -248,10 +250,15 @@ class Daemon(object):
self.daemonize() self.daemonize()
self.run() self.run()
def _set_process_title(self):
proctitle = "%s (%s)" % (self.procname, self._parent_proctitle)
setproctitle.setproctitle(proctitle)
def run(self): def run(self):
"""Override this method and call super().run when subclassing Daemon. """Override this method and call super().run when subclassing Daemon.
start() will call this method after the process has daemonized. start() will call this method after the process has daemonized.
""" """
self._set_process_title()
unwatch_log() unwatch_log()
drop_privileges(self.user, self.group) drop_privileges(self.user, self.group)