ptg wrongly created with null subnet, cannot be deleted either

Bug #1416177 reported by puppet-py
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Group Based Policy
Fix Released
Medium
Robert Kukura

Bug Description

Steps to create:
=============
1. Create a L3 policy with subnet-prefix-length larger than that of ip-pool subnet
2. Create a L2 policy and associate the above L3policy
3. Now create a PTG using the above L2policy
4. Now deletion of PTG will consistently fail because its implicit deletion of subnet will fail, as there is no subnet associated with that PTG

Proposing to fix the following:
1. If subnet allocation fails during PTG creation, the PTG object should not be even created
2. If there is no PT associated with the PTG, then PTG deletion should be allowed, if in this error case of implicit subnet being a null list

Observation:
==========
@Step 3: PTG creation errors out because of Bug #1416156, however the PTG Object gets created without "subnet"

test@localhost:~/devstack$ gbp policy-target-group-create new --l2-policy new
Service Unavailable (HTTP 503) (Request-ID: req-646f599b-9882-4de7-a2fa-0b4400055e67)
test@localhost:~/devstack$
test@localhost:~/devstack$ gbp policy-target-group-show new
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| consumed_policy_rule_sets | |
| description | |
| id | 1113768b-3c62-4ba4-8449-7b529b36efa7 |
| l2_policy_id | 53c6c47c-ec65-4b74-80de-5941534d900b |
| name | new |
| network_service_policy_id | |
| policy_targets | |
| provided_policy_rule_sets | |
| shared | False |
| subnets | | <<<<<<<< as you see, there is no subnet here
| tenant_id | b3094e3ded7e4d6ea7b91b3641214a7a |
+---------------------------+--------------------------------------+
test@localhost:~/devstack$

@Step 4: PTG deletion fails with this below log:

2015-01-29 14:48:28.949 19570 DEBUG gbpservice.neutron.services.grouppolicy.drivers.resource_mapping [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] gbpservice.neutron.services.grouppolicy.drivers.resource_mapping.ResourceMappingDriver method delete_policy_target_group_precommit called with arguments (<gbpservice.neutron.services.grouppolicy.group_policy_context.PolicyTargetGroupContext object at 0x7f3e2cfeaf90>,) {} wrapper /opt/stack/neutron/neutron/common/log.py:33
2015-01-29 14:48:28.950 19570 DEBUG gbpservice.neutron.db.grouppolicy.group_policy_db [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] gbpservice.neutron.services.grouppolicy.plugin.GroupPolicyPlugin method delete_policy_target_group called with arguments (<neutron.context.Context object at 0x7f3e2cd3abd0>, u'1113768b-3c62-4ba4-8449-7b529b36efa7') {} wrapper /opt/stack/neutron/neutron/common/log.py:33
2015-01-29 14:48:28.958 19570 DEBUG gbpservice.neutron.services.grouppolicy.drivers.resource_mapping [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] gbpservice.neutron.services.grouppolicy.drivers.resource_mapping.ResourceMappingDriver method delete_policy_target_group_postcommit called with arguments (<gbpservice.neutron.services.grouppolicy.group_policy_context.PolicyTargetGroupContext object at 0x7f3e2cfeaf90>,) {} wrapper /opt/stack/neutron/neutron/common/log.py:33
2015-01-29 14:48:28.959 19570 ERROR gbpservice.neutron.services.grouppolicy.policy_driver_manager [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] Policy driver 'resource_mapping' failed in delete_policy_target_group_postcommit
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager Traceback (most recent call last):
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager File "/opt/stack/gbpservice/gbpservice/neutron/services/grouppolicy/policy_driver_manager.py", line 119, in _call_on_drivers
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager getattr(driver.obj, method_name)(context)
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager File "/opt/stack/neutron/neutron/common/log.py", line 34, in wrapper
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager return method(*args, **kwargs)
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager File "/opt/stack/gbpservice/gbpservice/neutron/services/grouppolicy/drivers/resource_mapping.py", line 502, in delete_policy_target_group_postcommit
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager context.current['subnets'][0],
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager IndexError: list index out of range
2015-01-29 14:48:28.959 19570 TRACE gbpservice.neutron.services.grouppolicy.policy_driver_manager
2015-01-29 14:48:28.960 19570 DEBUG gbpservice.neutron.services.grouppolicy.drivers.implicit_policy [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] gbpservice.neutron.services.grouppolicy.drivers.implicit_policy.ImplicitPolicyDriver method delete_policy_target_group_postcommit called with arguments (<gbpservice.neutron.services.grouppolicy.group_policy_context.PolicyTargetGroupContext object at 0x7f3e2cfeaf90>,) {} wrapper /opt/stack/neutron/neutron/common/log.py:33
2015-01-29 14:48:28.962 19570 ERROR gbpservice.neutron.services.grouppolicy.plugin [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] delete_policy_target_group_postcommit failed, deleting policy_target_group '1113768b-3c62-4ba4-8449-7b529b36efa7'
2015-01-29 14:48:28.962 19570 ERROR neutron.api.v2.resource [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] delete failed
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource Traceback (most recent call last):
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/resource.py", line 87, in resource
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource result = method(request=request, **args)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 476, in delete
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource obj_deleter(request.context, id, **kwargs)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/common/log.py", line 34, in wrapper
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource return method(*args, **kwargs)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/gbpservice/gbpservice/neutron/services/grouppolicy/plugin.py", line 455, in delete_policy_target_group
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource policy_target_group_id)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/openstack/common/excutils.py", line 82, in __exit__
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/gbpservice/gbpservice/neutron/services/grouppolicy/plugin.py", line 450, in delete_policy_target_group
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource policy_context)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/gbpservice/gbpservice/neutron/services/grouppolicy/policy_driver_manager.py", line 173, in delete_policy_target_group_postcommit
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource continue_on_failure=True)
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource File "/opt/stack/gbpservice/gbpservice/neutron/services/grouppolicy/policy_driver_manager.py", line 134, in _call_on_drivers
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource method=method_name
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource GroupPolicyDriverError: delete_policy_target_group_postcommit failed.
2015-01-29 14:48:28.962 19570 TRACE neutron.api.v2.resource
2015-01-29 14:48:28.964 19570 INFO neutron.wsgi [req-d0fa78b0-6c68-48c2-9fcc-269cc867c64d None] 10.160.1.85 - - [29/Jan/2015 14:48:28] "DELETE /v2.0/grouppolicy/policy_target_groups/1113768b-3c62-4ba4-8449-7b529b36efa7.json HTTP/1.1" 500 335 0.027150
2015-01-29 14:48:31.067 1957

