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
Fix proposed to branch: master /review. openstack. org/161619
Review: https:/