<feature>[zwatch]: add OVN instance default alarms#3500
<feature>[zwatch]: add OVN instance default alarms#3500zstack-robot-1 wants to merge 1 commit into5.5.12from
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough在数据库升级脚本 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 庆祝诗
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 36-38: The three INSERTs into ActiveAlarmTemplateVO (rows with
UUIDs 'f1a6c2d85e7b8c9d3e4f5a6b7c8d9e0f', 'b3c8e4f07a9d0e1f5a6b7c8d9e0f1a2b',
'd5e0a6b29c1f2a3b7c8d9e0f1a2b3c4d' and alarmNames
OvnVmInstance-DiskAllUsedCapacityInPercent, OvnVmInstance-MemoryUsedInPercent,
OvnVmInstance-CPUAverageUsedUtilization) are not idempotent and will fail on
re-run; change them to be idempotent by either using INSERT IGNORE or converting
each to a conditional insert that checks existence (e.g., INSERT ... SELECT ...
WHERE NOT EXISTS (SELECT 1 FROM ActiveAlarmTemplateVO WHERE uuid = '<uuid>' OR
alarmName = '<alarmName>')) so repeated upgrades do not cause primary-key
conflicts; apply this pattern to all three INSERT statements.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: 25c52d43-a054-42cd-9457-afc7b31effa6
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
e64b2b0 to
767bb87
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 130-132: Prefix the table references in the three INSERT
statements to explicitly target the zstack schema: replace occurrences of
ActiveAlarmTemplateVO in the INSERT IGNORE INTO lines with
zstack.`ActiveAlarmTemplateVO` (so the INSERTs that insert templates like
'OvnVmInstance-DiskAllUsedCapacityInPercent',
'OvnVmInstance-MemoryUsedInPercent', and
'OvnVmInstance-CPUAverageUsedUtilization' run against the zstack schema
regardless of the current DB context); apply the same schema-qualified pattern
for any other unqualified table names in this upgrade script.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: fee3bbb8-09f7-4c4f-b760-ff0bad311860
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
| INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('f1a6c2d85e7b8c9d3e4f5a6b7c8d9e0f','OvnVmInstance-DiskAllUsedCapacityInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','DiskAllUsedCapacityInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); | ||
| INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('b3c8e4f07a9d0e1f5a6b7c8d9e0f1a2b','OvnVmInstance-MemoryUsedInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','MemoryUsedInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); | ||
| INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('d5e0a6b29c1f2a3b7c8d9e0f1a2b3c4d','OvnVmInstance-CPUAverageUsedUtilization','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','CPUAverageUsedUtilization',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); |
There was a problem hiding this comment.
建议在 Line 130-132 显式加上 zstack schema 前缀。
当前写法依赖默认库上下文;升级脚本里建议统一写成 zstack.ActiveAlarmTemplateVO,避免在非常规执行上下文下写入错误库。
💡 建议修改
-INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('f1a6c2d85e7b8c9d3e4f5a6b7c8d9e0f','OvnVmInstance-DiskAllUsedCapacityInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','DiskAllUsedCapacityInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);
-INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('b3c8e4f07a9d0e1f5a6b7c8d9e0f1a2b','OvnVmInstance-MemoryUsedInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','MemoryUsedInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);
-INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('d5e0a6b29c1f2a3b7c8d9e0f1a2b3c4d','OvnVmInstance-CPUAverageUsedUtilization','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','CPUAverageUsedUtilization',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);
+INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('f1a6c2d85e7b8c9d3e4f5a6b7c8d9e0f','OvnVmInstance-DiskAllUsedCapacityInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','DiskAllUsedCapacityInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);
+INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('b3c8e4f07a9d0e1f5a6b7c8d9e0f1a2b','OvnVmInstance-MemoryUsedInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','MemoryUsedInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);
+INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('d5e0a6b29c1f2a3b7c8d9e0f1a2b3c4d','OvnVmInstance-CPUAverageUsedUtilization','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','CPUAverageUsedUtilization',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);Based on learnings: "In ZStack, the database schema name is fixed as 'zstack'. For SQL upgrade scripts under conf/db/upgrade, continue using TABLE_SCHEMA = 'zstack' and reference tables as zstack.UsedIpVO."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@conf/db/upgrade/V5.5.12__schema.sql` around lines 130 - 132, Prefix the table
references in the three INSERT statements to explicitly target the zstack
schema: replace occurrences of ActiveAlarmTemplateVO in the INSERT IGNORE INTO
lines with zstack.`ActiveAlarmTemplateVO` (so the INSERTs that insert templates
like 'OvnVmInstance-DiskAllUsedCapacityInPercent',
'OvnVmInstance-MemoryUsedInPercent', and
'OvnVmInstance-CPUAverageUsedUtilization' run against the zstack schema
regardless of the current DB context); apply the same schema-qualified pattern
for any other unqualified table names in this upgrade script.
c3d5ae6 to
d7423b1
Compare
|
Comment from gitlab: 自上次添加REVIEWED标签(2026-03-17 19:40:57.000Z)后, 有新的COMMIT更新(2026-03-18 10:03:35.812Z), 所以移除了REVIEWED标签 |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
conf/db/upgrade/V5.5.12__schema.sql (1)
183-185:⚠️ Potential issue | 🟡 Minor请为插入目标表显式加上
zstackschema 前缀。当前写法依赖默认库上下文;在非常规执行环境中可能写入到错误 schema。建议改为
INSERT IGNORE INTO \zstack`.`ActiveAlarmTemplateVO``。💡 建议修复
-INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('f1a6c2d85e7b8c9d3e4f5a6b7c8d9e0f','OvnVmInstance-DiskAllUsedCapacityInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','DiskAllUsedCapacityInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); -INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('b3c8e4f07a9d0e1f5a6b7c8d9e0f1a2b','OvnVmInstance-MemoryUsedInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','MemoryUsedInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); -INSERT IGNORE INTO `ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('d5e0a6b29c1f2a3b7c8d9e0f1a2b3c4d','OvnVmInstance-CPUAverageUsedUtilization','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','CPUAverageUsedUtilization',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); +INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('f1a6c2d85e7b8c9d3e4f5a6b7c8d9e0f','OvnVmInstance-DiskAllUsedCapacityInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','DiskAllUsedCapacityInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); +INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('b3c8e4f07a9d0e1f5a6b7c8d9e0f1a2b','OvnVmInstance-MemoryUsedInPercent','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','MemoryUsedInPercent',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL); +INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO` (`uuid`,`alarmName`,`comparisonOperator`,`period`,`repeatInterval`,`namespace`,`metricName`,`threshold`,`lastOpDate`,`createDate`,`repeatCount`,`enableRecovery`,`emergencyLevel`,`labels`) VALUES ('d5e0a6b29c1f2a3b7c8d9e0f1a2b3c4d','OvnVmInstance-CPUAverageUsedUtilization','GreaterThanOrEqualTo',300,1800,'ZStack/OvnVmInstance','CPUAverageUsedUtilization',80,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),-1,0,'Important',NULL);Based on learnings: "In ZStack, the database schema name is fixed as 'zstack'. For SQL upgrade scripts under conf/db/upgrade, continue using TABLE_SCHEMA = 'zstack' and reference tables as zstack.
UsedIpVO."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@conf/db/upgrade/V5.5.12__schema.sql` around lines 183 - 185, The INSERT statements targeting ActiveAlarmTemplateVO rely on the current default schema; update each INSERT IGNORE INTO `ActiveAlarmTemplateVO` to explicitly reference the zstack schema (INSERT IGNORE INTO `zstack`.`ActiveAlarmTemplateVO`) so the three inserts (rows for alarmName values OvnVmInstance-DiskAllUsedCapacityInPercent, OvnVmInstance-MemoryUsedInPercent, OvnVmInstance-CPUAverageUsedUtilization) always write into the zstack schema regardless of execution context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 183-185: The INSERT statements targeting ActiveAlarmTemplateVO
rely on the current default schema; update each INSERT IGNORE INTO
`ActiveAlarmTemplateVO` to explicitly reference the zstack schema (INSERT IGNORE
INTO `zstack`.`ActiveAlarmTemplateVO`) so the three inserts (rows for alarmName
values OvnVmInstance-DiskAllUsedCapacityInPercent,
OvnVmInstance-MemoryUsedInPercent, OvnVmInstance-CPUAverageUsedUtilization)
always write into the zstack schema regardless of execution context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: 225a764d-596c-4162-b967-6ea113a0f91a
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
DBImpact Resolves: ZSTAC-73154 Change-Id: I7a6b69706374636e6d65716c6e7571657766636c Signed-off-by: zhangjianjun <jianjun.zhang@zstack.io>
|
Comment from gitlab: 自上次添加REVIEWED标签(2026-03-18 20:01:22.000Z)后, 有新的COMMIT更新(2026-03-19 19:56:58.950Z), 所以移除了REVIEWED标签 |
d7423b1 to
ec18635
Compare
DBImpact
Resolves: ZSTAC-73154
Change-Id: I7a6b69706374636e6d65716c6e7571657766636c
Signed-off-by: zhangjianjun jianjun.zhang@zstack.io
sync from gitlab !9359