Changed in group-based-policy:
assignee: nobody → Robert Kukura (rkukura)
milestone: none → kilo-gbp-1
importance: Undecided → Medium
status: New → Confirmed
tags: added: juno-backport-potential
Changed in group-based-policy:
milestone: kilo-gbp-1 → kilo-gbp-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to group-based-policy (master)

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

Changed in group-based-policy:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

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

Reviewed: https://review.openstack.org/161619
Committed: https://git.openstack.org/cgit/stackforge/group-based-policy/commit/?id=75dd238e507e86d3dbe6436265314d565906b268
Submitter: Jenkins
Branch: master

commit 75dd238e507e86d3dbe6436265314d565906b268
Author: Robert Kukura <email address hidden>
Date: Wed Mar 4 22:02:01 2015 -0500

    Properly handle driver exceptions during postcommit

    If any exception is raised by a driver's create_<resource>_postcommit
    method, the partially-created resource is deleted before returning the
    exception to the client.

    If any exception is raised by a driver's delete_<resource>_postcommit
    method, the exception is logged, but is not returned to the client.

    Also, the log messages are made more consistent and readable.

    Closes-bug: 1407321
    Partial-bug: 1416177
    Change-Id: I7c3096ae436f23d68d695b813f7d8d0b2588dbfe

Changed in group-based-policy:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/161968
Committed: https://git.openstack.org/cgit/stackforge/group-based-policy/commit/?id=985f435acba9c8c20cd405ca2783aa7601ce68ef
Submitter: Jenkins
Branch: master

commit 985f435acba9c8c20cd405ca2783aa7601ce68ef
Author: Robert Kukura <email address hidden>
Date: Thu Mar 5 19:47:22 2015 -0500

    Avoid exception deleting PTG with no subnets

    The resource_mapping driver's PTG cleanup code no longer assumes PTG
    has at least one subnet, which can occur when subnet allocation fails
    when the PTG is created. Unit test for subnet exhaustion added.

    Closes-bug: 1416177
    Change-Id: I45529255723282b6e0d8a884cac2bd604ea9b61a

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to group-based-policy (stable/juno)

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

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

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

Changed in group-based-policy:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to group-based-policy (stable/juno)

Reviewed: https://review.openstack.org/164914
Committed: https://git.openstack.org/cgit/stackforge/group-based-policy/commit/?id=c6eaae187283c8d2a738a5eb27d1532cae34a5d7
Submitter: Jenkins
Branch: stable/juno

commit c6eaae187283c8d2a738a5eb27d1532cae34a5d7
Author: Robert Kukura <email address hidden>
Date: Wed Mar 4 22:02:01 2015 -0500

    Properly handle driver exceptions during postcommit

    If any exception is raised by a driver's create_<resource>_postcommit
    method, the partially-created resource is deleted before returning the
    exception to the client.

    If any exception is raised by a driver's delete_<resource>_postcommit
    method, the exception is logged, but is not returned to the client.

    Also, the log messages are made more consistent and readable.

    Closes-bug: 1407321
    Partial-bug: 1416177
    Change-Id: I7c3096ae436f23d68d695b813f7d8d0b2588dbfe
    (cherry picked from commit 75dd238e507e86d3dbe6436265314d565906b268)

tags: added: in-stable-juno
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/164917
Committed: https://git.openstack.org/cgit/stackforge/group-based-policy/commit/?id=d754373ad837d24d1a275d3e971e924e1cb5c155
Submitter: Jenkins
Branch: stable/juno

commit d754373ad837d24d1a275d3e971e924e1cb5c155
Author: Robert Kukura <email address hidden>
Date: Thu Mar 5 19:47:22 2015 -0500

    Avoid exception deleting PTG with no subnets

    The resource_mapping driver's PTG cleanup code no longer assumes PTG
    has at least one subnet, which can occur when subnet allocation fails
    when the PTG is created. Unit test for subnet exhaustion added.

    Closes-bug: 1416177
    Change-Id: I45529255723282b6e0d8a884cac2bd604ea9b61a
    (cherry picked from commit 985f435acba9c8c20cd405ca2783aa7601ce68ef)

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.