From 6058905db763c9b141fcd844771e38f2feee6729 Mon Sep 17 00:00:00 2001 From: "yaohua.wu" Date: Fri, 26 Jun 2026 16:07:30 +0800 Subject: [PATCH] [zwatch]: clean alarm resource state label and prune stale ones The per-resource alarm state now stores a clean identify label and drops residual states when a metric series disappears. 1. Why is this change necessary? AlarmResourceState.identifyLabel stored the whole metric series key (e.g. ::CPUNum:19::::VMUuid:x::), so the alarm detail page showed the VMUuid that resourceUuid already carries. And when a series vanished while its resource stayed (e.g. a vCPU dropped after a cpu downsize), the state was only marked InsufficientData and lingered forever. 2. How does it address the problem? identifyLabel now persists the clean per-resource label (CPUNum:19); the resource identity stays in resourceUuid, so the row key becomes (alarmUuid, identifyLabel, resourceUuid) and its unique index follows (identifyLabel shrinks to 191 to keep the composite key within the CI MySQL limit). Rule rebuild reconstructs the full series key from the stored row, so the recovery pairing keeps matching the rule engine. A series missing this round whose resource still reports other series is deleted; a fully silent resource stays InsufficientData. 3. Are there any side effects? identifyLabel of existing rows changes shape; acceptable on this unreleased feature branch. No behavior change for silent resources. # Summary of changes (by module): - zwatch: store clean identifyLabel, (alarm,label,resourceUuid) row key, series-key reconstruction on rebuild, prune departed series - conf: AlarmResourceStateVO unique key + identifyLabel length Related: ZSTAC-85397 Related: SUG-2677 Change-Id: Ie8fa813292de89766f0733089a3610e09f88cfae --- conf/db/upgrade/V5.5.28__schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/db/upgrade/V5.5.28__schema.sql b/conf/db/upgrade/V5.5.28__schema.sql index 4f96610e446..18574920d6f 100644 --- a/conf/db/upgrade/V5.5.28__schema.sql +++ b/conf/db/upgrade/V5.5.28__schema.sql @@ -4,7 +4,7 @@ ALTER TABLE `zstack`.`AlarmVO` ADD COLUMN `recoveryThreshold` int unsigned DEFAU CREATE TABLE IF NOT EXISTS `zstack`.`AlarmResourceStateVO` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `alarmUuid` varchar(32) NOT NULL, - `identifyLabel` varchar(200) NOT NULL, + `identifyLabel` varchar(191) NOT NULL, `resourceUuid` varchar(32) DEFAULT NULL, `resourceType` varchar(256) DEFAULT NULL, `status` varchar(32) NOT NULL, @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS `zstack`.`AlarmResourceStateVO` ( `lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP, `createDate` timestamp, PRIMARY KEY (`id`), - UNIQUE KEY `ukAlarmUuidIdentifyLabel` (`alarmUuid`, `identifyLabel`), + UNIQUE KEY `ukAlarmUuidIdentifyLabel` (`alarmUuid`, `identifyLabel`, `resourceUuid`), KEY `idxAlarmResourceStateVOresourceUuid` (`resourceUuid`), CONSTRAINT `fkAlarmResourceStateVOAlarmVO` FOREIGN KEY (`alarmUuid`) REFERENCES `AlarmVO` (`uuid`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;