Remove use of contextlib.nested

Bug #1428424 reported by ChangBo Guo(gcb)
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Sean McGinnis
Glance
Fix Released
Undecided
ChangBo Guo(gcb)
OpenStack Compute (nova)
Fix Released
Low
Davanum Srinivas (DIMS)
neutron
Fix Released
Undecided
Ankit Agrawal

Bug Description

    The contextlib.nested call has been deprecated
    in Python 2.7. This causes DeprecationWarning
    messages in the unit tests.

    There are also known issues with contextlib.nested
    that were addressed by the native support for
    multiple "with" variables. For instance, if the
    first object is created but the second one throws
    an exception, the first object's __exit__ is never
    called. For more information see
    https://docs.python.org/2/library/contextlib.html#contextlib.nested
    contextlib.nested is also not compatible in Python 3.

Changed in nova:
assignee: nobody → ChangBo Guo(gcb) (glongwave)
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/161540

Changed in nova:
status: New → In Progress
Changed in glance:
assignee: nobody → ChangBo Guo(gcb) (glongwave)
Changed in cinder:
assignee: nobody → Sean McGinnis (sean-mcginnis)
status: New → In Progress
Changed in glance:
status: New → In Progress
Changed in nova:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/158732
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=ddbcdbb2d02a46eb0392e00a2b2d8e246cc8e3de
Submitter: Jenkins
Branch: master

