Skip to content

Commit c8be834

Browse files
committed
VPC: check only ssh services if VPC VR does not have any guest network
1 parent 7715b3d commit c8be834

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

core/src/main/java/com/cloud/agent/api/routing/SetMonitorServiceCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class SetMonitorServiceCommand extends NetworkElementCommand {
3737
public static final String ROUTER_HEALTH_CHECKS_BASIC_INTERVAL = "router.health.checks.basic.interval";
3838
public static final String ROUTER_HEALTH_CHECKS_ADVANCED_INTERVAL = "router.health.checks.advanced.interval";
3939
public static final String ROUTER_HEALTH_CHECKS_EXCLUDED = "router.health.checks.excluded";
40+
public static final String ROUTER_HEALTH_CHECKS_INCLUDED_SERVICES = "router.health.checks.included.services";
4041

4142
private MonitorServiceTO[] services;
4243
private Map<String, String> healthChecksConfig;

core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetMonitorServiceConfigItem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private void setupHealthChecksRelatedInfo(MonitorService monitorService, SetMoni
7070
}
7171

7272
monitorService.setExcludedHealthChecks(command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED));
73+
monitorService.setIncludedServices(command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_INCLUDED_SERVICES));
7374
monitorService.setHealthChecksConfig(command.getHealthChecksConfig());
7475
}
7576

core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/MonitorService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class MonitorService extends ConfigBase {
2727
public Integer healthChecksBasicRunInterval;
2828
public Integer healthChecksAdvancedRunInterval;
2929
public String excludedHealthChecks;
30+
public String includedServices;
3031
public Map<String, String> healthChecksConfig;
3132

3233
public MonitorService() {
@@ -92,6 +93,10 @@ public void setExcludedHealthChecks(String excludedHealthChecks) {
9293
this.excludedHealthChecks = excludedHealthChecks;
9394
}
9495

96+
public void setIncludedServices(String includedServices) {
97+
this.includedServices = includedServices;
98+
}
99+
95100
public void setHealthChecksConfig(Map<String, String> healthChecksConfig) {
96101
this.healthChecksConfig = healthChecksConfig;
97102
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import org.apache.cloudstack.utils.CloudStackVersion;
7171
import org.apache.cloudstack.utils.identity.ManagementServerNode;
7272
import org.apache.cloudstack.utils.usage.UsageUtils;
73+
import org.apache.commons.collections.CollectionUtils;
7374
import org.apache.commons.lang3.ObjectUtils;
7475
import org.apache.commons.lang3.StringUtils;
7576
import org.apache.log4j.Logger;
@@ -1595,17 +1596,22 @@ private SetMonitorServiceCommand createMonitorServiceCommand(DomainRouterVO rout
15951596
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_ENABLED, RouterHealthChecksEnabled.value().toString());
15961597
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_BASIC_INTERVAL, RouterHealthChecksBasicInterval.value().toString());
15971598
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_ADVANCED_INTERVAL, RouterHealthChecksAdvancedInterval.value().toString());
1599+
1600+
final List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
15981601
String excludedTests = RouterHealthChecksToExclude.valueIn(router.getDataCenterId());
15991602
if (router.getIsRedundantRouter()) {
16001603
// Disable gateway check if VPC has no tiers or no active VM's in it
1601-
final List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
16021604
if (RedundantState.BACKUP.equals(router.getRedundantState()) ||
16031605
routerGuestNtwkIds == null || routerGuestNtwkIds.isEmpty()) {
16041606
excludedTests = excludedTests.isEmpty() ? BACKUP_ROUTER_EXCLUDED_TESTS : excludedTests + "," + BACKUP_ROUTER_EXCLUDED_TESTS;
16051607
}
16061608
}
16071609

16081610
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, excludedTests);
1611+
if (router.getVpcId() != null && CollectionUtils.isEmpty(routerGuestNtwkIds)) {
1612+
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_INCLUDED_SERVICES, MonitoringService.Service.Ssh.toString().toLowerCase());
1613+
}
1614+
16091615
command.setHealthChecksConfig(routerHealthCheckConfig);
16101616
command.setReconfigureAfterUpdate(reconfigure);
16111617
command.setDeleteFromProcessedCache(deleteFromProcessedCache); // As part of updating

systemvm/debian/opt/cloud/bin/cs/CsMonitor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ def setupHealthChecksConfigFile(self):
6969
else:
7070
hc_data["excluded_health_checks"] = []
7171

72+
if "included_services" in self.dbag:
73+
included_services = self.dbag["included_services"]
74+
hc_data["included_services"] = [ch.strip() for ch in included_services.split(",")] if len(included_services) > 0 else []
75+
else:
76+
hc_data["included_services"] = []
77+
7278
if "health_checks_config" in self.dbag:
7379
hc_data["health_checks_config"] = self.dbag["health_checks_config"]
7480
else:

systemvm/debian/opt/cloud/bin/cs_monitorservice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ def merge(dbag, data):
3333
if "health_checks_config" in data:
3434
dbag["health_checks_config"] = data["health_checks_config"]
3535

36+
if "included_services" in data:
37+
dbag["included_services"] = data["included_services"]
38+
else:
39+
dbag["included_services"] = ""
40+
3641
return dbag

systemvm/debian/root/monitorServices.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def checkProcessStatus( process ):
247247
return StatusCodes.RUNNING, True
248248

249249

250-
def monitProcess( processes_info ):
250+
def monitProcess( processes_info, included_services ):
251251
"""
252252
Monitors the processes which got from the config file
253253
"""
@@ -263,7 +263,10 @@ def monitProcess( processes_info ):
263263
#time for noting process down time
264264
csec = repr(time.time()).split('.')[0]
265265

266-
for process,properties in processes_info.items():
266+
for process,properties in list(processes_info.items()):
267+
if included_services and len(included_services) > 0 and process not in included_services:
268+
printd ("---------------------------\nskipping the service %s\n---------------------------- " %process)
269+
continue
267270
printd ("---------------------------\nchecking the service %s\n---------------------------- " %process)
268271
serviceName = process + ".service"
269272
processStatus, wasRestarted = checkProcessStatus(properties)
@@ -325,20 +328,20 @@ def main(checkType = "basic"):
325328
'''
326329
printd("monitoring started")
327330
configDict = getServicesConfig()
331+
hc_data = getHealthChecksData()
328332

329333
'''
330334
Step2: Monitor services and Raise Alerts
331335
'''
332336
monitResult = {}
333337
failingChecks = []
334338
if checkType == "basic":
335-
monitResult, failingChecks = monitProcess(configDict)
339+
included_services = hc_data["included_services"] if "included_services" in hc_data else []
340+
monitResult, failingChecks = monitProcess(configDict, included_services)
336341

337342
'''
338343
Step3: Run health check scripts as needed
339344
'''
340-
hc_data = getHealthChecksData()
341-
342345
if hc_data is not None and "health_checks_enabled" in hc_data and hc_data['health_checks_enabled']:
343346
hc_exclude = hc_data["excluded_health_checks"] if "excluded_health_checks" in hc_data else []
344347
for f in os.listdir(Config.HEALTH_CHECKS_DIR):

0 commit comments

Comments
 (0)