From 6f7cc6717b6b1fc155928cdace784f11302ce803 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 30 Jul 2025 17:50:37 +0530 Subject: [PATCH 1/2] alert: fix type ID for alerts ALERT.VM.SNAPSHOT, ALERT.VR.PUBLIC.IFACE.MTU and ALERT.VR.PRIVATE.IFACE.MTU are all having type value 32. Signed-off-by: Abhishek Kumar --- .../main/java/org/apache/cloudstack/alert/AlertService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/alert/AlertService.java b/api/src/main/java/org/apache/cloudstack/alert/AlertService.java index 1250284b5c27..4ae6288efce4 100644 --- a/api/src/main/java/org/apache/cloudstack/alert/AlertService.java +++ b/api/src/main/java/org/apache/cloudstack/alert/AlertService.java @@ -71,8 +71,8 @@ private AlertType(short type, String name, boolean isDefault) { public static final AlertType ALERT_TYPE_HA_ACTION = new AlertType((short)30, "ALERT.HA.ACTION", true); public static final AlertType ALERT_TYPE_CA_CERT = new AlertType((short)31, "ALERT.CA.CERT", true); public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true); - public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true); - public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true); + public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)33, "ALERT.VR.PUBLIC.IFACE.MTU", true); + public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)34, "ALERT.VR.PRIVATE.IFACE.MTU", true); public short getType() { return type; From 6be21fb072dc347c7fe30227e9a2098a502b736f Mon Sep 17 00:00:00 2001 From: Suresh Kumar Anaparti Date: Tue, 27 Jan 2026 16:55:09 +0530 Subject: [PATCH 2/2] Added upgrade path for the alerts ALERT.VR.PUBLIC.IFACE.MTU, ALERT.VR.PRIVATE.IFACE.MTU --- .../src/main/java/com/cloud/alert/AlertManager.java | 1 - .../src/main/resources/META-INF/db/schema-42020to42030.sql | 3 +++ server/src/main/java/com/cloud/event/AlertGenerator.java | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java b/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java index 3d4e6579f7ca..7fe19c3ba9f8 100644 --- a/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java +++ b/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java @@ -54,5 +54,4 @@ public interface AlertManager extends Manager, AlertService { void recalculateCapacity(); void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String body); - } diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42020to42030.sql b/engine/schema/src/main/resources/META-INF/db/schema-42020to42030.sql index 598fdb7adc46..567e623564ea 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42020to42030.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42020to42030.sql @@ -20,3 +20,6 @@ --; ALTER TABLE `cloud`.`template_store_ref` MODIFY COLUMN `download_url` varchar(2048); + +UPDATE `cloud`.`alert` SET type = 33 WHERE name = 'ALERT.VR.PUBLIC.IFACE.MTU'; +UPDATE `cloud`.`alert` SET type = 34 WHERE name = 'ALERT.VR.PRIVATE.IFACE.MTU'; diff --git a/server/src/main/java/com/cloud/event/AlertGenerator.java b/server/src/main/java/com/cloud/event/AlertGenerator.java index f1b23e873082..601bf5e831a4 100644 --- a/server/src/main/java/com/cloud/event/AlertGenerator.java +++ b/server/src/main/java/com/cloud/event/AlertGenerator.java @@ -67,12 +67,13 @@ void init() { } public static void publishAlertOnEventBus(String alertType, long dataCenterId, Long podId, String subject, String body) { - String configKey = Config.PublishAlertEvent.key(); String value = s_configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); - if(!configValue) + if (!configValue) { return; + } + try { eventDistributor = ComponentContext.getComponent(EventDistributor.class); } catch (NoSuchBeanDefinitionException nbe) {