unit tests are leaking sudo commands

Bug #1410411 reported by Adam Gandelman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Undecided
Zhai, Edwin
Juno
Fix Released
Undecided
Lianhao Lu

Bug Description

infra has just recently fixed a bug so that the jenkins user on slaves correctly has no sudo access. Previously, it had mistakenly been granted sudo access. Since then, ceilometer's unit test jobs are periodically failing because of attempts to use sudo:

2015-01-13 10:15:34.499 | + sudo /usr/local/jenkins/slave_scripts/jenkins-sudo-grep.sh post
2015-01-13 10:15:34.501 | sudo: unable to resolve host bare-trusty-1421072110
2015-01-13 10:15:34.629 | 1a2,3
2015-01-13 10:15:34.630 | > Jan 13 10:14:05 bare-trusty-1421072110 sudo: jenkins : command not allowed ; TTY=unknown ; PWD=/home/jenkins/workspace/gate-ceilometer-python27 ; USER=root ; COMMAND=/home/jenkins/workspace/gate-ceilometer-python27/.tox/py27/bin/ceilometer-rootwrap /etc/ceilometer/rootwrap.conf ipmitool sdr info
2015-01-13 10:15:34.630 | > Jan 13 10:14:05 bare-trusty-1421072110 sudo: jenkins : command not allowed ; TTY=unknown ; PWD=/home/jenkins/workspace/gate-ceilometer-python27 ; USER=root ; COMMAND=/home/jenkins/workspace/gate-ceilometer-python27/.tox/py27/bin/ceilometer-rootwrap /etc/ceilometer/rootwrap.conf ipmitool raw 0x0a 0x2c 0x00
2015-01-13 10:15:34.630 | + sudoresult=1
2015-01-13 10:15:34.630 | + '[' 1 -ne 0 ']'
2015-01-13 10:15:34.631 | + echo
2015-01-13 10:15:34.631 |
2015-01-13 10:15:34.631 | + echo 'This test has failed because it attempted to execute commands'
2015-01-13 10:15:34.631 | This test has failed because it attempted to execute commands
2015-01-13 10:15:34.631 | + echo 'with sudo. See above for the exact commands used.'
2015-01-13 10:15:34.631 | with sudo. See above for the exact commands used.
2015-01-13 10:15:34.631 | + echo
2015-01-13 10:15:34.631 |
2015-01-13 10:15:34.631 | + exit 1

Note that the unit test run itself succeeds, but the post-job script to check for sudo attempts detects two ipmitool commands were attempted to be run with sudo and the job fails. I assume this is happening because of a missed mock somewhere in the tests. I'm not sure if it is specific to certain devstack slaves that the job is run, or the patch, but I originally hit it on a stable/juno patch:

https://review.openstack.org/#/c/146623/

But its happening on master as well:

https://review.openstack.org/#/c/144192/

I've attempted to push a debug patch to raise an exception for anything that actually shells out, but cannot seem to trigger the issue with that:

https://review.openstack.org/#/c/146684/

Revision history for this message
Matt Riedemann (mriedem) wrote :

message:"+ echo 'This test has failed because it attempted to execute commands'" AND tags:"console" AND (project:"openstack/neutron" OR project:"openstack/ceilometer")

Revision history for this message
Zhai, Edwin (edwin-zhai) wrote :

The unit test should not execute ipmitool , some test case is probably mocked completely. I'm looking at this.

Changed in ceilometer:
assignee: nobody → Zhai, Edwin (edwin-zhai)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

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

Changed in ceilometer:
status: New → In Progress
Changed in neutron:
assignee: nobody → Ihar Hrachyshka (ihar-hrachyshka)
Revision history for this message
Ihar Hrachyshka (ihar-hrachyshka) wrote :

Neutron hits are legitimate due to issue in patches that are tested in those runs, so removing Neutron.

no longer affects: neutron
Changed in ceilometer:
assignee: Zhai, Edwin (edwin-zhai) → Lianhao Lu (lianhao-lu)
Lianhao Lu (lianhao-lu)
Changed in ceilometer:
assignee: Lianhao Lu (lianhao-lu) → Zhai, Edwin (edwin-zhai)
Changed in ceilometer:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/147404

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on ceilometer (stable/juno)

Change abandoned by Lianhao Lu (<email address hidden>) on branch: stable/juno
Review: https://review.openstack.org/147404
Reason: merge this to https://review.openstack.org/#/c/146623/

Revision history for this message
Lianhao Lu (lianhao-lu) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (stable/juno)

Reviewed: https://review.openstack.org/146623
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=33e7fd8c62a3a5b9107410461edb9a87d09f549e
Submitter: Jenkins
Branch: stable/juno

commit 33e7fd8c62a3a5b9107410461edb9a87d09f549e
Author: Edwin Zhai <email address hidden>
Date: Wed Jan 14 11:10:11 2015 +0800

    Combined fixes for ipmitool, timeutils, and read from stderr

    This is a combination of 3 changes meant to fix various gate issues.
    Co-Authored-By: lianhao-lu <email address hidden>

    The first one is:

    IPMI unit tests call ipmitool accidently, and sudo requirements cause tox
    failure. Mock the executing engine completely to fix it.

    Change-Id: Ifa2f13b324f1e244cc0982bf850de928e37ecca5
    Closes-bug:1410411
    (cherry picked from commit 9307f9703191f527fbcb9bdae22c59d8911c407d)

    The second one is:

    the event api tests incorrectly reference a private attribute
    from oslo_utils. this is not required and should not be done in
    general. this patch changes this.

    Change-Id: I03610078123edbe8ef89e8ea271d9c72ed4ba696
    Closes-Bug: #1408737
    (cherry picked from commit 160513ddb680ffb66758fb003c58a75b41a89785)

    The third one is committed here directly as it is only relevant to
    stable/juno:

    Increase the amount of stderr read from 1024 to 2048 in test_bin.py

    These test currently asserts a specific message is contained in the first
    1024 bytes of the stderr message. oslo_utils now spits a bunch of deprecation
    messages that fill this quickly and the message being asserted on is cut off.
    This bumps the read() from 1024 to 2048 to account for deprecation spam.

    Change-Id: I03610078123edbe8ef89e8ea271d9c72ed4ba696
    (cherry picked from commit 3197c9be0731522a9bb1a47eafa10218893dbe13)

Thierry Carrez (ttx)
Changed in ceilometer:
milestone: none → kilo-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: kilo-2 → 2015.1.0
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.