ovs-agent: Trace remote methods only

Enabling osprofiler tracing on class OVSNeutronAgent decorates all of
its methods. Doing this as label "rpc" for locally called methods is
quite misleading.

More importantly later we want to enable tracing triggered by a vif
plug. For that profiler.init() must be called sometime in
OVSNeutronAgent.process_ports_events(). If process_ports_events() is
decorated for tracing and we call profiler.init() inside then we'll have
the end of the method call traced, but not its beginning. The unmatching
end-trace-event makes osprofiler raise.

Change-Id: I06b8643c75a30b5a5f6f78d75af9937180da645b
Partial-Bug: #1833674
This commit is contained in:
Bence Romsics 2019-06-25 15:55:36 +02:00
parent 3b2521a894
commit 0299746c72
1 changed files with 7 additions and 1 deletions

View File

@ -96,7 +96,6 @@ def has_zero_prefixlen_address(ip_addresses):
return any(netaddr.IPNetwork(ip).prefixlen == 0 for ip in ip_addresses) return any(netaddr.IPNetwork(ip).prefixlen == 0 for ip in ip_addresses)
@profiler.trace_cls("rpc")
class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
dvr_rpc.DVRAgentRpcCallbackMixin): dvr_rpc.DVRAgentRpcCallbackMixin):
'''Implements OVS-based tunneling, VLANs and flat networks. '''Implements OVS-based tunneling, VLANs and flat networks.
@ -479,6 +478,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
consumers, consumers,
start_listening=False) start_listening=False)
@profiler.trace("rpc")
def port_update(self, context, **kwargs): def port_update(self, context, **kwargs):
port = kwargs.get('port') port = kwargs.get('port')
agent_restarted = kwargs.pop("agent_restarted", False) agent_restarted = kwargs.pop("agent_restarted", False)
@ -568,11 +568,13 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
'iface_id': port_data['id'], 'iface_id': port_data['id'],
'vif_type': port_binding['vif_type']}) 'vif_type': port_binding['vif_type']})
@profiler.trace("rpc")
def port_delete(self, context, **kwargs): def port_delete(self, context, **kwargs):
port_id = kwargs.get('port_id') port_id = kwargs.get('port_id')
self.deleted_ports.add(port_id) self.deleted_ports.add(port_id)
self.updated_ports.discard(port_id) self.updated_ports.discard(port_id)
@profiler.trace("rpc")
def network_update(self, context, **kwargs): def network_update(self, context, **kwargs):
network_id = kwargs['network']['id'] network_id = kwargs['network']['id']
network = self.plugin_rpc.get_network_details( network = self.plugin_rpc.get_network_details(
@ -588,12 +590,14 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
{'network_id': network_id, {'network_id': network_id,
'ports': self.network_ports[network_id]}) 'ports': self.network_ports[network_id]})
@profiler.trace("rpc")
def binding_deactivate(self, context, **kwargs): def binding_deactivate(self, context, **kwargs):
if kwargs.get('host') != self.conf.host: if kwargs.get('host') != self.conf.host:
return return
port_id = kwargs.get('port_id') port_id = kwargs.get('port_id')
self.deactivated_bindings.add(port_id) self.deactivated_bindings.add(port_id)
@profiler.trace("rpc")
def binding_activate(self, context, **kwargs): def binding_activate(self, context, **kwargs):
if kwargs.get('host') != self.conf.host: if kwargs.get('host') != self.conf.host:
return return
@ -661,6 +665,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# ...and treat them as just added # ...and treat them as just added
port_info['added'] |= activated_bindings_copy port_info['added'] |= activated_bindings_copy
@profiler.trace("rpc")
def tunnel_update(self, context, **kwargs): def tunnel_update(self, context, **kwargs):
LOG.debug("tunnel_update received") LOG.debug("tunnel_update received")
if not self.enable_tunneling: if not self.enable_tunneling:
@ -684,6 +689,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
tunnel_type) tunnel_type)
self._setup_tunnel_flood_flow(self.tun_br, tunnel_type) self._setup_tunnel_flood_flow(self.tun_br, tunnel_type)
@profiler.trace("rpc")
def tunnel_delete(self, context, **kwargs): def tunnel_delete(self, context, **kwargs):
LOG.debug("tunnel_delete received") LOG.debug("tunnel_delete received")
if not self.enable_tunneling: if not self.enable_tunneling: