Skip to content

Commit b9e52df

Browse files
committed
resolve copilot comments
1 parent c0850de commit b9e52df

9 files changed

Lines changed: 21 additions & 15 deletions

File tree

engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ CREATE TABLE IF NOT EXISTS `cloud`.`dns_zone_network_map` (
547547
`created` datetime NOT NULL COMMENT 'date created',
548548
`removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
549549
PRIMARY KEY (`id`),
550-
CONSTRAINT `uc_dns_zone__uuid` UNIQUE (`uuid`),
550+
CONSTRAINT `uc_dns_zone_network_map__uuid` UNIQUE (`uuid`),
551551
KEY `fk_dns_map__zone_id` (`dns_zone_id`),
552552
KEY `fk_dns_map__network_id` (`network_id`),
553553
CONSTRAINT `fk_dns_map__zone_id` FOREIGN KEY (`dns_zone_id`) REFERENCES `dns_zone` (`id`) ON DELETE CASCADE,

server/src/main/java/com/cloud/api/ApiDBUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ public static Pair<String, String> findDnsZoneByNetworkId(long networkId) {
23142314
DnsZoneNetworkMapVO dnsNetworkMapVO = s_dnsZoneNetworkMapDao.findByNetworkId(networkId);
23152315
if (dnsNetworkMapVO != null) {
23162316
DnsZoneVO dnsZoneVO = s_dnsZoneDao.findById(dnsNetworkMapVO.getDnsZoneId());
2317-
if (Strings.isNotBlank(dnsZoneVO.getName())) {
2317+
if (dnsZoneVO != null && Strings.isNotBlank(dnsZoneVO.getName())) {
23182318
return new Pair<> (dnsZoneVO.getName(), dnsNetworkMapVO.getSubDomain());
23192319
}
23202320
}

server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ public boolean deleteDnsServer(DeleteDnsServerCmd cmd) {
320320
accountMgr.checkAccess(caller, null, true, dnsServer);
321321
return Transaction.execute((TransactionCallback<Boolean>) status -> {
322322
if (cmd.getCleanup()) {
323-
List<DnsZoneVO> dnsZones = dnsZoneDao.findDnsZonesByServerId(dnsServerId);
324-
for (DnsZoneVO dnsZone : dnsZones) {
323+
List<Long> dnsZoneIds = dnsZoneDao.findDnsZoneIdsByServerId(dnsServerId);
324+
for (Long dnsZoneId : dnsZoneIds) {
325325
try {
326-
deleteDnsZone(dnsZone.getId(), cmd.isUnmanage());
326+
deleteDnsZone(dnsZoneId, cmd.isUnmanage());
327327
} catch (Exception ex) {
328-
logger.error("Error cleaning up DNS zone: {} during DNS server: {} deletion", dnsZone.getName(), dnsServer.getName());
328+
logger.error("Error cleaning up DNS zone: {} during DNS server: {} deletion", dnsZoneId, dnsServer.getName());
329329
}
330330
}
331331
}

server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ public interface DnsZoneDao extends GenericDao<DnsZoneVO, Long> {
3333
Pair<List<DnsZoneVO>, Integer> searchZones(Long id, Long accountId, List<Long> ownDnsServerIds, Long targetDnsServerId,
3434
String keyword, Filter filter);
3535

36-
List<DnsZoneVO> findDnsZonesByServerId(long dnsServerId);
36+
List<Long> findDnsZoneIdsByServerId(long dnsServerId);
3737
}

server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneDaoImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
package org.apache.cloudstack.dns.dao;
1919

20+
import java.util.ArrayList;
2021
import java.util.List;
22+
import java.util.stream.Collectors;
2123

2224
import org.apache.cloudstack.api.ApiConstants;
2325
import org.apache.cloudstack.dns.DnsZone;
@@ -114,9 +116,13 @@ public Pair<List<DnsZoneVO>, Integer> searchZones(Long id, Long accountId, List<
114116
return searchAndCount(sc, filter);
115117
}
116118

117-
public List<DnsZoneVO> findDnsZonesByServerId(long dnsServerId) {
119+
public List<Long> findDnsZoneIdsByServerId(long dnsServerId) {
118120
SearchCriteria<DnsZoneVO> sc = DnsServerSearch.create();
119121
sc.setParameters(ApiConstants.DNS_SERVER_ID, dnsServerId);
120-
return listBy(sc);
122+
List<DnsZoneVO> dnsZones = listBy(sc);
123+
if (CollectionUtils.isEmpty(dnsZones)) {
124+
return new ArrayList<>();
125+
}
126+
return dnsZones.stream().map(DnsZoneVO::getId).collect(Collectors.toList());
121127
}
122128
}

server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneNetworkMapDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ public interface DnsZoneNetworkMapDao extends GenericDao<DnsZoneNetworkMapVO, Lo
2525
void removeNetworkMappingByZoneId(long dnsZoneId);
2626
DnsZoneNetworkMapVO findByNetworkId(long networkId);
2727

28-
DnsZoneNetworkMapVO findByZoneId(long networkId);
28+
DnsZoneNetworkMapVO findByZoneId(long dnsZoneId);
2929
}

server/src/test/java/org/apache/cloudstack/dns/DnsProviderManagerImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ public void testDeleteDnsServerWithCleanup() throws Exception {
372372
doNothing().when(accountMgr).checkAccess(any(Account.class),
373373
nullable(org.apache.cloudstack.acl.SecurityChecker.AccessType.class), eq(true), any());
374374

375-
List<DnsZoneVO> zones = Collections.singletonList(zoneVO);
376-
when(dnsZoneDao.findDnsZonesByServerId(SERVER_ID)).thenReturn(zones);
375+
List<Long> zones = Collections.singletonList(ZONE_ID);
376+
when(dnsZoneDao.findDnsZoneIdsByServerId(SERVER_ID)).thenReturn(zones);
377377
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
378378
when(dnsZoneNetworkMapDao.findByZoneId(ZONE_ID)).thenReturn(null);
379379
when(dnsServerDao.remove(SERVER_ID)).thenReturn(true);

server/src/test/java/org/apache/cloudstack/dns/dao/DnsZoneDaoImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public void testFindByNameServerAndType() {
7171
}
7272

7373
@Test
74-
public void testFindDnsZonesByServerId() {
74+
public void testFindDnsZoneIdsByServerId() {
7575
List<DnsZoneVO> expected = Collections.singletonList(mockZone);
7676
doReturn(expected).when(dao).listBy(any(SearchCriteria.class));
7777

78-
List<DnsZoneVO> result = dao.findDnsZonesByServerId(1L);
78+
List<Long> result = dao.findDnsZoneIdsByServerId(1L);
7979
assertEquals(1, result.size());
8080
}
8181

ui/src/components/view/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
<template v-if="column.key === 'templatetype'">
208208
<span>{{ text }}</span>
209209
</template>
210-
<template v-if="$route.path.startsWith('/dnsserver') && !['name', 'provider'].includes(column.key)">
210+
<template v-if="$route.path.startsWith('/dnsserver') && !['name', 'provider', 'state', 'ispublic'].includes(column.key)">
211211
<span>{{ text }}</span>
212212
</template>
213213
<template v-if="column.key === 'gpu'">

0 commit comments

Comments
 (0)