Catch duplicate db inserts in powerdns plugin

Catches duplicate db exceptions in the powerdns plugin, allowing it
to recover when a create is initially successful, but doesn't propagate
fast enough

Change-Id: I1a9d66c069b1f0f231618a369e31ce9be2e3c5c5
closes-bug: 1594582
This commit is contained in:
Tim Simmons 2016-06-20 22:28:45 +01:00
parent 812780d45b
commit 424ebf3206

View File

@ -19,6 +19,7 @@ import threading
import six
from oslo_config import cfg
from oslo_db import options
from oslo_db.exception import DBDuplicateEntry
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy.sql import select
@ -136,6 +137,11 @@ class PowerDNSBackend(base.Backend):
}
self._create(tables.domains, domain_values)
except DBDuplicateEntry:
LOG.debug('Successful create of %s in pdns, zone already exists'
% zone['name'])
# If create fails because the zone exists, don't reraise
pass
except Exception:
with excutils.save_and_reraise_exception():
self.session.rollback()