resolve copilot comments

This commit is contained in:
Manoj Kumar 2026-07-06 11:10:57 +05:30
parent c0850de4b1
commit b9e52df5ee
No known key found for this signature in database
GPG Key ID: E952B7234D2C6F88
9 changed files with 21 additions and 15 deletions

View File

@ -547,7 +547,7 @@ CREATE TABLE IF NOT EXISTS `cloud`.`dns_zone_network_map` (
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
PRIMARY KEY (`id`),
CONSTRAINT `uc_dns_zone__uuid` UNIQUE (`uuid`),
CONSTRAINT `uc_dns_zone_network_map__uuid` UNIQUE (`uuid`),
KEY `fk_dns_map__zone_id` (`dns_zone_id`),
KEY `fk_dns_map__network_id` (`network_id`),
CONSTRAINT `fk_dns_map__zone_id` FOREIGN KEY (`dns_zone_id`) REFERENCES `dns_zone` (`id`) ON DELETE CASCADE,

View File

@ -2314,7 +2314,7 @@ public class ApiDBUtils {
DnsZoneNetworkMapVO dnsNetworkMapVO = s_dnsZoneNetworkMapDao.findByNetworkId(networkId);
if (dnsNetworkMapVO != null) {
DnsZoneVO dnsZoneVO = s_dnsZoneDao.findById(dnsNetworkMapVO.getDnsZoneId());
if (Strings.isNotBlank(dnsZoneVO.getName())) {
if (dnsZoneVO != null && Strings.isNotBlank(dnsZoneVO.getName())) {
return new Pair<> (dnsZoneVO.getName(), dnsNetworkMapVO.getSubDomain());
}
}

View File

@ -320,12 +320,12 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
accountMgr.checkAccess(caller, null, true, dnsServer);
return Transaction.execute((TransactionCallback<Boolean>) status -> {
if (cmd.getCleanup()) {
List<DnsZoneVO> dnsZones = dnsZoneDao.findDnsZonesByServerId(dnsServerId);
for (DnsZoneVO dnsZone : dnsZones) {
List<Long> dnsZoneIds = dnsZoneDao.findDnsZoneIdsByServerId(dnsServerId);
for (Long dnsZoneId : dnsZoneIds) {
try {
deleteDnsZone(dnsZone.getId(), cmd.isUnmanage());
deleteDnsZone(dnsZoneId, cmd.isUnmanage());
} catch (Exception ex) {
logger.error("Error cleaning up DNS zone: {} during DNS server: {} deletion", dnsZone.getName(), dnsServer.getName());
logger.error("Error cleaning up DNS zone: {} during DNS server: {} deletion", dnsZoneId, dnsServer.getName());
}
}
}

View File

@ -33,5 +33,5 @@ public interface DnsZoneDao extends GenericDao<DnsZoneVO, Long> {
Pair<List<DnsZoneVO>, Integer> searchZones(Long id, Long accountId, List<Long> ownDnsServerIds, Long targetDnsServerId,
String keyword, Filter filter);
List<DnsZoneVO> findDnsZonesByServerId(long dnsServerId);
List<Long> findDnsZoneIdsByServerId(long dnsServerId);
}

View File

@ -17,7 +17,9 @@
package org.apache.cloudstack.dns.dao;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.dns.DnsZone;
@ -114,9 +116,13 @@ public class DnsZoneDaoImpl extends GenericDaoBase<DnsZoneVO, Long> implements D
return searchAndCount(sc, filter);
}
public List<DnsZoneVO> findDnsZonesByServerId(long dnsServerId) {
public List<Long> findDnsZoneIdsByServerId(long dnsServerId) {
SearchCriteria<DnsZoneVO> sc = DnsServerSearch.create();
sc.setParameters(ApiConstants.DNS_SERVER_ID, dnsServerId);
return listBy(sc);
List<DnsZoneVO> dnsZones = listBy(sc);
if (CollectionUtils.isEmpty(dnsZones)) {
return new ArrayList<>();
}
return dnsZones.stream().map(DnsZoneVO::getId).collect(Collectors.toList());
}
}

View File

@ -25,5 +25,5 @@ public interface DnsZoneNetworkMapDao extends GenericDao<DnsZoneNetworkMapVO, Lo
void removeNetworkMappingByZoneId(long dnsZoneId);
DnsZoneNetworkMapVO findByNetworkId(long networkId);
DnsZoneNetworkMapVO findByZoneId(long networkId);
DnsZoneNetworkMapVO findByZoneId(long dnsZoneId);
}

View File

@ -372,8 +372,8 @@ public class DnsProviderManagerImplTest {
doNothing().when(accountMgr).checkAccess(any(Account.class),
nullable(org.apache.cloudstack.acl.SecurityChecker.AccessType.class), eq(true), any());
List<DnsZoneVO> zones = Collections.singletonList(zoneVO);
when(dnsZoneDao.findDnsZonesByServerId(SERVER_ID)).thenReturn(zones);
List<Long> zones = Collections.singletonList(ZONE_ID);
when(dnsZoneDao.findDnsZoneIdsByServerId(SERVER_ID)).thenReturn(zones);
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
when(dnsZoneNetworkMapDao.findByZoneId(ZONE_ID)).thenReturn(null);
when(dnsServerDao.remove(SERVER_ID)).thenReturn(true);

View File

@ -71,11 +71,11 @@ public class DnsZoneDaoImplTest {
}
@Test
public void testFindDnsZonesByServerId() {
public void testFindDnsZoneIdsByServerId() {
List<DnsZoneVO> expected = Collections.singletonList(mockZone);
doReturn(expected).when(dao).listBy(any(SearchCriteria.class));
List<DnsZoneVO> result = dao.findDnsZonesByServerId(1L);
List<Long> result = dao.findDnsZoneIdsByServerId(1L);
assertEquals(1, result.size());
}

View File

@ -207,7 +207,7 @@
<template v-if="column.key === 'templatetype'">
<span>{{ text }}</span>
</template>
<template v-if="$route.path.startsWith('/dnsserver') && !['name', 'provider'].includes(column.key)">
<template v-if="$route.path.startsWith('/dnsserver') && !['name', 'provider', 'state', 'ispublic'].includes(column.key)">
<span>{{ text }}</span>
</template>
<template v-if="column.key === 'gpu'">