Project

General

Profile

Bug #37589

argument validators can eat up exceptions

Added by Alfredo Deza almost 4 years ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

If an error happens inside an argument validator, the exception is eaten up resulting in a cryptic error message

[root@osd0 vagrant]# CEPH_VOLUME_DEBUG=1 ceph-volume lvm batch --bluestore --report /dev/sdb
usage: ceph-volume lvm batch [-h] [--bluestore] [--filestore] [--report]
                             [--yes] [--format {json,pretty}] [--dmcrypt]
                             [--crush-device-class CRUSH_DEVICE_CLASS]
                             [--no-systemd]
                             [--osds-per-device OSDS_PER_DEVICE]
                             [--block-db-size BLOCK_DB_SIZE]
                             [--journal-size JOURNAL_SIZE] [--prepare]
 ceph-volume lvm batch: error: argument DEVICES: invalid <ceph_volume.util.arg_validators.ValidDevice object at 0x7f68072497d0> value: '/dev/sdb'

The error is eaten up by argparse:

>>> from ceph_volume.util import device
>>> device.Device('/dev/sdb')
 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/ceph_volume/util/device.py", line 92, in __init__
    self.device_id = self._get_device_id()
  File "/usr/lib/python2.7/site-packages/ceph_volume/util/device.py", line 198, in _get_device_id
    dev_id = '_'.join(p['ID_MODEL'], p['ID_SERIAL_SHORT'])
TypeError: join() takes exactly one argument (2 given)

A try/except that deals with this should be required, so that breakage like this doesn't occur.

In the event of breakage, I think that the validator should allow the process to continue (with a warning is fine)

Also available in: Atom PDF