diff --git a/neutron/agent/l3/ha_router.py b/neutron/agent/l3/ha_router.py index b6b9032d936..dd2084a8507 100644 --- a/neutron/agent/l3/ha_router.py +++ b/neutron/agent/l3/ha_router.py @@ -36,6 +36,9 @@ HA_DEV_PREFIX = 'ha-' IP_MONITOR_PROCESS_SERVICE = 'ip_monitor' 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 # SIGHUP to keepalived process. The constant multiplies ha_vrrp_advert_int # config option and the result is the throttle delay. @@ -368,7 +371,7 @@ class HaRouter(router.RouterInfo): def callback(pid_file): cmd = [ - 'neutron-keepalived-state-change', + STATE_CHANGE_PROC_NAME, '--router_id=%s' % self.router_id, '--namespace=%s' % self.ha_namespace, '--conf_dir=%s' % config_dir, diff --git a/neutron/agent/l3/keepalived_state_change.py b/neutron/agent/l3/keepalived_state_change.py index 70d42ba97de..412d30b9835 100644 --- a/neutron/agent/l3/keepalived_state_change.py +++ b/neutron/agent/l3/keepalived_state_change.py @@ -23,6 +23,7 @@ from oslo_log import log as logging from neutron._i18n import _ from neutron.agent.l3 import ha +from neutron.agent.l3 import ha_router from neutron.agent.linux import daemon from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_monitor @@ -54,8 +55,10 @@ class MonitorDaemon(daemon.Daemon): self.interface = interface self.cidr = cidr self.monitor = None - super(MonitorDaemon, self).__init__(pidfile, uuid=router_id, - user=user, group=group) + super(MonitorDaemon, self).__init__( + pidfile, uuid=router_id, + user=user, group=group, + procname=ha_router.STATE_CHANGE_PROC_NAME) def run(self, run_as_root=False): self.monitor = ip_monitor.IPMonitor(namespace=self.namespace, diff --git a/neutron/agent/linux/daemon.py b/neutron/agent/linux/daemon.py index 223bc1e9316..97194c3a007 100644 --- a/neutron/agent/linux/daemon.py +++ b/neutron/agent/linux/daemon.py @@ -24,6 +24,7 @@ import sys from neutron_lib import exceptions from oslo_log import log as logging +import setproctitle import six from neutron._i18n import _ @@ -238,6 +239,7 @@ class Daemon(object): def start(self): """Start the daemon.""" + self._parent_proctitle = setproctitle.getproctitle() if self.pidfile is not None and self.pidfile.is_running(): self.pidfile.unlock() LOG.error('Pidfile %s already exist. Daemon already ' @@ -248,10 +250,15 @@ class Daemon(object): self.daemonize() self.run() + def _set_process_title(self): + proctitle = "%s (%s)" % (self.procname, self._parent_proctitle) + setproctitle.setproctitle(proctitle) + def run(self): """Override this method and call super().run when subclassing Daemon. start() will call this method after the process has daemonized. """ + self._set_process_title() unwatch_log() drop_privileges(self.user, self.group)