Zone list all projects fails in interactive OSC prompt after previous identical command

Bug #1844028 reported by Joseph M
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-designateclient
Fix Released
High
Joseph M

Bug Description

Designate client version: master

The "zone list --all-projects" command has an issue when run twice from an interactive (openstack) prompt:

$ OS_CLOUD=admin OS_REGION_NAME=lax1 openstack
(openstack) zone list --all-projects
+--------------------------------------+--------------------------------------+---------------------------+---------+------------+--------+--------+
| id | project_id | name | type | serial | status | action |
+--------------------------------------+--------------------------------------+---------------------------+---------+------------+--------+--------+
| a064f09f-ffd6-4faa-89cc-add36a1765d1 | 16438941d21b4d01948f70c0be58c744 | redacted. | PRIMARY | 1568253176 | ACTIVE | NONE |
| df9c81e5-7c69-45e1-9056-c6e3e5476458 | 00000000-0000-0000-0000-000000000000 | redacted.in-addr.arpa. | PRIMARY | 1568254389 | ACTIVE | NONE |
| eedc6039-28a4-462b-9ada-67a6d2df1488 | 6a1421e443b941039befca0a6f65d108 | redacted. | PRIMARY | 1568303480 | ACTIVE | NONE |
+--------------------------------------+--------------------------------------+---------------------------+---------+------------+--------+--------+
(openstack) zone list --all-projects
Field names must be unique!

This is caused by the following line trying to add a new column to the result without checking if the column already exists:

https://opendev.org/openstack/python-designateclient/src/branch/master/designateclient/v2/cli/zones.py#L96

This data is then passed to prettytables which then errors because the field names aren't unique:

Traceback (most recent call last):
  File "/opt/openstack-venv/lib/python3.7/site-packages/cliff/app.py", line 401, in run_subcommand
    result = cmd.run(parsed_args)
  File "/opt/openstack-venv/lib/python3.7/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/opt/openstack-venv/lib/python3.7/site-packages/cliff/display.py", line 119, in run
    self.produce_output(parsed_args, column_names, data)
  File "/opt/openstack-venv/lib/python3.7/site-packages/cliff/lister.py", line 82, in produce_output
    parsed_args,
  File "/opt/openstack-venv/lib/python3.7/site-packages/cliff/formatters/table.py", line 95, in emit_list
    print_empty=parsed_args.print_empty,
  File "/opt/openstack-venv/lib/python3.7/site-packages/prettytable.py", line 122, in __init__
    self.field_names = field_names
  File "/opt/openstack-venv/lib/python3.7/site-packages/prettytable.py", line 412, in _set_field_names
    self._validate_option("field_names", val)
  File "/opt/openstack-venv/lib/python3.7/site-packages/prettytable.py", line 258, in _validate_option
    self._validate_field_names(val)
  File "/opt/openstack-venv/lib/python3.7/site-packages/prettytable.py", line 302, in _validate_field_names
    raise Exception("Field names must be unique!")
Exception: Field names must be unique!
clean_up ListZonesCommand: Field names must be unique!

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

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

Changed in python-designateclient:
assignee: nobody → Joseph M (noxoid)
status: New → In Progress
Changed in python-designateclient:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-designateclient (master)

Reviewed: https://review.opendev.org/682234
Committed: https://git.openstack.org/cgit/openstack/python-designateclient/commit/?id=7cc5f8bb2a31524f612e484e0bd4ea4e024e7d2c
Submitter: Zuul
Branch: master

commit 7cc5f8bb2a31524f612e484e0bd4ea4e024e7d2c
Author: Joseph M <email address hidden>
Date: Sat Sep 14 23:32:58 2019 -0400

    Fix "zone list --all-projects" in interactive OSC

    The current zone list function does not check to see if project_id is
    already a column to be output when adding it during an --all-projects
    list. This causes a duplicate field name to be added which is then
    passed to prettytables which subsequently throws an exception. Create a
    copy of the columns list so it is not appended to with every
    command.

    Change-Id: I5f62500086a807d5082221993c3b491f3b6a1db0
    Closes-Bug: #1844028

Changed in python-designateclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-designateclient (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/682868

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-designateclient (master)

Change abandoned by Jens Harbott (frickler) (<email address hidden>) on branch: master
Review: https://review.opendev.org/682868
Reason: Duplicate of https://review.opendev.org/682782

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-designateclient (master)

Reviewed: https://review.opendev.org/682868
Committed: https://git.openstack.org/cgit/openstack/python-designateclient/commit/?id=6be5c7b49e32864ebc60b255774d8f9b2a6ef9fc
Submitter: Zuul
Branch: master

commit 6be5c7b49e32864ebc60b255774d8f9b2a6ef9fc
Author: Jens Harbott <email address hidden>
Date: Wed Sep 18 11:44:57 2019 +0000

    Fix "recordset list --all-projects" in interactive OSC

    Class variables get re-used when multiple commands are executed in a row
    within a single OSC interactive session. So we need to take a copy
    before modifying in order to avoid unwanted side-effects.

    Change-Id: I9716014d65a3f649c23eb78faca2cb6dbf5eb5db
    Related-Bug: 1844028

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-designateclient 3.1.0

This issue was fixed in the openstack/python-designateclient 3.1.0 release.

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.