gate: context tests failed because missing parameter "is_admin_project" (oslo.context 2.6.0)

Bug #1603979 reported by Tang Chen
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Critical
Tang Chen

Bug Description

Description
===========
The following 3 tests failed:
1. nova.tests.unit.test_context.ContextTestCase.test_convert_from_dict_then_to_dict
Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/test_context.py", line 230, in test_convert_from_dict_then_to_dict
        self.assertEqual(values, values2)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: !=:
    reference = {
     ......
     'is_admin': True,
     ......}
    actual = {
     ......
     'is_admin': True,
     'is_admin_project': True,
     ......}

2. nova.tests.unit.test_context.ContextTestCase.test_convert_from_rc_to_dict
Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/test_context.py", line 203, in test_convert_from_rc_to_dict
        self.assertEqual(expected_values, values2)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: !=:
    reference = {
     ......
     'is_admin': True,
     ......}
    actual = {
     ......
     'is_admin': True,
     'is_admin_project': True,
     ......}

3. nova.tests.unit.test_context.ContextTestCase.test_to_dict_from_dict_no_log
Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/test_context.py", line 144, in test_to_dict_from_dict_no_log
        self.assertEqual(0, len(warns), warns)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: 0 != 1: ["Arguments dropped when creating context: {'is_admin_project': True}"]

Steps to reproduce
==================
Just run the context tests:
    tox -e py27 test_context

This is because we missed to pass "is_admin_project" parameter to __init__() of oslo.context.ResourceContext when initializing a nova ResourceContext object.

In nova/context.py

@enginefacade.transaction_context_provider
class RequestContext(context.RequestContext):
    """Security context and request information.

    Represents the user taking a given action within the system.

    """

    def __init__(self, user_id=None, project_id=None,
                 is_admin=None, read_deleted="no",
                 roles=None, remote_address=None, timestamp=None,
                 request_id=None, auth_token=None, overwrite=True,
                 quota_class=None, user_name=None, project_name=None,
                 service_catalog=None, instance_lock_checked=False,
                 user_auth_plugin=None, **kwargs):
    ......
        super(RequestContext, self).__init__(
            ......
            is_admin=is_admin,
            ......)

But in oslo_context/context.py,

class RequestContext(object):

    ......

    def __init__(......
                 is_admin=False,
                 ......
                 is_admin_project=True):

Tags: oslo
Tang Chen (tangchen)
Changed in nova:
assignee: nobody → Tang Chen (tangchen)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Changed in nova:
importance: Undecided → Critical
summary: - context tests failed because missing parameter "is_admin_project"
+ gate: context tests failed because missing parameter "is_admin_project"
Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote : Re: gate: context tests failed because missing parameter "is_admin_project"

The nova gate uses oslo.context 2.6.0 (for example [1]), but the support is not yet there [2].

References:
[1] http://logs.openstack.org/44/342944/2/check/gate-nova-python27-db/f8076bd/console.html#_2016-07-18_11_55_51_007624
[2] https://review.openstack.org/#/c/342604/1

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :

Global requirements uses "oslo.context>=2.4.0" and the "upper-constraints.txt" got updated to use 2.6.0 yesterday [1].

References:
[1] https://github.com/openstack/requirements/commit/238389c4ee1bd3cc9be4931dd2639aea2dae70f1

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :
Matt Riedemann (mriedem)
summary: gate: context tests failed because missing parameter "is_admin_project"
+ (oslo.context 2.6.0)
tags: added: oslo
Revision history for this message
Matt Riedemann (mriedem) wrote :

Tony Breeds has a fix here too: https://review.openstack.org/#/c/342604/

Revision history for this message
Matt Riedemann (mriedem) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Tang Chen (<email address hidden>) on branch: master
Review: https://review.openstack.org/343618
Reason: Fixed by another patch.

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :
Changed in nova:
status: In Progress → Fix Released
Revision history for this message
Vasyl Saienko (vsaienko) wrote :

@Markus: shouldn't be https://review.openstack.org/#/c/333181/ merged to fix the issue?

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

Nova didn't accept the g-r update now, Maybe the CI test skip oslo.context 2.6.0.

We have another fix in https://review.openstack.org/#/c/343694/

Changed in nova:
status: Fix Released → In Progress
Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :

Hm, there's also https://review.openstack.org/#/c/345633/
I have no strong feelings for any solution, to be honest.

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :
Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Ronald Bradford (<email address hidden>) on branch: master
Review: https://review.openstack.org/343694
Reason: Superseded by https://review.openstack.org/#/c/345633/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.