Skip to content

Commit 100c2f9

Browse files
sureshanapartidhslove
authored andcommitted
Shutdown MS maintenance jobs when finished (apache#11330)
1 parent b57b1e3 commit 100c2f9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,11 @@ private Answer migrateAgentToOtherMS(final MigrateAgentConnectionCommand cmd) {
965965
if (CollectionUtils.isNotEmpty(cmd.getMsList())) {
966966
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval(), false);
967967
}
968-
Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("MigrateAgentConnection-Job")).schedule(() -> {
968+
ScheduledExecutorService migrateAgentConnectionService = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("MigrateAgentConnection-Job"));
969+
migrateAgentConnectionService.schedule(() -> {
969970
migrateAgentConnection(cmd.getAvoidMsList());
970971
}, 3, TimeUnit.SECONDS);
972+
migrateAgentConnectionService.shutdown();
971973
} catch (Exception e) {
972974
String errMsg = "Migrate agent connection failed, due to " + e.getMessage();
973975
logger.debug(errMsg, e);

plugins/maintenance/src/main/java/org/apache/cloudstack/maintenance/ManagementServerMaintenanceManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ protected void runInContext() {
622622
ManagementServerHostVO msHost = msHostDao.findByMsid(ManagementServerNode.getManagementServerId());
623623
if (msHost == null) {
624624
logger.warn("Unable to find the management server, invalid node id");
625+
managementServerMaintenanceManager.cancelWaitForPendingJobs();
625626
return;
626627
}
627628
msHostDao.updateState(msHost.getId(), State.Maintenance);
@@ -658,6 +659,7 @@ protected void runInContext() {
658659
ManagementServerHostVO msHost = msHostDao.findByMsid(ManagementServerNode.getManagementServerId());
659660
if (msHost == null) {
660661
logger.warn("Unable to find the management server, invalid node id");
662+
managementServerMaintenanceManager.cancelWaitForPendingJobs();
661663
return;
662664
}
663665
if (totalAgents == 0) {
@@ -693,6 +695,7 @@ protected void runInContext() {
693695
ManagementServerHostVO msHost = msHostDao.findByMsid(ManagementServerNode.getManagementServerId());
694696
if (msHost == null) {
695697
logger.warn("Unable to find the management server, invalid node id");
698+
managementServerMaintenanceManager.cancelWaitForPendingJobs();
696699
return;
697700
}
698701
msHostDao.updateState(msHost.getId(), State.ReadyToShutDown);

0 commit comments

Comments
 (0)