split cleanup of old dns urls and new record registration

This commit is contained in:
Manoj Kumar 2026-04-13 18:31:50 +05:30
parent 3ae9834325
commit a036281cd9
No known key found for this signature in database
GPG Key ID: E952B7234D2C6F88
1 changed files with 16 additions and 11 deletions

View File

@ -1009,26 +1009,31 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
List<DnsNicJoinVO> nicsForThisFqdn = newUrlEntry.getValue();
try {
Set<String> oldDnsRecordUrls = new HashSet<>();
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<DnsProviderException>() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) throws DnsProviderException {
for (DnsNicJoinVO nic : nicsForThisFqdn) {
if (nic.getNicDnsUrl() != null) {
oldDnsRecordUrls.add(nic.getNicDnsUrl());
nicDetailsDao.removeDetail(nic.getId(), ApiConstants.NIC_DNS_RECORD);
}
}
for (String oldUrl : oldDnsRecordUrls) {
syncDnsRecordsState(instanceId, oldUrl, targetZoneId);
}
}
});
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<DnsProviderException>() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) throws DnsProviderException {
if (isDnsCollision(newDnsRecordUrl, targetZoneId, instanceId)) {
return;
}
Set<String> oldDnsRecordUrls = new HashSet<>();
for (DnsNicJoinVO nic : nicsForThisFqdn) {
if (nic.getNicDnsUrl() != null) {
oldDnsRecordUrls.add(nic.getNicDnsUrl());
}
nicDetailsDao.addDetail(nic.getId(), ApiConstants.NIC_DNS_RECORD, newDnsRecordUrl, true);
}
// NICs for the old URL and cleanly send a DELETE API call to PowerDNS!
for (String oldUrl : oldDnsRecordUrls) {
syncDnsRecordsState(instanceId, oldUrl, targetZoneId);
}
// This sync call finds the newly written intent and sends an ADD/REPLACE call.
syncDnsRecordsState(instanceId, newDnsRecordUrl, targetZoneId);
}