Merge "Set process name for agents"

This commit is contained in:
Zuul 2020-07-08 13:40:10 +00:00 committed by Gerrit Code Review
commit cee4686710
28 changed files with 124 additions and 50 deletions

View File

@ -968,7 +968,7 @@ class DhcpAgentWithStateReport(DhcpAgent):
self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
self.failed_report_state = False
self.agent_state = {
'binary': 'neutron-dhcp-agent',
'binary': constants.AGENT_PROCESS_DHCP,
'host': host,
'availability_zone': self.conf.AGENT.availability_zone,
'topic': topics.DHCP_AGENT,

View File

@ -17,6 +17,7 @@
import sys
from neutron_lib.agent import topics
from neutron_lib import constants
from oslo_config import cfg
from oslo_service import service
@ -45,7 +46,7 @@ def main():
config.setup_logging()
config.setup_privsep()
server = neutron_service.Service.create(
binary='neutron-dhcp-agent',
binary=constants.AGENT_PROCESS_DHCP,
topic=topics.DHCP_AGENT,
report_interval=cfg.CONF.AGENT.report_interval,
manager='neutron.agent.dhcp.agent.DhcpAgentWithStateReport')

View File

@ -923,7 +923,7 @@ class L3NATAgentWithStateReport(L3NATAgent):
self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
self.failed_report_state = False
self.agent_state = {
'binary': 'neutron-l3-agent',
'binary': lib_const.AGENT_PROCESS_L3,
'host': host,
'availability_zone': self.conf.AGENT.availability_zone,
'topic': topics.L3_AGENT,

View File

@ -17,6 +17,7 @@
import sys
from neutron_lib.agent import topics
from neutron_lib import constants
from oslo_config import cfg
from oslo_service import service
@ -49,7 +50,7 @@ def main(manager='neutron.agent.l3.agent.L3NATAgentWithStateReport'):
config.setup_logging()
config.setup_privsep()
server = neutron_service.Service.create(
binary='neutron-l3-agent',
binary=constants.AGENT_PROCESS_L3,
topic=topics.L3_AGENT,
report_interval=cfg.CONF.AGENT.report_interval,
manager=manager)

View File

@ -276,7 +276,7 @@ class UnixDomainMetadataProxy(object):
self.failed_state_report = False
self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
self.agent_state = {
'binary': 'neutron-metadata-agent',
'binary': constants.AGENT_PROCESS_METADATA,
'host': cfg.CONF.host,
'topic': 'N/A',
'configurations': {
@ -333,7 +333,8 @@ class UnixDomainMetadataProxy(object):
return MODE_MAP[mode]
def run(self):
server = agent_utils.UnixDomainWSGIServer('neutron-metadata-agent')
server = agent_utils.UnixDomainWSGIServer(
constants.AGENT_PROCESS_METADATA)
server.start(MetadataProxyHandler(self.conf),
self.conf.metadata_proxy_socket,
workers=self.conf.metadata_workers,

View File

@ -10,8 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
from neutron.agent import dhcp_agent
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_DHCP, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
dhcp_agent.main()

View File

@ -10,8 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
from neutron.agent import l3_agent
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_L3, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
l3_agent.main()

View File

@ -10,8 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
from neutron.agent import metadata_agent
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_METADATA, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
metadata_agent.main()

View File

@ -10,8 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
from neutron.agent.ovn import metadata_agent
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_OVN_METADATA, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
metadata_agent.main()

View File

@ -12,10 +12,17 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
import \
neutron.plugins.ml2.drivers.linuxbridge.agent.linuxbridge_neutron_agent \
as agent_main
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_LINUXBRIDGE, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
agent_main.main()

View File

@ -12,9 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
from neutron.plugins.ml2.drivers.macvtap.agent import (
macvtap_neutron_agent as agent_main)
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_MACVTAP, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
agent_main.main()

View File

@ -13,8 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
import neutron.plugins.ml2.drivers.openvswitch.agent.main as agent_main
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_OVS, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
agent_main.main()

View File

@ -12,9 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
import neutron.plugins.ml2.drivers.mech_sriov.agent.sriov_nic_agent \
as agent_main
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_NIC_SWITCH, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
agent_main.main()

View File

@ -10,8 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
from neutron.services.metering.agents import metering_agent
from neutron_lib import constants
def main():
proctitle = "%s (%s)" % (
constants.AGENT_PROCESS_METERING, setproctitle.getproctitle())
setproctitle.setproctitle(proctitle)
metering_agent.main()

View File

@ -61,7 +61,6 @@ from neutron.plugins.ml2.drivers.linuxbridge.agent \
LOG = logging.getLogger(__name__)
LB_AGENT_BINARY = 'neutron-linuxbridge-agent'
BRIDGE_NAME_PREFIX = "brq"
MAX_VLAN_POSTFIX_LEN = 5
VXLAN_INTERFACE_PREFIX = "vxlan-"
@ -1059,8 +1058,8 @@ def main():
quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
constants.AGENT_TYPE_LINUXBRIDGE,
LB_AGENT_BINARY)
setup_profiler.setup("neutron-linuxbridge-agent", cfg.CONF.host)
constants.AGENT_PROCESS_LINUXBRIDGE)
setup_profiler.setup(constants.AGENT_PROCESS_LINUXBRIDGE, cfg.CONF.host)
LOG.info("Agent initialized successfully, now running... ")
launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
launcher.wait()

View File

@ -36,7 +36,6 @@ from neutron.plugins.ml2.drivers.macvtap import macvtap_common
LOG = logging.getLogger(__name__)
MACVTAP_AGENT_BINARY = "neutron-macvtap-agent"
MACVTAP_FS = "/sys/class/net/"
EXTENSION_DRIVER_TYPE = 'macvtap'
@ -222,7 +221,7 @@ def main():
agent = ca.CommonAgentLoop(manager, polling_interval,
quitting_rpc_timeout,
constants.AGENT_TYPE_MACVTAP,
MACVTAP_AGENT_BINARY)
constants.AGENT_PROCESS_MACVTAP)
LOG.info("Agent initialized successfully, now running... ")
launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
launcher.wait()

View File

@ -172,7 +172,7 @@ class SriovNicSwitchAgent(object):
# TODO(mangelajo): optimize resource_versions (see ovs agent)
self.agent_state = {
'binary': 'neutron-sriov-nic-agent',
'binary': n_constants.AGENT_PROCESS_NIC_SWITCH,
'host': self.conf.host,
'topic': n_constants.L2_AGENT_TOPIC,
'configurations': configurations,
@ -580,6 +580,6 @@ def main():
LOG.exception("Agent Initialization Failed")
raise SystemExit(1)
# Start everything.
setup_profiler.setup("neutron-sriov-nic-agent", cfg.CONF.host)
setup_profiler.setup(n_constants.AGENT_PROCESS_NIC_SWITCH, cfg.CONF.host)
LOG.info("Agent initialized successfully, now running... ")
agent.daemon_loop()

View File

@ -322,7 +322,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# versions about resources which are common,
# or which are used by specific extensions.
self.agent_state = {
'binary': 'neutron-openvswitch-agent',
'binary': n_const.AGENT_PROCESS_OVS,
'host': host,
'topic': n_const.L2_AGENT_TOPIC,
'configurations': {'bridge_mappings': self.bridge_mappings,

View File

@ -253,7 +253,7 @@ class MeteringAgentWithStateReport(MeteringAgent):
self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
self.failed_report_state = False
self.agent_state = {
'binary': 'neutron-metering-agent',
'binary': constants.AGENT_PROCESS_METERING,
'host': host,
'topic': topics.METERING_AGENT,
'configurations': {
@ -302,7 +302,7 @@ def main():
config.setup_logging()
config.setup_privsep()
server = neutron_service.Service.create(
binary='neutron-metering-agent',
binary=constants.AGENT_PROCESS_METERING,
topic=topics.METERING_AGENT,
report_interval=cfg.CONF.AGENT.report_interval,
manager='neutron.services.metering.agents.'

View File

@ -57,7 +57,7 @@ def _get_l3_agent_dict(host, agent_mode, internal_only=True,
az=DEFAULT_AZ):
return {
'agent_type': constants.AGENT_TYPE_L3,
'binary': 'neutron-l3-agent',
'binary': constants.AGENT_PROCESS_L3,
'host': host,
'topic': topics.L3_AGENT,
'availability_zone': az,
@ -82,7 +82,7 @@ def register_l3_agent(host=HOST, agent_mode=constants.L3_AGENT_MODE_LEGACY,
def _get_dhcp_agent_dict(host, networks=0, az=DEFAULT_AZ):
agent = {
'binary': 'neutron-dhcp-agent',
'binary': constants.AGENT_PROCESS_DHCP,
'host': host,
'topic': topics.DHCP_AGENT,
'agent_type': constants.AGENT_TYPE_DHCP,
@ -161,7 +161,7 @@ def _get_l2_agent_dict(host, agent_type, binary, tunnel_types=None,
def register_ovs_agent(host=HOST, agent_type=constants.AGENT_TYPE_OVS,
binary='neutron-openvswitch-agent',
binary=constants.AGENT_PROCESS_OVS,
tunnel_types=['vxlan'], tunneling_ip='20.0.0.1',
interface_mappings=None, bridge_mappings=None,
l2pop_network_types=None, plugin=None, start_flag=True,
@ -176,7 +176,7 @@ def register_ovs_agent(host=HOST, agent_type=constants.AGENT_TYPE_OVS,
def register_linuxbridge_agent(host=HOST,
agent_type=constants.AGENT_TYPE_LINUXBRIDGE,
binary='neutron-linuxbridge-agent',
binary=constants.AGENT_PROCESS_LINUXBRIDGE,
tunnel_types=['vxlan'], tunneling_ip='20.0.0.1',
interface_mappings=None, bridge_mappings=None,
plugin=None):
@ -189,7 +189,7 @@ def register_linuxbridge_agent(host=HOST,
def register_macvtap_agent(host=HOST,
agent_type=constants.AGENT_TYPE_MACVTAP,
binary='neutron-macvtap-agent',
binary=constants.AGENT_PROCESS_MACVTAP,
interface_mappings=None, plugin=None):
agent = _get_l2_agent_dict(host, agent_type, binary,
interface_mappings=interface_mappings)
@ -198,7 +198,7 @@ def register_macvtap_agent(host=HOST,
def register_sriovnicswitch_agent(host=HOST,
agent_type=constants.AGENT_TYPE_NIC_SWITCH,
binary='neutron-sriov-nic-agent',
binary=constants.AGENT_PROCESS_NIC_SWITCH,
device_mappings=None, plugin=None):
agent = _get_l2_agent_dict(host, agent_type, binary,
device_mappings=device_mappings)

View File

@ -19,6 +19,7 @@ import re
import signal
import fixtures
from neutron_lib import constants
from neutronclient.common import exceptions as nc_exc
from neutronclient.v2_0 import client
from oslo_log import log as logging
@ -182,8 +183,6 @@ class NeutronServerFixture(ServiceFixture):
class OVSAgentFixture(ServiceFixture):
NEUTRON_OVS_AGENT = "neutron-openvswitch-agent"
def __init__(self, env_desc, host_desc,
test_name, neutron_cfg_fixture, agent_cfg_fixture):
super(OVSAgentFixture, self).__init__()
@ -205,7 +204,7 @@ class OVSAgentFixture(ServiceFixture):
self.process_fixture = self.useFixture(ProcessFixture(
test_name=self.test_name,
process_name=self.NEUTRON_OVS_AGENT,
process_name=constants.AGENT_PROCESS_OVS,
exec_name=spawn.find_executable(
'ovs_agent.py',
path=os.path.join(fullstack_base.ROOTDIR, CMD_FOLDER)),
@ -237,8 +236,6 @@ class PlacementFixture(fixtures.Fixture):
class SRIOVAgentFixture(ServiceFixture):
NEUTRON_SRIOV_AGENT = "neutron-sriov-nic-agent"
def __init__(self, env_desc, host_desc,
test_name, neutron_cfg_fixture, agent_cfg_fixture):
super(SRIOVAgentFixture, self).__init__()
@ -255,16 +252,14 @@ class SRIOVAgentFixture(ServiceFixture):
self.agent_cfg_fixture.filename]
self.process_fixture = self.useFixture(ProcessFixture(
test_name=self.test_name,
process_name=self.NEUTRON_SRIOV_AGENT,
exec_name=self.NEUTRON_SRIOV_AGENT,
process_name=constants.AGENT_PROCESS_NIC_SWITCH,
exec_name=constants.AGENT_PROCESS_NIC_SWITCH,
config_filenames=config_filenames,
kill_signal=signal.SIGTERM))
class LinuxBridgeAgentFixture(ServiceFixture):
NEUTRON_LINUXBRIDGE_AGENT = "neutron-linuxbridge-agent"
def __init__(self, env_desc, host_desc, test_name,
neutron_cfg_fixture, agent_cfg_fixture,
namespace=None):
@ -285,8 +280,8 @@ class LinuxBridgeAgentFixture(ServiceFixture):
self.process_fixture = self.useFixture(
ProcessFixture(
test_name=self.test_name,
process_name=self.NEUTRON_LINUXBRIDGE_AGENT,
exec_name=self.NEUTRON_LINUXBRIDGE_AGENT,
process_name=constants.AGENT_PROCESS_LINUXBRIDGE,
exec_name=constants.AGENT_PROCESS_LINUXBRIDGE,
config_filenames=config_filenames,
namespace=self.namespace
)
@ -295,8 +290,6 @@ class LinuxBridgeAgentFixture(ServiceFixture):
class L3AgentFixture(ServiceFixture):
NEUTRON_L3_AGENT = "neutron-l3-agent"
def __init__(self, env_desc, host_desc, test_name,
neutron_cfg_fixture, l3_agent_cfg_fixture,
namespace=None):
@ -326,7 +319,7 @@ class L3AgentFixture(ServiceFixture):
self.process_fixture = self.useFixture(
ProcessFixture(
test_name=self.test_name,
process_name=self.NEUTRON_L3_AGENT,
process_name=constants.AGENT_PROCESS_L3,
exec_name=exec_name,
config_filenames=config_filenames,
namespace=self.namespace
@ -339,8 +332,6 @@ class L3AgentFixture(ServiceFixture):
class DhcpAgentFixture(fixtures.Fixture):
NEUTRON_DHCP_AGENT = "neutron-dhcp-agent"
def __init__(self, env_desc, host_desc, test_name,
neutron_cfg_fixture, agent_cfg_fixture, namespace=None):
super(DhcpAgentFixture, self).__init__()
@ -369,7 +360,7 @@ class DhcpAgentFixture(fixtures.Fixture):
self.process_fixture = self.useFixture(
ProcessFixture(
test_name=self.test_name,
process_name=self.NEUTRON_DHCP_AGENT,
process_name=constants.AGENT_PROCESS_DHCP,
exec_name=exec_name,
config_filenames=config_filenames,
namespace=self.namespace

View File

@ -507,7 +507,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
ensure_dir.assert_called_once_with('/the', mode=0o755)
server.assert_has_calls([
mock.call('neutron-metadata-agent'),
mock.call(n_const.AGENT_PROCESS_METADATA),
mock.call().start(handler.return_value,
'/the/path', workers=0,
backlog=128, mode=0o644),

View File

@ -45,8 +45,8 @@ load_tests = testscenarios.load_tests_apply_scenarios
TEST_RESOURCE_VERSIONS = {"A": "1.0"}
AGENT_STATUS = {'agent_type': 'Open vSwitch agent',
'binary': 'neutron-openvswitch-agent',
AGENT_STATUS = {'agent_type': constants.AGENT_TYPE_OVS,
'binary': constants.AGENT_PROCESS_OVS,
'host': 'overcloud-notcompute',
'topic': 'N/A',
'resource_versions': TEST_RESOURCE_VERSIONS}

View File

@ -122,15 +122,16 @@ class AgentDBTestCase(AgentDBTestMixIn,
def test_show_agent(self):
self._register_agent_states()
agents = self._list_agents(
query_string='binary=neutron-l3-agent')
query_string='binary=' + constants.AGENT_PROCESS_L3)
self.assertEqual(2, len(agents['agents']))
agent = self._show('agents', agents['agents'][0]['id'])
self.assertEqual('neutron-l3-agent', agent['agent']['binary'])
self.assertEqual(constants.AGENT_PROCESS_L3, agent['agent']['binary'])
def test_update_agent(self):
self._register_agent_states()
agents = self._list_agents(
query_string='binary=neutron-l3-agent&host=' + L3_HOSTB)
query_string=('binary=' + constants.AGENT_PROCESS_L3 +
'&host=' + L3_HOSTB))
self.assertEqual(1, len(agents['agents']))
com_id = agents['agents'][0]['id']
agent = self._show('agents', com_id)
@ -148,5 +149,6 @@ class AgentDBTestCase(AgentDBTestMixIn,
self._register_agent_states()
time.sleep(1.5)
agents = self._list_agents(
query_string='binary=neutron-l3-agent&host=' + L3_HOSTB)
query_string=('binary=' + constants.AGENT_PROCESS_L3 +
'&host=' + L3_HOSTB))
self.assertFalse(agents['agents'][0]['alive'])

View File

@ -19,6 +19,7 @@ import sys
from unittest import mock
from neutron_lib.agent import topics
from neutron_lib import constants
from neutron_lib.utils import helpers
from oslo_config import cfg
from oslo_service import service
@ -252,7 +253,7 @@ class TestMacvtapMain(base.BaseTestCase):
self.assertTrue(mock_pim.called)
mock_manager.assert_called_with(INTERFACE_MAPPINGS)
mock_loop.assert_called_with(mock_manager_return, 2, 1,
'Macvtap agent',
'neutron-macvtap-agent')
constants.AGENT_TYPE_MACVTAP,
constants.AGENT_PROCESS_MACVTAP)
self.assertTrue(mock_launch.called)
self.assertTrue(mock_launch_return.wait.called)

View File

@ -90,7 +90,7 @@ class SriovSwitchMechGenericTestCase(SriovNicSwitchMechanismBaseTestCase,
def test_driver_responsible_for_ports_allocation(self):
agents = [
{'agent_type': 'NIC Switch agent',
{'agent_type': constants.AGENT_TYPE_NIC_SWITCH,
'configurations': {'resource_provider_bandwidths': {'eth0': {}}},
'host': 'host',
'id': '1'}

View File

@ -173,7 +173,7 @@ class OpenvswitchMechanismGenericTestCase(OpenvswitchMechanismBaseTestCase,
base.AgentMechanismGenericTestCase):
def test_driver_responsible_for_ports_allocation(self):
agents = [
{'agent_type': 'Open vSwitch agent',
{'agent_type': constants.AGENT_TYPE_OVS,
'configurations': {'resource_provider_bandwidths': {'eth0': {}}},
'id': '1',
'host': 'host'}

View File

@ -0,0 +1,16 @@
---
features:
- |
A previous change to set neutron-server child process names also modified
neutron agent ones. This can impact monitoring systems relying on
/proc/PID/environ formatting or `ps -e` output. Now neutron agents all have
process names formatted this way (showing both an old style process name
and full process name visible in recent releases)
``neutron-agent-name`` (``original process name including interpreter``)
See bug `1881297 <https://bugs.launchpad.net/neutron/+bug/1881297>`_
for more details.
upgrade:
- |
Monitoring tools relying on exact process names should be checked after
upgrade, and modified if needed.