From 097359bef9ed2f7448083deda734806326e88d4f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 21 Jun 2024 10:12:16 +0530 Subject: [PATCH] plugins/shutdown: fix triggerShutdown scheduling and response (#9276) Earlier the triggerShutdown API would immediately shutdown the MS and if it is the same MS on which API is called it would lead to error in the API call. This change adds a delay to the process so the MS would be able to send response to the API. Signed-off-by: Abhishek Kumar --- .../org/apache/cloudstack/shutdown/ShutdownManagerImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/shutdown/src/main/java/org/apache/cloudstack/shutdown/ShutdownManagerImpl.java b/plugins/shutdown/src/main/java/org/apache/cloudstack/shutdown/ShutdownManagerImpl.java index b8f5fb57155..da3bba54bdc 100644 --- a/plugins/shutdown/src/main/java/org/apache/cloudstack/shutdown/ShutdownManagerImpl.java +++ b/plugins/shutdown/src/main/java/org/apache/cloudstack/shutdown/ShutdownManagerImpl.java @@ -107,7 +107,10 @@ public class ShutdownManagerImpl extends ManagerBase implements ShutdownManager, this.shutdownTask = null; } this.shutdownTask = new ShutdownTask(this); - timer.scheduleAtFixedRate(shutdownTask, 0, 30L * 1000); + long period = 30L * 1000; + long delay = period / 2; + logger.debug(String.format("Scheduling shutdown task with delay: %d and period: %d", delay, period)); + timer.scheduleAtFixedRate(shutdownTask, delay, period); } @Override