<fix>[sdk]: refactor HA network group validation#3770
<fix>[sdk]: refactor HA network group validation#3770zstack-robot-2 wants to merge 1 commit intofeature-5.5.6-dpu-net-ha2from
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 54 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml) Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
概览本次变更对HA网络组的数据库架构进行了调整。移除了 变更
估计代码审查工作量🎯 2 (Simple) | ⏱️ ~10 分钟 诗歌
🚥 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)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
conf/db/upgrade/V5.5.12__schema.sql (1)
1-24:⚠️ Potential issue | 🟡 Minor将 TIMESTAMP 默认值改为 CURRENT_TIMESTAMP
第 8、17、31 行的
lastOpDate和createDate列使用了DEFAULT '0000-00-00 00:00:00',违反编码指南规范。应改为DEFAULT CURRENT_TIMESTAMP。🤖 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 1 - 24, The TIMESTAMP columns use the invalid zero-date default; update the DEFAULT for lastOpDate and createDate in HaNetworkGroupVO and HaNetworkGroupL3NetworkRefVO: replace "DEFAULT '0000-00-00 00:00:00'" with "DEFAULT CURRENT_TIMESTAMP" and keep the ON UPDATE CURRENT_TIMESTAMP only on lastOpDate (i.e., HaNetworkGroupVO.lastOpDate and HaNetworkGroupL3NetworkRefVO.lastOpDate should have DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, while HaNetworkGroupVO.createDate and HaNetworkGroupL3NetworkRefVO.createDate should have DEFAULT CURRENT_TIMESTAMP without ON UPDATE).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 1-24: The TIMESTAMP columns use the invalid zero-date default;
update the DEFAULT for lastOpDate and createDate in HaNetworkGroupVO and
HaNetworkGroupL3NetworkRefVO: replace "DEFAULT '0000-00-00 00:00:00'" with
"DEFAULT CURRENT_TIMESTAMP" and keep the ON UPDATE CURRENT_TIMESTAMP only on
lastOpDate (i.e., HaNetworkGroupVO.lastOpDate and
HaNetworkGroupL3NetworkRefVO.lastOpDate should have DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP, while HaNetworkGroupVO.createDate and
HaNetworkGroupL3NetworkRefVO.createDate should have DEFAULT CURRENT_TIMESTAMP
without ON UPDATE).
ℹ️ 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: 74be4c8c-3ce6-4b3b-a34d-a46971c83f27
⛔ Files ignored due to path filters (2)
sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupAction.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/HaNetworkGroupInventory.javais excluded by!sdk/**
📒 Files selected for processing (2)
conf/db/upgrade/V5.5.12__schema.sqlutils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
af329bc to
7e7f9c0
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
conf/db/upgrade/V5.5.12__schema.sql (1)
21-48:⚠️ Potential issue | 🟠 Major将结构变更放在历史版本脚本中,可能导致已升级环境缺失本次变更。
这里的唯一索引调整和新表创建都写在
V5.5.12__schema.sql。对已经执行过该版本升级的数据库,这些变更通常不会再次生效,可能造成:
l3NetworkUuid唯一约束未落地;HaNetworkGroupGlobalConfigVersionVO与初始化记录缺失。建议将这些变更放到新的更高版本升级脚本,并在添加唯一约束前补充重复数据清理与幂等保护。
As per coding guidelines
**/*.sql: “Upgrading scene has been carefully handled”.🤖 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 21 - 48, The schema changes (unique index `ukHaNetworkGroupL3NetworkRefVOl3NetworkUuid`, tables `HostHaNetworkGroupStatusVO`, `HaNetworkGroupGlobalConfigVersionVO` and the INSERT for `'ha-network-group'`) must not live in the historical file `V5.5.12__schema.sql`; move them into a new higher-version migration script (e.g., V5.5.13+), make the unique-index addition idempotent by first deduplicating rows in the `HaNetworkGroupL3NetworkRefVO` source table and/or skipping index creation if it already exists, and ensure the `HaNetworkGroupGlobalConfigVersionVO` initialization uses an idempotent INSERT/UPDATE path so re-running the migration is safe; reference the constraints `fkHaNetworkGroupL3NetworkRefVOHaNetworkGroupVO` / `fkHaNetworkGroupL3NetworkRefVOL3NetworkEO` when verifying referential integrity during the migration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 21-48: The schema changes (unique index
`ukHaNetworkGroupL3NetworkRefVOl3NetworkUuid`, tables
`HostHaNetworkGroupStatusVO`, `HaNetworkGroupGlobalConfigVersionVO` and the
INSERT for `'ha-network-group'`) must not live in the historical file
`V5.5.12__schema.sql`; move them into a new higher-version migration script
(e.g., V5.5.13+), make the unique-index addition idempotent by first
deduplicating rows in the `HaNetworkGroupL3NetworkRefVO` source table and/or
skipping index creation if it already exists, and ensure the
`HaNetworkGroupGlobalConfigVersionVO` initialization uses an idempotent
INSERT/UPDATE path so re-running the migration is safe; reference the
constraints `fkHaNetworkGroupL3NetworkRefVOHaNetworkGroupVO` /
`fkHaNetworkGroupL3NetworkRefVOL3NetworkEO` when verifying referential integrity
during the migration.
ℹ️ 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: 8253e10d-fa79-4194-b648-4842872a0141
⛔ Files ignored due to path filters (2)
sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupAction.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/HaNetworkGroupInventory.javais excluded by!sdk/**
📒 Files selected for processing (2)
conf/db/upgrade/V5.5.12__schema.sqlutils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
✅ Files skipped from review due to trivial changes (1)
- utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
|
Comment from ye.zou: Code Review
结论: APPROVE ✅(条件性) |
DBImpact Resolves: ZSTAC-84164 Change-Id: I736967737a6963726b666776746b677a69717278
7e7f9c0 to
dac798d
Compare
DBImpact
Resolves: ZSTAC-84164
Change-Id: I736967737a6963726b666776746b677a69717278
sync from gitlab !9639