Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
private static final String FILESYSTEM_WRITABLE_TEST = "filesystem.writable.test";
private static final String READONLY_FILESYSTEM_ERROR = "Read-only file system";
private static final String BACKUP_ROUTER_EXCLUDED_TESTS = "gateways_check.py";
private static final String INTERNAL_LB_EXCLUDED_TESTS = "dhcp_check.py,dns_check.py";
/**
* Used regex to ensure that the value that will be passed to the VR is an acceptable value
*/
Expand Down Expand Up @@ -1616,6 +1617,9 @@ private SetMonitorServiceCommand createMonitorServiceCommand(DomainRouterVO rout
excludedTests = excludedTests.isEmpty() ? BACKUP_ROUTER_EXCLUDED_TESTS : excludedTests + "," + BACKUP_ROUTER_EXCLUDED_TESTS;
}
}
if (router.getRole() == Role.INTERNAL_LB_VM) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens to the old failed dhcp and dns results on internal lb vms that already exist? looks like nothing updates them anymore so they might stay failed until the vm is recreated

@nagaboinaramgopal nagaboinaramgopal Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old results don't stay until recreation, they get cleared on the normal health check cycle. getFailingChecks (run by FetchRouterHealthChecksResultTask on a fixed interval) calls resetRouterHealthChecksAndConnectivity first, which expunges all stored results for the router, and then re-persists only the checks the agent reported that round (L1199-1200). Once the excluded-tests config reaches the internal LB VM the agent stops reporting dhcp and dns, so on the next fetch the old failed rows are expunged and not re-added.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, the periodic config push plus the reset on each fetch clears them. thanks

excludedTests = excludedTests.isEmpty() ? INTERNAL_LB_EXCLUDED_TESTS : excludedTests + "," + INTERNAL_LB_EXCLUDED_TESTS;
}

command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, excludedTests);
command.setHealthChecksConfig(routerHealthCheckConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import com.cloud.user.dao.UserDao;
import com.cloud.user.dao.UserStatisticsDao;
import com.cloud.user.dao.UserStatsLogDao;
import com.cloud.agent.api.routing.SetMonitorServiceCommand;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineManager;
Expand All @@ -78,6 +79,7 @@
import com.cloud.vm.dao.VMInstanceDao;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.BgpPeer;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.network.RoutedIpv4Manager;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.junit.Assert;
Expand All @@ -91,6 +93,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.nullable;
Expand Down Expand Up @@ -354,6 +357,28 @@ public void checkLogrotateTimerPatternTestMatchesWithRegex(){
Assert.assertTrue(result);
}

@Test
public void testInternalLbRouterExcludesDhcpAndDnsHealthChecks() throws Exception {
DomainRouterVO router = Mockito.mock(DomainRouterVO.class);
when(router.getId()).thenReturn(1L);
when(router.getInstanceName()).thenReturn("r-1-VM");
when(router.getDataCenterId()).thenReturn(1L);
when(router.getIsRedundantRouter()).thenReturn(false);
when(router.getRole()).thenReturn(VirtualRouter.Role.INTERNAL_LB_VM);
when(_routerControlHelper.getRouterControlIp(1L)).thenReturn("169.254.0.1");

java.lang.reflect.Method method = VirtualNetworkApplianceManagerImpl.class.getDeclaredMethod(
"createMonitorServiceCommand", DomainRouterVO.class, List.class, boolean.class, boolean.class, Map.class);
method.setAccessible(true);
SetMonitorServiceCommand command = (SetMonitorServiceCommand) method.invoke(
virtualNetworkApplianceManagerImpl, router, null, true, true, null);

String excluded = command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED);
Assert.assertNotNull(excluded);
Assert.assertTrue("Internal LB VM should exclude dhcp and dns health checks, got: " + excluded,
excluded.contains("dhcp_check.py") && excluded.contains("dns_check.py"));
}

@Test
public void testFinalizeNetworkRulesForNetwork() {
Long guestNetworkId = 10L;
Expand Down Expand Up @@ -391,4 +416,56 @@ public void testFinalizeNetworkRulesForVpcNetwork() {

Mockito.verify(_commandSetupHelper).createBgpPeersCommands(bgpPeers, router, cmds, network);
}

@Test
public void testNonInternalLbRouterDoesNotExcludeDhcpAndDnsHealthChecks() throws Exception {
DomainRouterVO router = Mockito.mock(DomainRouterVO.class);
when(router.getId()).thenReturn(1L);
when(router.getInstanceName()).thenReturn("r-1-VM");
when(router.getDataCenterId()).thenReturn(1L);
when(router.getIsRedundantRouter()).thenReturn(false);
when(router.getRole()).thenReturn(VirtualRouter.Role.VIRTUAL_ROUTER);
Mockito.lenient().when(_routerControlHelper.getRouterControlIp(1L)).thenReturn("169.254.0.1");

java.lang.reflect.Method method = VirtualNetworkApplianceManagerImpl.class.getDeclaredMethod(
"createMonitorServiceCommand", DomainRouterVO.class, List.class, boolean.class, boolean.class, Map.class);
method.setAccessible(true);
SetMonitorServiceCommand command = (SetMonitorServiceCommand) method.invoke(
virtualNetworkApplianceManagerImpl, router, null, true, true, null);

String excluded = command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED);
Assert.assertTrue("A non internal LB router must not exclude the dhcp and dns checks, got: " + excluded,
excluded == null || (!excluded.contains("dhcp_check.py") && !excluded.contains("dns_check.py")));
}

@Test
public void testInternalLbRouterAppendsToExistingExcludedHealthChecks() throws Exception {
java.lang.reflect.Field defaultValueField = ConfigKey.class.getDeclaredField("_defaultValue");
defaultValueField.setAccessible(true);
Object original = defaultValueField.get(VirtualNetworkApplianceManager.RouterHealthChecksToExclude);
try {
defaultValueField.set(VirtualNetworkApplianceManager.RouterHealthChecksToExclude, "custom_check.py");

DomainRouterVO router = Mockito.mock(DomainRouterVO.class);
when(router.getId()).thenReturn(1L);
when(router.getInstanceName()).thenReturn("r-1-VM");
when(router.getDataCenterId()).thenReturn(1L);
when(router.getIsRedundantRouter()).thenReturn(false);
when(router.getRole()).thenReturn(VirtualRouter.Role.INTERNAL_LB_VM);
Mockito.lenient().when(_routerControlHelper.getRouterControlIp(1L)).thenReturn("169.254.0.1");

java.lang.reflect.Method method = VirtualNetworkApplianceManagerImpl.class.getDeclaredMethod(
"createMonitorServiceCommand", DomainRouterVO.class, List.class, boolean.class, boolean.class, Map.class);
method.setAccessible(true);
SetMonitorServiceCommand command = (SetMonitorServiceCommand) method.invoke(
virtualNetworkApplianceManagerImpl, router, null, true, true, null);

String excluded = command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED);
Assert.assertNotNull(excluded);
Assert.assertTrue("Internal LB VM should append dhcp and dns to the existing exclusions, got: " + excluded,
excluded.contains("custom_check.py") && excluded.contains("dhcp_check.py") && excluded.contains("dns_check.py"));
} finally {
defaultValueField.set(VirtualNetworkApplianceManager.RouterHealthChecksToExclude, original);
}
}
}