nova-manage Tracebeck on missing arg

Bug #1837199 reported by Attila Fazekas
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Matt Riedemann
Queens
Confirmed
Low
Unassigned
Stein
Confirmed
Low
Unassigned
Train
Fix Released
Low
Stephen Finucane

Bug Description

# nova-manage cell_v2
An error has occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/oslo_config/cfg.py", line 3179, in __getattr__
    return getattr(self._conf._namespace, name)
AttributeError: '_Namespace' object has no attribute 'action_fn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/stack/nova/nova/cmd/manage.py", line 2205, in main
    fn, fn_args, fn_kwargs = cmd_common.get_action_fn()
  File "/opt/stack/nova/nova/cmd/common.py", line 169, in get_action_fn
    fn = CONF.category.action_fn
  File "/usr/local/lib/python3.7/site-packages/oslo_config/cfg.py", line 3181, in __getattr__
    raise NoSuchOptError(name)
oslo_config.cfg.NoSuchOptError: no such option action_fn in group [DEFAULT]

# nova-manage cell_v2 help
usage: nova-manage cell_v2 [-h]
                           {create_cell,delete_cell,delete_host,discover_hosts,list_cells,list_hosts,map_cell0,map_cell_and_hosts,map_instances,simple_cell_setup,update_cell,verify_instance}
                           ...
nova-manage cell_v2: error: argument action: invalid choice: 'help' (choose from 'create_cell', 'delete_cell', 'delete_host', 'discover_hosts', 'list_cells', 'list_hosts', 'map_cell0', 'map_cell_and_hosts', 'map_instances', 'simple_cell_setup', 'update_cell', 'verify_instance')

# nova-manage cell_v2 -h
usage: nova-manage cell_v2 [-h]
                           {create_cell,delete_cell,delete_host,discover_hosts,list_cells,list_hosts,map_cell0,map_cell_and_hosts,map_instances,simple_cell_setup,update_cell,verify_instance}
                           ...

positional arguments:
  {create_cell,delete_cell,delete_host,discover_hosts,list_cells,list_hosts,map_cell0,map_cell_and_hosts,map_instances,simple_cell_setup,update_cell,verify_instance}

optional arguments:
  -h, --help show this help message and exit

python version:
/usr/bin/python3 --version
Python 3.7.3

nova version:
$ git log -1
commit 78f9961d293e3b3e0ac62345b78abb1c9e2bd128 (HEAD -> master, origin/master, origin/HEAD)

oslo.config 6.11.0

Instead of printing Traceback, nova-manage should give a hint for the user choices.

Tags: nova-manage
description: updated
Revision history for this message
Takashi Natsume (natsume-takashi) wrote :

I could not reproduce the issue in the following environment.

nova master commit 063ef486e93bbef1628aa722b96bbd86290361cd
nova-manage 19.1.0 (nova-manage --version)
oslo.config 6.11.0
Python 3.6.7

stack@devstack-master:~/nova$ nova-manage cell_v2
usage: nova-manage cell_v2 [-h]
                           {create_cell,delete_cell,delete_host,discover_hosts,list_cells,list_hosts,map_cell0,map_cell_and_hosts,map_instances,simple_cell_setup,update_cell,verify_instance}
                           ...
nova-manage cell_v2: error: too few arguments

tags: added: nova-manage
Revision history for this message
Matt Riedemann (mriedem) wrote :

I just recreated this locally on master in a local venv:

osboxes@osboxes:~/git/nova$ source .tox/shared/bin/activate
(shared) osboxes@osboxes:~/git/nova$ nova-manage cell_v2
An error has occurred:
Traceback (most recent call last):
  File "/home/osboxes/git/nova/.tox/shared/lib/python3.6/site-packages/oslo_config/cfg.py", line 3179, in __getattr__
    return getattr(self._conf._namespace, name)
AttributeError: '_Namespace' object has no attribute 'action_fn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/osboxes/git/nova/nova/cmd/manage.py", line 2206, in main
    fn, fn_args, fn_kwargs = cmd_common.get_action_fn()
  File "/home/osboxes/git/nova/nova/cmd/common.py", line 169, in get_action_fn
    fn = CONF.category.action_fn
  File "/home/osboxes/git/nova/.tox/shared/lib/python3.6/site-packages/oslo_config/cfg.py", line 3181, in __getattr__
    raise NoSuchOptError(name)
oslo_config.cfg.NoSuchOptError: no such option action_fn in group [DEFAULT]

