neutronclient shows low-level logs in console screen

Bug #1356735 reported by Feng Xi Yan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-neutronclient
Fix Released
Medium
Feng Xi Yan

Bug Description

Problem summary:
All neutron command will show 1 ˜3 lines of "Starting new HTTP connection (1): <ip of the controller>", I think these sentence are no impact to the command result, and useless to customers,
And other component do not show such sentence, like nova, glance, only neutron command will display these sentence, all component should keep the same format for their command, these sentence are easy to make customers think there is error with neutron.
So neutron command should not display these sentence.

Test Steps:
1. install neutron

2. Run neutron command

[root@cmwo81 home]# neutron net-create net_local --provider:network_type local
Starting new HTTP connection (1): 10.104.0.81
Starting new HTTP connection (1): 10.104.0.81
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | 44f104cb-7cd7-47f7-bf24-7f57f8b5724f |
| name | net_local |
| provider:network_type | local |
| provider:physical_network | |
| provider:segmentation_id | |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 1227a7d1ab094fb8a92d13a4ffd3a0a5 |
+---------------------------+--------------------------------------+

[root@cmwo81 home]# neutron subnet-create net_local 10.0.1.0/24 --name sub_netlocal --dns-nameserver 10.0.1.1
Starting new HTTP connection (1): 10.104.0.81
Starting new HTTP connection (1): 10.104.0.81
Starting new HTTP connection (1): 10.104.0.81
Created a new subnet:
+-------------------+--------------------------------------------+
| Field | Value |
+-------------------+--------------------------------------------+
| allocation_pools | {"start": "10.0.1.2", "end": "10.0.1.254"} |
| cidr | 10.0.1.0/24 |
| dns_nameservers | 10.0.1.1 |
| enable_dhcp | True |
| gateway_ip | 10.0.1.1 |
| host_routes | |
| id | ebf6d6c5-5cbf-4bee-ad70-06bbbe254943 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | sub_netlocal |
| network_id | 44f104cb-7cd7-47f7-bf24-7f57f8b5724f |
| tenant_id | 1227a7d1ab094fb8a92d13a4ffd3a0a5 |
+-------------------+--------------------------------------------+

[root@cmwo81 ˜]# neutron net-list
Starting new HTTP connection (1): 10.104.0.81
Starting new HTTP connection (1): 10.104.0.81
Starting new HTTP connection (1): 10.104.0.81
+--------------------------------------+-----------+--------------------------------------------------+
| id | name | subnets |
+--------------------------------------+-----------+--------------------------------------------------+
| 44f104cb-7cd7-47f7-bf24-7f57f8b5724f | net_local | ebf6d6c5-5cbf-4bee-ad70-06bbbe254943 10.0.1.0/24 |
+--------------------------------------+-----------+--------------------------------------------------+

Expected result:
neutron command does not show "Starting new HTTP connection (1): 10.104.0.81". for example, the expected result of neutron net-list should be as below:
[root@cmwo81 ˜]# neutron net-list
+--------------------------------------+-----------+--------------------------------------------------+
| id | name | subnets |
+--------------------------------------+-----------+--------------------------------------------------+
| 44f104cb-7cd7-47f7-bf24-7f57f8b5724f | net_local | ebf6d6c5-5cbf-4bee-ad70-06bbbe254943 10.0.1.0/24 |
+--------------------------------------+-----------+--------------------------------------------------+

Revision history for this message
Feng Xi Yan (yanfengxi) wrote :

vim neutronclient/shell.py

def configure_logging(self):
        """Create logging handlers for any log output."""
        root_logger = logging.getLogger('')

        # Set up logging to a file
        root_logger.setLevel(logging.DEBUG)

        # Send higher-level messages to the console via stderr
        console = logging.StreamHandler(self.stderr)
        console_level = {self.WARNING_LEVEL: logging.WARNING,
                         self.INFO_LEVEL: logging.INFO,
                         self.DEBUG_LEVEL: logging.DEBUG,
                         }.get(self.options.verbose_level, logging.DEBUG)
        console.setLevel(console_level)
        if logging.DEBUG == console_level:
            formatter = logging.Formatter(self.DEBUG_MESSAGE_FORMAT)
        else:
            formatter = logging.Formatter(self.CONSOLE_MESSAGE_FORMAT)
        console.setFormatter(formatter)
        root_logger.addHandler(console)
        return

As the code says, there is a console stream to display higher-level messages.
But the log "Starting new HTTP connection (1): 10.104.0.81" is a low-level(INFO) log of urllib3

def _new_conn(self):
        """
        Return a fresh :class:`httplib.HTTPConnection`.
        """
        self.num_connections += 1
        log.info("Starting new HTTP connection (%d): %s" %
                 (self.num_connections, self.host))
        return HTTPConnection(host=self.host, port=self.port)

We should set the log_level of the console stream to WARNING to avoid displaying low level logs.
If we want to use --debug to display detailed messages, we should set the log level of the console stream to DEBUG.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/114164

Changed in python-neutronclient:
assignee: nobody → Feng Xi Yan (yanfengxi)
status: New → In Progress
Akihiro Motoki (amotoki)
Changed in python-neutronclient:
importance: Undecided → Medium
milestone: none → 2.3.7
Akihiro Motoki (amotoki)
Changed in python-neutronclient:
milestone: 2.3.7 → 2.3.8
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-neutronclient (master)

Reviewed: https://review.openstack.org/114164
Committed: https://git.openstack.org/cgit/openstack/python-neutronclient/commit/?id=d9de6b9ecd800a3147030ecea3a75e47a07394b3
Submitter: Jenkins
Branch: master

commit d9de6b9ecd800a3147030ecea3a75e47a07394b3
Author: Feng Xi Yan <email address hidden>
Date: Thu Aug 14 16:20:58 2014 +0800

    neutronclient shows low-level logs in console screen

    Neutron command lines always display some useless information. This
    should be avoided. This commit modifies the default level of console
    stream to WARNING.

    Closes-bug: #1356735

    Change-Id: I997dad9ce3fc3eb795e4e44b27d211fa619c1907

Changed in python-neutronclient:
status: In Progress → Fix Committed
Akihiro Motoki (amotoki)
Changed in python-neutronclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.