Bug 2216468

Summary: openstack volume snapshot list --state should be using error_deleting but is using error-deleting
Product: Red Hat OpenStack Reporter: coldford <coldford>
Component: python-openstackclientAssignee: Cinder Bugs List <cinder-bugs>
Status: NEW --- QA Contact: Nobody <nobody>
Severity: medium Docs Contact:
Priority: medium    
Version: 16.2 (Train)CC: apevec, eharney, eprado, gconsalv, jpichon, lhh, tkajinam
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description coldford@redhat.com 2023-06-21 14:14:46 UTC
Description of problem:

$ openstack volume snapshot list --state should be using error_deleting but is using error-deleting.

Here we see volume snapshots with the status error_deleting:

(overcloud) [stack@director ~]$ openstack volume snapshot list  --all-projects | grep error_deleting
| bac27b54-b468-4e52-a30a-514066359199 | TrilioVaultSnapshot-534ab6fe-a3b5-41fa-873e-99a172dd9c24                        | TrilioVault initiated snapshot     | error_deleting |  5537 |

But when we check for that status we get the following:

(overcloud) [stack@director ~]$ openstack volume snapshot list  --all-projects --status error_deleting

usage: openstack volume snapshot list [-h] [-f {csv,json,table,value,yaml}]
                                      [-c COLUMN]
                                      [--quote {all,minimal,none,nonnumeric}]
                                      [--noindent] [--max-width <integer>]
                                      [--fit-width] [--print-empty]
                                      [--sort-column SORT_COLUMN]
                                      [--all-projects] [--project <project>]
                                      [--project-domain <project-domain>]
                                      [--long] [--marker <volume-snapshot>]
                                      [--limit <num-snapshots>]
                                      [--name <name>] [--status <status>]
                                      [--volume <volume>]
openstack volume snapshot list: error: argument --status: invalid choice: 'error_deleting' (choose from 'available', 'error', 'creating', 'deleting', 'error-deleting')

If we try with the suggested error-deleting we get no matches:

(overcloud) [stack@director ~]$ openstack volume snapshot list  --all-projects --status error-deleting
(overcloud) [stack@director ~]$

It seems the latest version python3-openstackclient-4.0.2-2.20221012154730.54bf2c0.el8ost.noarch.rpm for RHOSP 16.2 has this bug in both the API v1 and v2 code paths:

./usr/lib/python3.6/site-packages/openstackclient/volume/v1/volume_snapshot.py
./usr/lib/python3.6/site-packages/openstackclient/volume/v2/volume_snapshot.py

// EXAMPLE:
class ListVolumeSnapshot(command.Lister):
    _description = _("List volume snapshots")

    def get_parser(self, prog_name):
        parser = super(ListVolumeSnapshot, self).get_parser(prog_name)
        parser.add_argument(
            '--all-projects',
            action='store_true',
            default=False,
            help=_('Include all projects (admin only)'),
        )
        parser.add_argument(
            '--long', 
            action='store_true',
            default=False,
            help=_('List additional fields in output'),
        )
        parser.add_argument(
            '--name',
            metavar='<name>',
            default=None,
            help=_('Filters results by a name.')
        )
        parser.add_argument(
            '--status',
            metavar='<status>', 
            choices=['available', 'error', 'creating', 'deleting',
                     'error-deleting'],                                             <------ INCORRECT
            help=_("Filters results by a status. "
                   "('available', 'error', 'creating', 'deleting'"
                   " or 'error-deleting')")                                         <------ INCORRECT
        )
        parser.add_argument(
            '--volume',
            metavar='<volume>',
            default=None,
            help=_('Filters results by a volume (name or ID).')
        )
        return parser



Version-Release number of selected component (if applicable):
python3-openstackclient-4.0.2-2.20221012154730.54bf2c0.el8ost.noarch.rpm

How reproducible:

Every execution of:
- openstack volume snapshot list --state error_deleting

Expected results:

It should match the error_deleting state of the volumes of interest.

This seems to be fixed both upstream and in the beta rpm:
- python3-openstackclient-5.5.2-1.20230404121004.42d9b6e.el9ost.noarch.rpm

class ListVolumeSnapshot(command.Lister):
    _description = _("List volume snapshots")

    def get_parser(self, prog_name):
        parser = super(ListVolumeSnapshot, self).get_parser(prog_name)
        parser.add_argument(
            '--all-projects',
            action='store_true',
            default=False,
            help=_('Include all projects (admin only)'),
        )
        parser.add_argument(
            '--long',
            action='store_true',
            default=False,
            help=_('List additional fields in output'),
        )
        parser.add_argument(
            '--name',
            metavar='<name>', 
            default=None,
            help=_('Filters results by a name.')
        )
        parser.add_argument(
            '--status',
            metavar='<status>',
            choices=['available', 'error', 'creating', 'deleting', 
                     'error_deleting'],                                                <----- CORRECT
            help=_("Filters results by a status. "
                   "('available', 'error', 'creating', 'deleting'"
                   " or 'error_deleting')")                                            <----- CORRECT


Additional info:
- None.