Don't assume backend resource was created if no ManagerError raised

A backend call may fail with ServiceClusterUnavailable, which is not a
ManagerError, therefore, we should not assume that backend resources were
succesfully created if no ManagerError was raised.

This patch only changes the create_security_group method with that
logic, other methods may also require a similar change.

Change-Id: I0170b910f246e8bb0d05fca12d4d8de3cbb26a4f
Closes-Bug: #1546474
This commit is contained in:
Roey Chen 2016-02-17 02:46:16 -08:00
parent b6b224ea98
commit 6f68b51626

View File

@ -1651,12 +1651,16 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
firewall.delete_nsgroup(ns_group['id'])
except Exception:
with excutils.save_and_reraise_exception():
section_id = firewall_section.get('id')
nsgroup_id = ns_group.get('id')
LOG.debug("Neutron failed to create security-group, "
"deleting backend resources: "
"section %s, ns-group %s.",
firewall_section['id'], ns_group['id'])
firewall.delete_nsgroup(ns_group['id'])
firewall.delete_section(firewall_section['id'])
section_id, nsgroup_id)
if nsgroup_id:
firewall.delete_nsgroup(nsgroup_id)
if section_id:
firewall.delete_section(section_id)
try:
sg_rules = secgroup_db['security_group_rules']
# translate and creates firewall rules.