(shared) osboxes@osboxes:~/git/nova$ pip show oslo.config
Name: oslo.config
Version: 6.11.0
Summary: Oslo Configuration API
Home-page: https://docs.openstack.org/oslo.config/latest/
Author: OpenStack
Author-email: <email address hidden>
License: UNKNOWN
Location: /home/osboxes/git/nova/.tox/shared/lib/python3.6/site-packages
Requires: oslo.i18n, PyYAML, requests, six, rfc3986, debtcollector, netaddr, stevedore
Required-by: python-keystoneclient, pycadf, oslo.versionedobjects, oslo.upgradecheck, oslo.service, oslo.privsep, oslo.policy, oslo.middleware, oslo.messaging, oslo.log, oslo.db, oslo.concurrency, oslo.cache, os-win, os-vif, keystonemiddleware, castellan, nova
(shared) osboxes@osboxes:~/git/nova$

Matt Riedemann (mriedem)
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
Matt Riedemann (mriedem)
no longer affects: oslo.config
Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/694806

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Matt Riedemann (mriedem) wrote :

Something must have regressed in Queens because going back to Pike this still works:

usage: nova-manage db [-h]
                      {archive_deleted_rows,ironic_flavor_migration,null_instance_uuid_scan,online_data_migrations,sync,version}
                      ...
nova-manage db: error: too few arguments

I don't see anything obvious in the nova-manage code in Queens that changed so it must have been something in oslo.config.

Changed in nova:
assignee: Matt Riedemann (mriedem) → Stephen Finucane (stephenfinucane)
Matt Riedemann (mriedem)
Changed in nova:
assignee: Stephen Finucane (stephenfinucane) → Matt Riedemann (mriedem)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.opendev.org/694806
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=51b0d4ca58f70fdd887dd053bfae1b2c918c33ba
Submitter: Zuul
Branch: master

commit 51b0d4ca58f70fdd887dd053bfae1b2c918c33ba
Author: Matt Riedemann <email address hidden>
Date: Mon Nov 18 11:36:20 2019 -0500

    Print help if nova-manage subcommand is not specified

    If a nova-manage command is executed without the -h option
    or a subcommand the user gets an ugly traceback. This is
    easily recreated:

      $ tox -e venv -- nova-manage db

    Make the action argument required, so we get a helpful error message
    instead.

      $ nova-manage db
      usage: nova-manage db [-h]
                          {archive_deleted_rows,ironic_flavor_migration,
                           null_instance_uuid_scan,online_data_migrations,
                           purge,sync,version}
                          ...
      nova-manage db: error: the following arguments are required: action

    Note that unit tests appear to be impossible for this, since doing so
    attempts to initialize an oslo.config 'CONF' singleton and this is
    something we've already done in 'nova.test' and can't do again.

    Change-Id: I24d03eed3aa3b882c49916938f4c25d76fd4e831
    Closes-Bug: #1837199
    Co-Authored-By: Stephen Finucane <email address hidden>

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/702637

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/train)

Reviewed: https://review.opendev.org/702637
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=48f9b1c2ce798dc4a7f6b7b54dfaf38760d3a730
Submitter: Zuul
Branch: stable/train

commit 48f9b1c2ce798dc4a7f6b7b54dfaf38760d3a730
Author: Matt Riedemann <email address hidden>
Date: Mon Nov 18 11:36:20 2019 -0500

    Print help if nova-manage subcommand is not specified

    If a nova-manage command is executed without the -h option
    or a subcommand the user gets an ugly traceback. This is
    easily recreated:

      $ tox -e venv -- nova-manage db

    Make the action argument required, so we get a helpful error message
    instead.

      $ nova-manage db
      usage: nova-manage db [-h]
                          {archive_deleted_rows,ironic_flavor_migration,
                           null_instance_uuid_scan,online_data_migrations,
                           purge,sync,version}
                          ...
      nova-manage db: error: the following arguments are required: action

    Note that unit tests appear to be impossible for this, since doing so
    attempts to initialize an oslo.config 'CONF' singleton and this is
    something we've already done in 'nova.test' and can't do again.

    Change-Id: I24d03eed3aa3b882c49916938f4c25d76fd4e831
    Closes-Bug: #1837199
    Co-Authored-By: Stephen Finucane <email address hidden>
    (cherry picked from commit 51b0d4ca58f70fdd887dd053bfae1b2c918c33ba)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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