Failed unit test due to permission on /tmp/device_images

Bug #1911997 reported by Sabeel Ansari
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Low
Al Bailey

Bug Description

Running unit test on local build server (cgts4) failed. Tox reports a unit test failure locally, and another user who had run tox previously owns the permissions to the target folder.

The source code writing to /tmp/device_images needs to be mocked using either a @mock.patch('os.makedirs') or similar calls.

It appears that the culprit is this line: https://github.com/starlingx/config/blame/master/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/device_image.py#L267

Captured pythonlogging:
~~~~~~~~~~~~~~~~~~~~~~~
    _host_upgrade_create system version=0.0
    None "POST /v1/device_images HTTP/1.0" status: 200 len: 0 time: 0.00612902641296 POST: NestedMultiDict([('pci_device', u'0b30'), ('bitstream_type', u'key-revocation'), ('pci_vendor', u'8086'), ('revoke_key_id', u'12345'), ('file', FieldStorage('file', u'/localdisk/designer/sansari/starlingx-0/cgcs-root/stx/config/sysinv/sysinv/sysinv/sysinv/tests/api/data/bitstream.bit'))]) host:localhost:80 agent:sysinv-test user: None tenant: None domain: None
    [Errno 13] Permission denied: '/tmp/device_images/key-revocation-8086-0b30-5ae6c262-5e03-4953-9a22-46e3595c1779.bit'
    Traceback (most recent call last):
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/middleware/debug.py", line 78, in __call__
        return self.app(environ, start_response)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/middleware/recursive.py", line 56, in __call__
        return self.application(environ, start_response)
      File "sysinv/api/middleware/parsable_error.py", line 70, in __call__
        app_iter = self.app(environ, replacement_start_response)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/core.py", line 840, in __call__
        return super(Pecan, self).__call__(environ, start_response)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/core.py", line 683, in __call__
        self.invoke_controller(controller, args, kwargs, state)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/core.py", line 574, in invoke_controller
        result = controller(*args, **kwargs)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/oslo_concurrency/lockutils.py", line 328, in inner
        return f(*args, **kwargs)
      File "sysinv/api/controllers/v1/device_image.py", line 269, in post
        constants.CONFIG_FILE_PERMISSION_DEFAULT),
    OSError: [Errno 13] Permission denied: '/tmp/device_images/key-revocation-8086-0b30-5ae6c262-5e03-4953-9a22-46e3595c1779.bit'

======
Totals
======
Ran: 1480 tests in 384.0000 sec.
 - Passed: 1449
 - Skipped: 28
 - Expected Fail: 0
 - Unexpected Success: 0
 - Failed: 3
Sum of execute time for each test: 15561.9743 sec.

Revision history for this message
Al Bailey (albailey1974) wrote :

The three tox unit tests that are failing are tests that invoke the device_images API and attempt to write to that folder.

The easiest way to reproduce this problem is to make an in-accessible (000 permissions) /tmp/device_images folder, and then run tox for sysinv for the tests that fail (tests.api.test_device_image)

mkdir /tmp/device_images
chmod 000 /tmp/device_images

cd $MY_REPO/stx/config/sysinv/sysinv/sysinv/
tox -e py27 -- tests.api.test_device_image

These are the three tests that fail:
 tests.api.test_device_image.TestPostDeviceImage.test_create_revoke_key_image
 tests.api.test_device_image.TestPostDeviceImage.test_create_root_key_image
 tests.api.test_device_image.TestPostDeviceImage.test_create_functional_image

Revision history for this message
Ghada Khalil (gkhalil) wrote :

Minor / low priority - issue w/ running tox on a shared server related to specific test-cases

Changed in starlingx:
importance: Undecided → Low
status: New → Triaged
tags: added: stx.config
Changed in starlingx:
assignee: nobody → Al Bailey (albailey1974)
Revision history for this message
Al Bailey (albailey1974) wrote :
Changed in starlingx:
status: Triaged → In Progress
Revision history for this message
Al Bailey (albailey1974) wrote :

