designate: allow PTR zone creation to fail
When multiple PTR records are created at the same time, Neutron may try
to create the same zone multiple times, resulting in a conflict. Ignore
the resulting error instead and try to create the record anyway.
Change-Id: I59b0f99463ab00743f19016a890561916df900ed
Closes-Bug: 1891309
(cherry picked from commit ca1c6fd69b
)
This commit is contained in:
parent
3e818718b6
commit
e9b7c64802
|
@ -23,6 +23,7 @@ from keystoneauth1 import token_endpoint
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib.exceptions import dns as dns_exc
|
from neutron_lib.exceptions import dns as dns_exc
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
from neutron.conf.services import extdns_designate_driver
|
from neutron.conf.services import extdns_designate_driver
|
||||||
from neutron.services.externaldns import driver
|
from neutron.services.externaldns import driver
|
||||||
|
@ -37,6 +38,8 @@ _SESSION = None
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
extdns_designate_driver.register_designate_opts()
|
extdns_designate_driver.register_designate_opts()
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_clients(context):
|
def get_clients(context):
|
||||||
global _SESSION
|
global _SESSION
|
||||||
|
@ -117,9 +120,20 @@ class Designate(driver.ExternalDNSService):
|
||||||
in_addr_name, 'PTR',
|
in_addr_name, 'PTR',
|
||||||
[recordset_name])
|
[recordset_name])
|
||||||
except d_exc.NotFound:
|
except d_exc.NotFound:
|
||||||
designate_admin.zones.create(
|
# Note(jh): If multiple PTRs get created at the same time,
|
||||||
in_addr_zone_name, email=ptr_zone_email,
|
# the creation of the zone may fail with a conflict because
|
||||||
description=in_addr_zone_description)
|
# it has already been created by a parallel job. So we
|
||||||
|
# ignore that error and try to create the recordset
|
||||||
|
# anyway. That call will still fail in the end if something
|
||||||
|
# is really broken. See bug 1891309.
|
||||||
|
try:
|
||||||
|
designate_admin.zones.create(
|
||||||
|
in_addr_zone_name, email=ptr_zone_email,
|
||||||
|
description=in_addr_zone_description)
|
||||||
|
except d_exc.Conflict:
|
||||||
|
LOG.debug('Conflict when trying to create PTR zone %s,'
|
||||||
|
' assuming it exists.',
|
||||||
|
in_addr_zone_name)
|
||||||
designate_admin.recordsets.create(in_addr_zone_name,
|
designate_admin.recordsets.create(in_addr_zone_name,
|
||||||
in_addr_name, 'PTR',
|
in_addr_name, 'PTR',
|
||||||
[recordset_name])
|
[recordset_name])
|
||||||
|
|
Loading…
Reference in New Issue