Merge "Fix check+set race condition in APIv1/Sink"
This commit is contained in:
commit
20d4c22bb3
@ -46,9 +46,7 @@ def _find_or_create_recordset(context, domain_id, name, type, ttl):
|
|||||||
central_api.find_domain(context, criterion=criterion)
|
central_api.find_domain(context, criterion=criterion)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
recordset = _find_recordset(context, domain_id, name, type)
|
# Attempt to create an empty recordset
|
||||||
except exceptions.RecordSetNotFound:
|
|
||||||
# Create an empty recordset
|
|
||||||
values = {
|
values = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'type': type,
|
'type': type,
|
||||||
@ -58,6 +56,10 @@ def _find_or_create_recordset(context, domain_id, name, type, ttl):
|
|||||||
recordset = central_api.create_recordset(
|
recordset = central_api.create_recordset(
|
||||||
context, domain_id, objects.RecordSet(**values))
|
context, domain_id, objects.RecordSet(**values))
|
||||||
|
|
||||||
|
except exceptions.DuplicateRecordSet:
|
||||||
|
# Fetch the existing recordset
|
||||||
|
recordset = _find_recordset(context, domain_id, name, type)
|
||||||
|
|
||||||
return recordset
|
return recordset
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,12 +69,7 @@ class NotificationHandler(ExtensionPlugin):
|
|||||||
name = name.encode('idna')
|
name = name.encode('idna')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
recordset = self.central_api.find_recordset(context, {
|
# Attempt to create an empty recordset
|
||||||
'domain_id': domain_id,
|
|
||||||
'name': name,
|
|
||||||
'type': type,
|
|
||||||
})
|
|
||||||
except exceptions.RecordSetNotFound:
|
|
||||||
values = {
|
values = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'type': type,
|
'type': type,
|
||||||
@ -83,6 +78,14 @@ class NotificationHandler(ExtensionPlugin):
|
|||||||
recordset = self.central_api.create_recordset(
|
recordset = self.central_api.create_recordset(
|
||||||
context, domain_id, RecordSet(**values))
|
context, domain_id, RecordSet(**values))
|
||||||
|
|
||||||
|
except exceptions.DuplicateRecordSet:
|
||||||
|
# Fetch the existing recordset
|
||||||
|
recordset = self.central_api.find_recordset(context, {
|
||||||
|
'domain_id': domain_id,
|
||||||
|
'name': name,
|
||||||
|
'type': type,
|
||||||
|
})
|
||||||
|
|
||||||
return recordset
|
return recordset
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user