commit ddbcdbb2d02a46eb0392e00a2b2d8e246cc8e3de
Author: Sean McGinnis <email address hidden>
Date: Tue Feb 24 09:24:52 2015 -0600

    Remove use of contextlib.nested

    The contextlib.nested call has been deprecated
    in Python 2.7. This causes DeprecationWarning
    messages in the unit tests.

    There are also known issues with contextlib.nested
    that were addressed by the native support for
    multiple "with" variables. For instance, if the
    first object is created but the second one throws
    an exception, the first object's __exit__ is never
    called.

    Since Cinder no longer supports 2.6 we can remove
    the use of these contextlib.nested calls.

    Added hacking check to catch if any new instances
    are added to the codebase.

    Note: line continuation markers (e.g. '\') had to
    be used or syntax errors were thrown. While using
    parentheses is the preferred way for multiple line
    statements it is not a requirement.

    Partial-Bug: 1428424
    Change-Id: I7bb7d201d31ff239be3402fb64e5f202ede019b0

Changed in neutron:
assignee: nobody → Ankit Agrawal (ankitagrawal)
Revision history for this message
Ankit Agrawal (ankitagrawal) wrote :

In neutron project there are approx 281 of occurrences of contextlib.nested, so fixing all of these in a single patch will be cumbersome for review.

I will be submitting this change in a series of patches to ease the review process, where I'll add hacking rules for the same in the last patch.

These patches will only remove the use of contextlib.nested from the neutron code base and is not intended to remove use of nested with statements.

Jay Bryant (jsbryant)
Changed in cinder:
importance: Undecided → High
importance: High → Medium
Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/161649
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=27539859ece47e4654736b905d75de5399d25ccc
Submitter: Jenkins
Branch: master

commit 27539859ece47e4654736b905d75de5399d25ccc
Author: ChangBo Guo(gcb) <email address hidden>
Date: Thu Mar 5 17:31:56 2015 +0800

    Remove use of contextlib.nested

    The contextlib.nested call has been deprecated
    in Python 2.7. This causes DeprecationWarning
    messages in the unit tests.

    There are also known issues with contextlib.nested
    that were addressed by the native support for
    multiple "with" variables. For instance, if the
    first object is created but the second one throws
    an exception, the first object's __exit__ is never
    called. For more information see
    https://docs.python.org/2/library/contextlib.html#contextlib.nested
    contextlib.nested is also not compatible in Python 3.

    Since Glance no longer supports 2.6 we can remove
    the use of these contextlib.nested calls.

    Added hacking check to catch if any new instances
    are added to the codebase.

    Closes-Bug: #1428424
    Change-Id: Ic8edfa41d6c468cf6db8d11d3533e4f8cf2053c2

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → kilo-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: none → kilo-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: kilo-rc1 → 2015.1.0
Thierry Carrez (ttx)
Changed in cinder:
milestone: kilo-rc1 → 2015.1.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/167677
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=4cd1600b2548b3d15cdbc9dcc368c375d2f7fee9
Submitter: Jenkins
Branch: master

commit 4cd1600b2548b3d15cdbc9dcc368c375d2f7fee9
Author: ankitagrawal <email address hidden>
Date: Wed Mar 25 05:40:45 2015 -0700

    Remove use of contextlib.nested

    Removed use of contextlib.nested call from codebase, as it has been
    deprecated since Python 2.7.

    There are also known issues with contextlib.nested that were addressed
    by the native support for multiple "with" variables. For instance, if
    the first object is created but the second one throws an exception,
    the first object's __exit__ is never called. For more information see
    https://docs.python.org/2/library/contextlib.html#contextlib.nested
    contextlib.nested is also not compatible with Python 3.

    This is the first patch in a series for removing use of
    contextlib.nested.

    Added hacking check to catch if any new instances are added to
    the codebase.

    Line continuation markers (e.g. '\') had to be used or syntax
    errors were thrown. While using parentheses is the preferred way
    for multiple line statements, but in case of long with statements
    backslashes are acceptable.

    Partial-Bug: 1428424
    Change-Id: I171fbdb89892a3d4548bf2ca52f4a7dd9ef8dccb

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron-vpnaas (master)

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

Changed in neutron:
assignee: Ankit Agrawal (ankitagrawal) → Paul Michali (pcm)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Joe Gordon (<email address hidden>) on branch: master
Review: https://review.openstack.org/161540
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

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

Reviewed: https://review.openstack.org/182670
Committed: https://git.openstack.org/cgit/openstack/neutron-vpnaas/commit/?id=23365d39399e046b0358b06769116e44f5d8da1f
Submitter: Jenkins
Branch: master

commit 23365d39399e046b0358b06769116e44f5d8da1f
Author: Paul Michali <email address hidden>
Date: Tue May 12 14:36:46 2015 -0400

    Remove contextlib.nested from tests

    With the deprecation of this method in Python2.7, the neutron hacking
    check has been modified to check for this (N324). Since this check has
    been upstreamed (I171fbdb89892a3d4548bf2ca52f4a7dd9ef8dccb), and the
    neutron-vpnaas repo uses the same hacking check, the VPN test cases
    are now failing.

    This commit does the same changes as was done in neutron to remove use
    of this method.

    Change-Id: Ie490e89c1a65e126ad0a57d062076e472762837e
    Partial-Bug: 1428424

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

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

Changed in neutron:
assignee: Paul Michali (pcm) → Ankit Agrawal (ankitagrawal)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron-fwaas (master)

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

Changed in neutron:
assignee: Ankit Agrawal (ankitagrawal) → Freescale Openstack Team (trinath-somanchi)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/182999
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=f3f2e59ae76ab2a52ee448bf53722be5503f0d43
Submitter: Jenkins
Branch: master

commit f3f2e59ae76ab2a52ee448bf53722be5503f0d43
Author: ankitagrawal <email address hidden>
Date: Thu May 14 02:06:39 2015 -0700

    Remove use of contextlib.nested

    Removed use of contextlib.nested call from codebase, as it has been
    deprecated since Python 2.7.

    There are also known issues with contextlib.nested that were addressed
    by the native support for multiple "with" variables. For instance, if
    the first object is created but the second one throws an exception,
    the first object's __exit__ is never called. For more information see
    https://docs.python.org/2/library/contextlib.html#contextlib.nested
    contextlib.nested is also not compatible with Python 3.

    Multi-patch set for easier chunks. This one addresses the
    neutron/tests/unit/agent/test_securitygroups_rpc.py tests.

    Line continuation markers (e.g. '\') had to be used or syntax
    errors were thrown. While using parentheses is the preferred way
    for multiple line statements, but in case of long with statements
    backslashes are acceptable.

    Partial-Bug: 1428424
    Change-Id: Ia66b98423b14fc7d1bbf6d8a673a49f798d328fa

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

Reviewed: https://review.openstack.org/183056
Committed: https://git.openstack.org/cgit/openstack/neutron-fwaas/commit/?id=f5f28ec6fa46fcb4009c2105bf09dfdbe0b7041b
Submitter: Jenkins
Branch: master

commit f5f28ec6fa46fcb4009c2105bf09dfdbe0b7041b
Author: Trinath Somanchi <email address hidden>
Date: Fri May 15 13:55:29 2015 +0530

    Remove contextlib.nested from tests

    With the deprecation of this method in Python2.7, the neutron hacking
    check has been modified to check for this (N324). Since this check has
    been upstreamed (I171fbdb89892a3d4548bf2ca52f4a7dd9ef8dccb), and the
    neutron-fwaas repo uses the same hacking check, the FWaaS test cases
    are now failing.
    This commit does the same changes as was done in neutron to remove use
    of this method.

    Partial-Bug: #1428424

    Change-Id: I130cf3eaeccbf6a965407c76a74f8f8fa59943a4

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
assignee: Trinath Somanchi (trinath-somanchi) → Ankit Agrawal (ankitagrawal)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (neutron-pecan)

Fix proposed to branch: neutron-pecan
Review: https://review.openstack.org/185072

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

Reviewed: https://review.openstack.org/184876
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=032847b3030106a9e605b3088826b599789d7991
Submitter: Jenkins
Branch: master

commit 032847b3030106a9e605b3088826b599789d7991
Author: ankitagrawal <email address hidden>
Date: Thu May 14 04:08:36 2015 -0700

    Remove use of contextlib.nested

    Removed use of contextlib.nested call from codebase, as it has been
    deprecated since Python 2.7.

    There are also known issues with contextlib.nested that were addressed
    by the native support for multiple "with" variables. For instance, if
    the first object is created but the second one throws an exception,
    the first object's __exit__ is never called. For more information see
    https://docs.python.org/2/library/contextlib.html#contextlib.nested
    contextlib.nested is also not compatible with Python 3.

    Multi-patch set for easier chunks. This one addresses the
    neutron/plugins/ml2 directory.

    Line continuation markers (e.g. '\') had to be used or syntax
    errors were thrown. While using parentheses is the preferred way
    for multiple line statements, but in case of long with statements
    backslashes are acceptable.

    Partial-Bug: 1428424
    Change-Id: I7bbe4cec511125b4b2c954aa93e2d9ff6871b9e0

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

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

Changed in neutron:
status: Fix Released → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/186708

Changed in neutron:
assignee: Ankit Agrawal (ankitagrawal) → Adrien Vergé (adrien-verge)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Revision history for this message
Adrien Vergé (adrienverge) wrote :

ChangBo, I see that change I3a0bb6b4016ca0f5c2753ef3f34a5680ceab7f64 is abandoned, do you mind if I re-assign the bug to myself? I have a patch for removing contextlib.nested from Nova.

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

Reviewed: https://review.openstack.org/185557
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=8ee3020c47cd7eb716216852a90c3db595e2c3c6
Submitter: Jenkins
Branch: master

commit 8ee3020c47cd7eb716216852a90c3db595e2c3c6
Author: ankitagrawal <email address hidden>
Date: Thu May 14 05:19:44 2015 -0700

    Remove use of contextlib.nested (api-tests)

    Removed use of contextlib.nested call from codebase, as it has been
    deprecated since Python 2.7.

    There are also known issues with contextlib.nested that were addressed
    by the native support for multiple "with" variables. For instance, if
    the first object is created but the second one throws an exception,
    the first object's __exit__ is never called. For more information see
    https://docs.python.org/2/library/contextlib.html#contextlib.nested
    contextlib.nested is also not compatible with Python 3.

    Multi-patch set for easier chunks. This one addresses the tests from
    neutron/tests/unit/api directory.

    Line continuation markers (e.g. '\') had to be used or syntax
    errors were thrown. While using parentheses is the preferred way
    for multiple line statements, but in case of long with statements
    backslashes are acceptable.

    Partial-Bug: 1428424
    Change-Id: I09673f9d4c7f07d3043804676fef018905dd1239

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

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

Changed in neutron:
assignee: Adrien Vergé (adrien-verge) → Ankit Agrawal (ankitagrawal)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/186709
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=422588e13338dab4a5ba1973c96256690ba4adf5
Submitter: Jenkins
Branch: master

commit 422588e13338dab4a5ba1973c96256690ba4adf5
Author: Adrien Vergé <email address hidden>
Date: Fri May 29 22:54:33 2015 +0200

    Get completely rid of contextlib.nested

    `contextlib.nested` is deprecated since Python 2.7 and incompatible with
    Python 3. This patch removes all its occurences by using the helper
    script at [1].

    This is a necessary step to allow us running all unit tests with
    Python 3 (not just a small subset as it is done now).

    [1]: https://github.com/adrienverge/context_unnester

    Change-Id: I8d1de09ff38ed0af9fb56f423a2c43476408e0fb
    Blueprint: neutron-python3
    Closes-Bug: #1428424

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

Change abandoned by Ankit Agrawal (<email address hidden>) on branch: master
Review: https://review.openstack.org/186993

Thierry Carrez (ttx)
Changed in neutron:
milestone: none → liberty-1
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (feature/pecan)

Fix proposed to branch: feature/pecan
Review: https://review.openstack.org/196701

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (feature/pecan)

Change abandoned by Kyle Mestery (<email address hidden>) on branch: feature/pecan
Review: https://review.openstack.org/196701
Reason: This is lacking the functional fix [1], so I'll propose a new merge commit which includes that one.

[1] https://review.openstack.org/#/c/196711/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (feature/pecan)

Fix proposed to branch: feature/pecan
Review: https://review.openstack.org/196920

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

In nova.test module there is a nested implementation that works with both PY3 and PY2.

Thierry Carrez (ttx)
Changed in neutron:
milestone: liberty-1 → 7.0.0
Changed in nova:
assignee: ChangBo Guo(gcb) (glongwave) → Davanum Srinivas (DIMS) (dims-v)
status: In Progress → 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.