Skip to content

Commit 2ee566c

Browse files
network: skip dhcp and dns health checks on internal LB routers
An internal LB VM runs only the load balancer, but it was given the full virtual router health check set, so the dhcp and dns checks failed on every advanced health check run and flooded the event log. Exclude those checks for a router whose role is internal LB, using the existing per-router excluded-checks mechanism. Fixes: #12658
1 parent 3a79799 commit 2ee566c

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
276276
private static final String FILESYSTEM_WRITABLE_TEST = "filesystem.writable.test";
277277
private static final String READONLY_FILESYSTEM_ERROR = "Read-only file system";
278278
private static final String BACKUP_ROUTER_EXCLUDED_TESTS = "gateways_check.py";
279+
private static final String INTERNAL_LB_EXCLUDED_TESTS = "dhcp_check.py,dns_check.py";
279280
/**
280281
* Used regex to ensure that the value that will be passed to the VR is an acceptable value
281282
*/
@@ -1616,6 +1617,9 @@ private SetMonitorServiceCommand createMonitorServiceCommand(DomainRouterVO rout
16161617
excludedTests = excludedTests.isEmpty() ? BACKUP_ROUTER_EXCLUDED_TESTS : excludedTests + "," + BACKUP_ROUTER_EXCLUDED_TESTS;
16171618
}
16181619
}
1620+
if (router.getRole() == Role.INTERNAL_LB_VM) {
1621+
excludedTests = excludedTests.isEmpty() ? INTERNAL_LB_EXCLUDED_TESTS : excludedTests + "," + INTERNAL_LB_EXCLUDED_TESTS;
1622+
}
16191623

16201624
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, excludedTests);
16211625
command.setHealthChecksConfig(routerHealthCheckConfig);

server/src/test/java/com/cloud/network/router/VirtualNetworkApplianceManagerImplTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import com.cloud.user.dao.UserDao;
6868
import com.cloud.user.dao.UserStatisticsDao;
6969
import com.cloud.user.dao.UserStatsLogDao;
70+
import com.cloud.agent.api.routing.SetMonitorServiceCommand;
7071
import com.cloud.vm.DomainRouterVO;
7172
import com.cloud.vm.VirtualMachine;
7273
import com.cloud.vm.VirtualMachineManager;
@@ -91,6 +92,7 @@
9192
import java.util.ArrayList;
9293
import java.util.Date;
9394
import java.util.List;
95+
import java.util.Map;
9496

9597
import static org.junit.Assert.assertEquals;
9698
import static org.mockito.ArgumentMatchers.nullable;
@@ -354,6 +356,28 @@ public void checkLogrotateTimerPatternTestMatchesWithRegex(){
354356
Assert.assertTrue(result);
355357
}
356358

359+
@Test
360+
public void testInternalLbRouterExcludesDhcpAndDnsHealthChecks() throws Exception {
361+
DomainRouterVO router = Mockito.mock(DomainRouterVO.class);
362+
when(router.getId()).thenReturn(1L);
363+
when(router.getInstanceName()).thenReturn("r-1-VM");
364+
when(router.getDataCenterId()).thenReturn(1L);
365+
when(router.getIsRedundantRouter()).thenReturn(false);
366+
when(router.getRole()).thenReturn(VirtualRouter.Role.INTERNAL_LB_VM);
367+
when(_routerControlHelper.getRouterControlIp(1L)).thenReturn("169.254.0.1");
368+
369+
java.lang.reflect.Method method = VirtualNetworkApplianceManagerImpl.class.getDeclaredMethod(
370+
"createMonitorServiceCommand", DomainRouterVO.class, List.class, boolean.class, boolean.class, Map.class);
371+
method.setAccessible(true);
372+
SetMonitorServiceCommand command = (SetMonitorServiceCommand) method.invoke(
373+
virtualNetworkApplianceManagerImpl, router, null, true, true, null);
374+
375+
String excluded = command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED);
376+
Assert.assertNotNull(excluded);
377+
Assert.assertTrue("Internal LB VM should exclude dhcp and dns health checks, got: " + excluded,
378+
excluded.contains("dhcp_check.py") && excluded.contains("dns_check.py"));
379+
}
380+
357381
@Test
358382
public void testFinalizeNetworkRulesForNetwork() {
359383
Long guestNetworkId = 10L;

0 commit comments

Comments
 (0)