VR: skip dhcp/dns health check in some cases (#5554)

this fixes #5536
This commit is contained in:
Wei Zhou 2021-10-08 04:52:32 +02:00 committed by GitHub
parent 2a42a01728
commit 798d7bebf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View File

@ -168,6 +168,7 @@ import com.cloud.network.dao.LoadBalancerVO;
import com.cloud.network.dao.MonitoringServiceDao;
import com.cloud.network.dao.MonitoringServiceVO;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkServiceMapDao;
import com.cloud.network.dao.NetworkVO;
import com.cloud.network.dao.OpRouterMonitorServiceDao;
import com.cloud.network.dao.OpRouterMonitorServiceVO;
@ -349,6 +350,7 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
@Inject private ApplicationLoadBalancerRuleDao applicationLoadBalancerRuleDao;
@Inject private RouterHealthCheckResultDao routerHealthCheckResultDao;
@Inject private LBStickinessPolicyDao lbStickinessPolicyDao;
@Inject private NetworkServiceMapDao _ntwkSrvcDao;
@Inject private NetworkService networkService;
@Inject private VpcService vpcService;
@ -1775,6 +1777,8 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
SearchCriteria<UserVmJoinVO> scvm = sbvm.create();
scvm.setParameters("networkId", routerJoinVO.getNetworkId());
List<UserVmJoinVO> vms = userVmJoinDao.search(scvm, null);
boolean isDhcpSupported = _ntwkSrvcDao.areServicesSupportedInNetwork(routerJoinVO.getNetworkId(), Service.Dhcp);
boolean isDnsSupported = _ntwkSrvcDao.areServicesSupportedInNetwork(routerJoinVO.getNetworkId(), Service.Dns);
for (UserVmJoinVO vm : vms) {
if (vm.getState() != VirtualMachine.State.Running) {
continue;
@ -1782,7 +1786,9 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
vmsData.append("vmName=").append(vm.getName())
.append(",macAddress=").append(vm.getMacAddress())
.append(",ip=").append(vm.getIpAddress()).append(";");
.append(",ip=").append(vm.getIpAddress())
.append(",dhcp=").append(isDhcpSupported)
.append(",dns=").append(isDnsSupported).append(";");
updateWithPortForwardingRules(routerJoinVO, vm, portData);
}
updateWithLbRules(routerJoinVO, loadBalancingData);

View File

@ -27,13 +27,20 @@ def main():
print "No VMs running data available, skipping"
exit(0)
with open('/etc/dhcphosts.txt', 'r') as hostsFile:
allHosts = hostsFile.readlines()
hostsFile.close()
try:
with open('/etc/dhcphosts.txt', 'r') as hostsFile:
allHosts = hostsFile.readlines()
hostsFile.close()
except IOError:
allHosts = []
failedCheck = False
failureMessage = "Missing elements in dhcphosts.txt - \n"
COUNT = 0
for vM in vMs:
if vM["dhcp"] == "false":
continue
COUNT = COUNT + 1
entry = vM["macAddress"] + " " + vM["ip"] + " " + vM["vmName"]
foundEntry = False
for host in allHosts:
@ -60,7 +67,7 @@ def main():
print failureMessage[:-2]
exit(1)
else:
print "All " + str(len(vMs)) + " VMs are present in dhcphosts.txt"
print "All " + str(COUNT) + " VMs are present in dhcphosts.txt"
exit(0)

View File

@ -33,7 +33,11 @@ def main():
failedCheck = False
failureMessage = "Missing entries for VMs in /etc/hosts -\n"
COUNT = 0
for vM in vMs:
if vM["dns"] == "false":
continue
COUNT = COUNT + 1
foundEntry = False
for host in allHosts:
components = host.split('\t')
@ -50,7 +54,7 @@ def main():
print failureMessage[:-2]
exit(1)
else:
print "All " + str(len(vMs)) + " VMs are present in /etc/hosts"
print "All " + str(COUNT) + " VMs are present in /etc/hosts"
exit(0)