command logging in processutils.py mangles the command

Bug #1349890 reported by Amrith Kumar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
Medium
Amrith Kumar

Bug Description

In processutils.py, https://github.com/openstack/trove/blob/master/trove/openstack/common/processutils.py#L159-L160

the code

             LOG.log(loglevel, 'Running cmd (subprocess): %s',
                    ' '.join(logging.mask_password(cmd)))

does a join() on a string. This results in the command getting logged like this:

2014-07-29 15:00:13.796 875 DEBUG trove.openstack.common.processutils [-] Running cmd (subprocess): [ ' s u d o ' , ' / u s r / b i n / m y s q l a d m i n ' , ' p i n g ' ] execute /home/amrith/trove/trove/openstack/common/processutils.py:160

The space is added between characters in the various command elements. This is less than optimal. It makes debugging harder when someone wants to just copy the command and re-run it.

It turns out that this was fixed in a prior version of oslo code and trove is just missing an oslo update. I'll leave this assigned to myself and use it to merge other oslo-incubator changes related to processutils.py.

Amrith Kumar (amrith)
affects: trove → oslo
Changed in oslo:
assignee: nobody → Amrith (amrith)
Changed in oslo:
status: New → Triaged
importance: Undecided → High
tags: added: concurrency low-hanging-fruit
Revision history for this message
Amrith Kumar (amrith) wrote :

Doug, sorry this isn't a change for oslo but rather for trove.

affects: oslo → trove
Changed in trove:
status: Triaged → Incomplete
importance: High → Medium
description: updated
Revision history for this message
Amrith Kumar (amrith) wrote :

Interactively running the code in trove (as it is right now) with python

>>> command=['sudo', 'abc', 'pqr']
>>> logging.mask_password(command)
u"['sudo', 'abc', 'pqr']"
>>> print ' '.join(logging.mask_password(command))
[ ' s u d o ' , ' a b c ' , ' p q r ' ]
>>>

Amrith Kumar (amrith)
Changed in trove:
status: Incomplete → New
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

Fix proposed to branch: master
Review: https://review.openstack.org/111870

Changed in trove:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on trove (master)

Change abandoned by Auston McReynolds (<email address hidden>) on branch: master
Review: https://review.openstack.org/111870
Reason: testing abandon, don't be mad amrith :)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to trove (master)

Reviewed: https://review.openstack.org/111870
Committed: https://git.openstack.org/cgit/openstack/trove/commit/?id=c53cff1d34602a8c189da3071b5a394731e07cd2
Submitter: Jenkins
Branch: master

commit c53cff1d34602a8c189da3071b5a394731e07cd2
Author: Amrith Kumar <email address hidden>
Date: Mon Aug 4 17:26:48 2014 -0400

    Merge from oslo-incubator

    Merging processutils.py and dependencies from oslo-incubator.
    Primarily, I want change d6b55fb but the rest come along for
    the ride.

    0d7296f Add kwargs to jsonutils.load(s) functions
    3310d8d update new requests logger to default WARN
    33afb20 Fix broken formatting of processutils.execute log statement
    3d90045 Backport code for i18n to check lazy at runtime
    433fa0b Make logging_context_format_string optional in log.set_defaults
    4d9328c Python 3: enable tests/unit/test_log.py
    5fd77eb Ability to customize default_log_levels for each project
    6751b30 Remove extra whitespace
    726d00a Adjust oslo logging to provide adapter is enabled for
    ac92c06 Add default log level for websocket
    cb5a804 Move `mask_password` to strutils
    d6b55fb Remove `processutils` dependency on `log`
    e184dd3 Fix exception message in openstack.common.processutils.execute
    ef37e03 Added missing jsonutils.dump() function

    Change-Id: I567f514faed5a8467602257d35a98625801daf22
    Closes-Bug: #1349890

Changed in trove:
status: In Progress → Fix Committed
Changed in trove:
milestone: none → juno-3
Thierry Carrez (ttx)
Changed in trove:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in trove:
milestone: juno-3 → 2014.2
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.