Skip to content

<feature>[utils]: Network group high availability strategy#3402

Open
zstack-robot-2 wants to merge 1 commit intofeature-5.5.6-dpu-net-ha2from
sync/haoyu.ding/fv-81413@@3
Open

<feature>[utils]: Network group high availability strategy#3402
zstack-robot-2 wants to merge 1 commit intofeature-5.5.6-dpu-net-ha2from
sync/haoyu.ding/fv-81413@@3

Conversation

@zstack-robot-2
Copy link
Collaborator

DBImpact

Resolves: ZSTAC-81413

Change-Id: I6a7574656467636e686377756f716d67707a7063

sync from gitlab !9250

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f0e113 and 4cb34c8.

⛔ Files ignored due to path filters (12)
  • sdk/src/main/java/SourceClassMap.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/ChangeHaNetworkGroupStateAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/ChangeHaNetworkGroupStateResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/DeleteHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/DeleteHaNetworkGroupResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/HaNetworkGroupInventory.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/QueryHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/QueryHaNetworkGroupResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/UpdateHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/UpdateHaNetworkGroupResult.java is excluded by !sdk/**
📒 Files selected for processing (5)
  • conf/db/upgrade/V5.5.12__schema.sql
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMConstant.java
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
  • utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMConstant.java
  • conf/db/upgrade/V5.5.12__schema.sql

Walkthrough

新增 HA 网络组相关数据库表、KVM 代理命令与路径常量、测试库 API 辅助方法及大量运维错误码常量;在 StartVmCmd 中增加 enableHa 字段以支持 VM 的 HA 启用状态传递。

Changes

Cohort / File(s) Summary
数据库迁移:HA 网络组
conf/db/upgrade/V5.5.12__schema.sql
新增三张表:HaNetworkGroupVOHaNetworkGroupL3NetworkRefVOHostHaNetworkGroupStatusVO,含主键、外键(带 ON DELETE CASCADE)、索引与默认值(ENGINE=InnoDB, CHARSET=utf8)。注意外键约束和时间戳默认值。
KVM 代理命令与常量
plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java, plugin/kvm/src/main/java/org/zstack/kvm/KVMConstant.java
新增命令类 UpdateVmEnableHaLiveCmdReconcileVmEnableHaOnHostCmd,在 StartVmCmd 中加入 enableHa 字段及其 getter/setter;新增两条代理路径常量:/host/vm/updateEnableHa/live/host/vm/reconcileEnableHa/live。注意序列化结构变化与 API 路径一致性。
测试辅助与 API 路径追踪
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
增加多个 API 辅助方法并新增 updateHaNetworkGroup()(遵循现有请求封装与可选 apipath 路径追踪模式)。注意测试调用的 session/id 及 apipath 行为。
运维错误码扩展
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
大量新增 public static final String 错误码常量(包括 HA、网络、存储等类别)。仅为常量声明扩展,无行为改动。

Sequence Diagram(s)

sequenceDiagram
    rect rgba(200,220,255,0.5)
    participant User
    end
    rect rgba(200,255,200,0.5)
    participant MgmtNode as ManagementNode(API / ApiHelper)
    end
    rect rgba(255,220,200,0.5)
    participant DB as Database
    end
    rect rgba(255,200,220,0.5)
    participant KVM as KVMAgent
    end

    User->>MgmtNode: 调用 updateHaNetworkGroup / 更新 VM HA
    MgmtNode->>DB: 写入/读取 HaNetworkGroup 与关联表
    MgmtNode->>KVM: POST /host/vm/updateEnableHa/live (UpdateVmEnableHaLiveCmd)
    KVM->>MgmtNode: 返回执行结果
    MgmtNode->>KVM: POST /host/vm/reconcileEnableHa/live (ReconcileVmEnableHaOnHostCmd)
    KVM->>MgmtNode: 返回 reconcile 结果
    MgmtNode->>User: 返回 API 响应
Loading

预估代码审查工作量

🎯 3 (中等) | ⏱️ ~22 分钟

诗歌

🐰 地下新表排队成行,
HA 组名声渐响亮,
代理路径悄开新门,
测试与码表都补上,
小兔一跳庆良忙 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 标题遵循了[scope]: 格式,长度为58字符,符合72字符限制,清晰描述了高可用性网络组功能。
Description check ✅ Passed 描述与变更集相关,提及了JIRA问题ZSTAC-81413和gitlab同步,与新增的高可用性功能相符。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/haoyu.ding/fv-81413@@3

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.41.0)
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java`:
- Around line 2273-2275: The `@GrayVersion` on StartVmCmd.enableHa is set too low
(5.0.0) and risks being sent to older agents; update the annotation to the
actual version this field was introduced in for this branch (use the
branch/release version constant or the correct semantic version), and apply the
same correction to the other occurrences referenced (the similar field block
around the 2752-2758 range). Locate the StartVmCmd.enableHa field and any
duplicate fields annotated with `@GrayVersion` and replace the version string with
the correct introduced-version value so grayscaling won't dispatch the new field
to incompatible older agents.

ℹ️ Review info

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf48ab8 and 8f0e113.

⛔ Files ignored due to path filters (12)
  • sdk/src/main/java/SourceClassMap.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/ChangeHaNetworkGroupStateAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/ChangeHaNetworkGroupStateResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/DeleteHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/DeleteHaNetworkGroupResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/HaNetworkGroupInventory.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/QueryHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/QueryHaNetworkGroupResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/UpdateHaNetworkGroupAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/UpdateHaNetworkGroupResult.java is excluded by !sdk/**
📒 Files selected for processing (5)
  • conf/db/upgrade/V5.5.12__schema.sql
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMConstant.java
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
  • utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java

DBImpact

Resolves: ZSTAC-81413

Change-Id: I6a7574656467636e686377756f716d67707a7063
@MatheMatrix MatheMatrix force-pushed the sync/haoyu.ding/fv-81413@@3 branch from 8f0e113 to 4cb34c8 Compare February 28, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants