From bd2c496265d86b227657f1907e4ef2e85638e125 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 20 Jun 2024 17:16:33 +0530 Subject: [PATCH] plugins/shutdown: fix triggerShutdown scheduling and response 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 b8f5fb57155d..da3bba54bdc3 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 @@ private void prepareForShutdown(boolean postTrigger) { 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