Merge pull request #20594 from ceph/wip-rm23004

ceph-volume: log the current running command for easier debugging

Reviewed-by: Alfredo Deza <adeza@redhat.com>
This commit is contained in:
Alfredo Deza 2018-02-26 14:24:38 -05:00 committed by GitHub
commit 9c8afc2365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -137,6 +137,7 @@ Ceph Conf: {ceph_path}
conf.log_path = os.path.join(args.log_path, 'ceph-volume.log')
log.setup()
logger = logging.getLogger(__name__)
logger.info("Running command: ceph-volume %s %s", " ".join(main_args), " ".join(subcommand_args))
# set all variables from args and load everything needed according to
# them
self.load_ceph_conf_path(cluster_name=args.cluster)

View File

@ -34,6 +34,15 @@ class TestVolume(object):
main.Volume(argv=['ceph-volume', '--cluster', 'barnacle', 'lvm', '--help'])
# make sure we aren't causing an actual error
assert error.value.code == 0
log = caplog.records[0]
log = caplog.records[1]
assert log.message == 'ignoring inability to load ceph.conf'
assert log.levelname == 'ERROR'
def test_logs_current_command(self, caplog):
with pytest.raises(SystemExit) as error:
main.Volume(argv=['ceph-volume', '--cluster', 'barnacle', 'lvm', '--help'])
# make sure we aren't causing an actual error
assert error.value.code == 0
log = caplog.records[0]
assert log.message == 'Running command: ceph-volume --cluster barnacle lvm --help'
assert log.levelname == 'INFO'