From 545df90f0af1418e9b53dd933e5bb916c4cc9046 Mon Sep 17 00:00:00 2001 From: Ryan Moats Date: Fri, 21 Aug 2015 09:16:52 -0500 Subject: [PATCH] Rationalize neutron logs to help in troubleshooting router issues Currently the neutron logs are not very useful for troubleshooting router issues - this patch adds additional logging statements to help the triage process. Change-Id: I014e0119205d4a947a1be142aeeb29940c4de3bd Signed-off-by: Ryan Moats --- neutron/agent/l3/dvr_fip_ns.py | 4 +++- neutron/agent/l3/dvr_local_router.py | 5 +++-- neutron/agent/l3/router_info.py | 15 ++++++++++++++- neutron/agent/linux/interface.py | 4 ++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/neutron/agent/l3/dvr_fip_ns.py b/neutron/agent/l3/dvr_fip_ns.py index bec1eb6c5..7b5894d19 100644 --- a/neutron/agent/l3/dvr_fip_ns.py +++ b/neutron/agent/l3/dvr_fip_ns.py @@ -96,6 +96,7 @@ class FipNamespace(namespaces.Namespace): def _gateway_added(self, ex_gw_port, interface_name): """Add Floating IP gateway port.""" + LOG.debug("add gateway interface(%s)", interface_name) ns_name = self.get_name() self.driver.plug(ex_gw_port['network_id'], ex_gw_port['id'], @@ -129,6 +130,7 @@ class FipNamespace(namespaces.Namespace): def create(self): # TODO(Carl) Get this functionality from mlavelle's namespace baseclass + LOG.debug("add fip-namespace(%s)", self.name) ip_wrapper_root = ip_lib.IPWrapper() ip_wrapper_root.netns.execute(['sysctl', '-w', @@ -175,7 +177,6 @@ class FipNamespace(namespaces.Namespace): """ self.agent_gateway_port = agent_gateway_port - # add fip-namespace and agent_gateway_port self.create() iface_name = self.get_ext_device_name(agent_gateway_port['id']) @@ -189,6 +190,7 @@ class FipNamespace(namespaces.Namespace): def create_rtr_2_fip_link(self, ri): """Create interface between router and Floating IP namespace.""" + LOG.debug("Create FIP link interfaces for router %s", ri.router_id) rtr_2_fip_name = self.get_rtr_ext_device_name(ri.router_id) fip_2_rtr_name = self.get_int_device_name(ri.router_id) fip_ns_name = self.get_name() diff --git a/neutron/agent/l3/dvr_local_router.py b/neutron/agent/l3/dvr_local_router.py index 42399144c..6e5b37028 100644 --- a/neutron/agent/l3/dvr_local_router.py +++ b/neutron/agent/l3/dvr_local_router.py @@ -373,8 +373,9 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase): floating_ips = self.get_floating_ips() fip_agent_port = self.get_floating_agent_gw_interface( ex_gw_port['network_id']) - LOG.debug("FloatingIP agent gateway port received from the plugin: " - "%s", fip_agent_port) + if fip_agent_port: + LOG.debug("FloatingIP agent gateway port received from the " + "plugin: %s", fip_agent_port) is_first = False if floating_ips: is_first = self.fip_ns.subscribe(self.router_id) diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py index 81bca3877..ba20be41e 100644 --- a/neutron/agent/l3/router_info.py +++ b/neutron/agent/l3/router_info.py @@ -238,6 +238,8 @@ class RouterInfo(object): ip_cidr for ip_cidr in existing_cidrs - new_cidrs if common_utils.is_cidr_host(ip_cidr)) for ip_cidr in fips_to_remove: + LOG.debug("Removing floating ip %s from interface %s in " + "namespace %s", ip_cidr, interface_name, self.ns_name) self.remove_floating_ip(device, ip_cidr) return fip_statuses @@ -268,6 +270,8 @@ class RouterInfo(object): def _internal_network_added(self, ns_name, network_id, port_id, fixed_ips, mac_address, interface_name, prefix): + LOG.debug("adding internal network: prefix(%s), port(%s)", + prefix, port_id) self.driver.plug(network_id, port_id, interface_name, mac_address, namespace=ns_name, prefix=prefix) @@ -299,7 +303,8 @@ class RouterInfo(object): def internal_network_removed(self, port): interface_name = self.get_internal_device_name(port['id']) - + LOG.debug("removing internal network: port(%s) interface(%s)", + port['id'], interface_name) if ip_lib.device_exists(interface_name, namespace=self.ns_name): self.driver.unplug(interface_name, namespace=self.ns_name, prefix=INTERNAL_DEV_PREFIX) @@ -360,11 +365,13 @@ class RouterInfo(object): enable_ra = False for p in new_ports: self.internal_network_added(p) + LOG.debug("appending port %s to internal_ports cache", p) self.internal_ports.append(p) enable_ra = enable_ra or self._port_has_ipv6_subnet(p) for p in old_ports: self.internal_network_removed(p) + LOG.debug("removing port %s from internal_ports cache", p) self.internal_ports.remove(p) enable_ra = enable_ra or self._port_has_ipv6_subnet(p) @@ -375,6 +382,7 @@ class RouterInfo(object): self.internal_ports[index] = updated_ports[p['id']] interface_name = self.get_internal_device_name(p['id']) ip_cidrs = common_utils.fixed_ip_cidrs(p['fixed_ips']) + LOG.debug("updating internal network for port %s", p) self.internal_network_updated(interface_name, ip_cidrs) enable_ra = enable_ra or self._port_has_ipv6_subnet(p) @@ -432,6 +440,8 @@ class RouterInfo(object): def _external_gateway_added(self, ex_gw_port, interface_name, ns_name, preserve_ips): + LOG.debug("External gateway added: port(%s), interface(%s), ns(%s)", + ex_gw_port, interface_name, ns_name) self._plug_external_gateway(ex_gw_port, interface_name, ns_name) # Build up the interface and gateway IP addresses that @@ -473,6 +483,8 @@ class RouterInfo(object): ex_gw_port, interface_name, self.ns_name, preserve_ips) def external_gateway_removed(self, ex_gw_port, interface_name): + LOG.debug("External gateway removed: port(%s), interface(%s)", + ex_gw_port, interface_name) self.driver.unplug(interface_name, bridge=self.agent_conf.external_network_bridge, namespace=self.ns_name, @@ -611,6 +623,7 @@ class RouterInfo(object): :param agent: Passes the agent in order to send RPC messages. """ + LOG.debug("process router updates") self._process_internal_ports() self.process_external(agent) # Process static routes for router diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 9207503e7..c76278bb2 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -116,6 +116,8 @@ class LinuxInterfaceDriver(object): associated to removed ips extra_subnets: An iterable of cidrs to add as routes without address """ + LOG.debug("init_router_port: device_name(%s), namespace(%s)", + device_name, namespace) self.init_l3(device_name=device_name, ip_cidrs=ip_cidrs, namespace=namespace, @@ -134,8 +136,10 @@ class LinuxInterfaceDriver(object): device.route.list_onlink_routes(n_const.IP_VERSION_4) + device.route.list_onlink_routes(n_const.IP_VERSION_6)) for route in new_onlink_routes - existing_onlink_routes: + LOG.debug("adding onlink route(%s)", route) device.route.add_onlink_route(route) for route in existing_onlink_routes - new_onlink_routes: + LOG.debug("deleting onlink route(%s)", route) device.route.delete_onlink_route(route) def check_bridge_exists(self, bridge): -- 2.45.2