openstack volume backup restore fails to produce output

Bug #2063335 reported by Pavlo Shchelokovskyy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
In Progress
Undecided
Pavlo Shchelokovskyy

Bug Description

using python-openstackclient as of current master branch,
restoring backup to volume produces the following output

❯ openstack volume backup restore cirros-lvm2ceph restored
too many values to unpack (expected 2)

note that the command actually succeeds (backup is restored to the volume as expected), problem is clearly in the output path

runnning with --debug shows a bit more hints

❯ openstack volume backup restore cirros-lvm2ceph restored2
...
RESP BODY: {"restore": {"backup_id": "6390761c-87cc-4ad7-97cb-7502ed065748", "volume_id": "56213b74-791e-4c84-ad6c-4b1ebeee5863", "volume_name": "restored2"}}
POST call to block-storage for https://cinder.it.just.works/v3/c5ca04280f1a4862a01fdf033250cbce/backups/6390761c-87cc-4ad7-97cb-7502ed065748/restore used request id req-00182cb2-b698-4858-85d1-031693a108b4
too many values to unpack (expected 2)
Traceback (most recent call last):
  File "/home/pshchelo/.local/pipx/venvs/python-openstackclient/lib/python3.10/site-packages/cliff/app.py", line 410, in run_subcommand
    result = cmd.run(parsed_args)
  File "/home/pshchelo/.local/pipx/venvs/python-openstackclient/lib/python3.10/site-packages/osc_lib/command/command.py", line 39, in run
    return super(Command, self).run(parsed_args)
  File "/home/pshchelo/.local/pipx/venvs/python-openstackclient/lib/python3.10/site-packages/cliff/display.py", line 117, in run
    column_names, data = self.take_action(parsed_args)
ValueError: too many values to unpack (expected 2)
clean_up RestoreVolumeBackup: too many values to unpack (expected 2)
END return value: 1

So the problem is that this
https://opendev.org/openstack/python-openstackclient/src/commit/a79cb608b0b75f1400a21ecc074de1056c50b29a/openstackclient/volume/v2/volume_backup.py#L437
returns openstack.block_storage.v3.backup.Backup object, while every other method that has anything to return returns (columns, data) tuple as expected by cliff.

What's more, the code in openstacksdk is also sub-optimal. It returns the Backup object itself, loosing actual response that has some useful info like volume_id of the restored volume that might've not been known before (if the volume was created).

So there're several options IMO:
- return nothing, only fail if the restore call fails
- return the same as backup show
- return the backup list of one current backup (like shortened version of backup show)
- return a custom table/object with what was actually returned by the API call, which is backup_id, volume_id, volume_name (need to be resolved first).

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-openstackclient (master)
Changed in python-openstackclient:
status: New → In Progress
Changed in python-openstackclient:
assignee: nobody → Pavlo Shchelokovskyy (pshchelo)
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.