neutron-remove-duplicated-port-bindings does not write to stdout

Bug #2012944 reported by Simon Hensel
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
neutron
In Progress
Medium
Miguel Lavalle

Bug Description

The new neutron-remove-duplicated-port-bindings tool does not log any information when run from the CLI, as the log levels are mismatching.

The logger gets initialized with log_level = WARNING, but the tool uses LOG.info() to display its messages, therefore the user never receives any results.
Furthermore, the logger does not take into account any parameters from the neutron config file during its initialization, and instead relies on its default settings, so log-related settings (log-level, log-path, etc.) cannot be changed.

On another note, dry-running is only possible when setting [cli_script] dry_run=True in the neutron config file, which is inconvenient to say the least.
A proper --debug CLI option would be way more helpful.

Revision history for this message
Miguel Lavalle (minsel) wrote :

The script neutron-remove-duplicated-port-bindings gets a logger here https://opendev.org/openstack/neutron/src/branch/master/neutron/cmd/remove_duplicated_port_bindings.py#L27, which calls oslo.log which in turn calls Python's logging facility here: https://github.com/openstack/oslo.log/blob/master/oslo_log/log.py#L507. The default Python logging level is WARNING. So, yes, since the code logs at INFO level, nothing gets logged.

We should call https://opendev.org/openstack/neutron/src/branch/master/neutron/common/config.py#L111 to initialize logging, like in for example https://opendev.org/openstack/neutron/src/branch/master/neutron/cmd/netns_cleanup.py#L271. This calls oslo.log setup which sets logging level at INFO level by default: https://github.com/openstack/oslo.log/blob/master/oslo_log/log.py#L352

Changed in neutron:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Miguel Lavalle (minsel)
Revision history for this message
Christian Rohmann (christian-rohmann) wrote :

Is there any way to also allow for the dry run option to be given in the command line?
Currently this needs to be set via config file.

Revision history for this message
Christian Rohmann (christian-rohmann) wrote :

Miguel are you still working on fixing this?

Revision history for this message
Elod Illes (elod-illes) wrote :

hi Christian,

this does not seem to have a nova related issue, i guess you added nova accidentally, so i'm removing Nova as affected component. If i misunderstood something then please let me know and add further detail.

Thanks,

Elod

no longer affects: nova
Revision history for this message
Christian Rohmann (christian-rohmann) wrote :

Yes Elod, this very issue is NOT a Nova issue. But the whole reason the `neutron-remove-duplicated-port-bindings` tool exists is a bug in Nova: https://bugs.launchpad.net/nova/+bug/1822884

I am wondering why this cannot be fixed and some point an Neutron has to contain tools to clean up the pieces.

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

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/neutron/+/917056

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
Lajos Katona (lajos-katona) wrote :

The above patch fixes in a dirty way the dry-run problem to overwrite the cfg option from CLI:
$ neutron-remove-duplicated-port-bindings --config-dir /etc/neutron --neutron_cli_opts-dry_run

but I can't make logging work, I even can't find where the log will be, I have a feeling that logging cfg should be parsed but there are several --debug options and I have to handle that, and even after I am not sure I am at the end.

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.