This merged on Jan 26, 2021

Changed in starlingx:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to config (f/centos8)

Fix proposed to branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/793460

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/793696

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/794611

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/794906

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on config (f/centos8)

Change abandoned by "Chuck Short <email address hidden>" on branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/794611

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to config (f/centos8)
Download full text (147.3 KiB)

Reviewed: https://review.opendev.org/c/starlingx/config/+/794906
Committed: https://opendev.org/starlingx/config/commit/75758b37a5a23c8811355b67e2a430a1713cd85b
Submitter: "Zuul (22348)"
Branch: f/centos8

commit 9e420d9513e5fafb1df4d29567bc299a9e04d58d
Author: Bin Qian <email address hidden>
Date: Mon May 31 14:45:52 2021 -0400

    Add more logging to run docker login

    Add error log for running docker login. The new log could
    help identify docker login failure.

    Closes-Bug: 1930310
    Change-Id: I8a709fb6665de8301fbe3022563499a92b2a0211
    Signed-off-by: Bin Qian <email address hidden>

commit 31c77439d2cea590dfcca13cfa646522665f8686
Author: albailey <email address hidden>
Date: Fri May 28 13:42:42 2021 -0500

    Fix controller-0 downgrade failing to kill ceph

    kill_ceph_storage_monitor tried to manipulate a pmon
    file that does not exist in an AIO-DX environment.

    We no longer invoke kill_ceph_storage_monitor in an
    AIO SX or DX env.

    This allows: "system host-downgrade controller-0"
    to proceed in an AIO-DX environment where that second
    controller (controller-0) was upgraded.

    Partial-Bug: 1929884
    Signed-off-by: albailey <email address hidden>
    Change-Id: I633853f75317736084feae96b5b849c601204c13

commit 0dc99eee608336fe01b58821ea404286371f1408
Author: albailey <email address hidden>
Date: Fri May 28 11:05:43 2021 -0500

    Fix file permissions failure during duplex upgrade abort

    When issuing a downgrade for controller-0 in a duplex upgrade
    abort and rollback scenario, the downgrade command was failing
    because the sysinv API does not have root permissions to set
    a file flag.
    The fix is to use RPC so the conductor can create the flag
    and allow the downgrade for controller-0 to get further.

    Partial-Bug: 1929884
    Signed-off-by: albailey <email address hidden>
    Change-Id: I913bcad73309fe887a12cbb016a518da93327947

commit 7ef3724dad173754e40b45538b1cc726a458cc1c
Author: Chen, Haochuan Z <email address hidden>
Date: Tue May 25 16:16:29 2021 +0800

    Fix bug rook-ceph provision with multi osd on one host

    Test case:
    1, deploy simplex system
    2, apply rook-ceph with below override value
    value.yaml
    cluster:
      storage:
        nodes:
        - name: controller-0
          devices:
          - name: sdb
          - name: sdc
    3, reboot

    Without this fix, only osd pod could launch successfully after boot
    as vg start with ceph could not correctly add in sysinv-database

    Closes-bug: 1929511

    Change-Id: Ia5be599cd168d13d2aab7b5e5890376c3c8a0019
    Signed-off-by: Chen, Haochuan Z <email address hidden>

commit 23505ba77d76114cf8a0bf833f9a5bcd05bc1dd1
Author: Angie Wang <email address hidden>
Date: Tue May 25 18:49:21 2021 -0400

    Fix issue in partition data migration script

    The created partition dictonary partition_map is not
    an ordered dict so we need to sort it by its key -
    device node when iterating it to adjust the device
    nodes/paths for user created extra partitions to ensure
    the number of device node...

tags: added: in-f-centos8
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on config (f/centos8)

Change abandoned by "Chuck Short <email address hidden>" on branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/793696

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by "Chuck Short <email address hidden>" on branch: f/centos8
Review: https://review.opendev.org/c/starlingx/config/+/793460

Ghada Khalil (gkhalil)
Changed in starlingx:
status: Fix Committed → Fix Released
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.