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

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

新增 HA 网络组相关数据库表、KVM 代理命令与路径常量、模拟器端点与配置字段;在 StartVmCmd 中加入 enableHa;扩展测试库大量监控/告警 API 辅助方法,并追加大量运维错误码常量。

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 字段(null 归一为 false);新增代理路径常量 /host/vm/updateEnableHa/live/host/vm/reconcileEnableHa/live。注意序列化与代理接口兼容性。
KVM 模拟器:控制器与配置
simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorController.java, simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorConfig.java
在模拟器控制器新增两个 POST 处理方法以接收并记录上述命令,并在配置类中新增对应命令列表字段以保存接收的命令序列。
测试辅助:监控/告警 API 封装
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
大量新增监控、告警、事件订阅与 SNS 平台(Endpoint/Topic/Template/Rule 等)相关的辅助方法,采用一致的请求封装与 ApiPath 跟踪样板,扩展测试库的 API 覆盖。
运维错误码扩展
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 Mgmt as ManagementNode
    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->>Mgmt: 调用 管理 API(如 创建/查询 HaNetworkGroup 或 StartVm 包含 enableHa)
    Mgmt->>DB: 写入/读取 HaNetworkGroup 与关联表
    Mgmt->>KVM: POST /host/vm/updateEnableHa/live (UpdateVmEnableHaLiveCmd)
    KVM-->>Mgmt: 返回 AgentResponse
    Mgmt->>KVM: POST /host/vm/reconcileEnableHa/live (ReconcileVmEnableHaOnHostCmd)
    KVM-->>Mgmt: 返回 AgentResponse
    Mgmt->>User: 返回 API 响应
Loading

Estimated code review effort

🎯 4 (复杂) | ⏱️ ~45 分钟

Poem

🐰 新表土里悄悄生,
代理小令轻声鸣,
模拟器里记命令,
错码星海静无声,
小兔跳跃盼上线 🥕

🚥 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 拉取请求描述与变更集相关,涉及高可用性网络组的数据库架构修改和API扩展。

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

✨ Finishing Touches
🧪 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

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

@MatheMatrix MatheMatrix force-pushed the sync/haoyu.ding/fv-81413@@3 branch 2 times, most recently from 4cb34c8 to 98aaeef Compare March 2, 2026 09:03
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 2272-2273: Add `@GrayVersion` to the two new command classes
(UpdateVmEnableHaLiveCmd and ReconcileVmEnableHaOnHostCmd) to match project
convention, change StartVmCmd.enableHa's `@GrayVersion` from "5.5.12" to the
correct initial rollout version (use "5.5.0" to align with project current
version), and make null handling consistent by updating
UpdateVmEnableHaLiveCmd.setEnableHa(...) to mirror StartVmCmd.setEnableHa(...)
(convert null to false via enableHa == null ? false : enableHa) so both setter
behaviors are identical.

ℹ️ 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 4cb34c8 and 98aaeef.

⛔ 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 (7)
  • 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
  • simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorConfig.java
  • simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorController.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 (1)
  • conf/db/upgrade/V5.5.12__schema.sql

Comment on lines +2272 to +2273
@GrayVersion(value = "5.5.12")
private Boolean enableHa = false;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== StartVmCmd enableHa block =="
rg -n "enableHa|@GrayVersion" plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java -C2

echo
echo "== 该文件中的 5.5.x GrayVersion 分布 =="
rg -n "@GrayVersion\(value = \"5\.5\.[0-9]+\"\)" plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java

echo
echo "== 仓库内 POM 版本线(抽样前10个)== "
fd pom.xml -x head -20 {} \; 2>/dev/null | grep -E "version|revision" | head -30 || true

Repository: MatheMatrix/zstack

Length of output: 48882


🏁 Script executed:

#!/bin/bash
# 检查目标分支信息和当前版本配置
echo "== 检查git分支信息 =="
git branch -a 2>/dev/null | grep -E "5\.[0-9]+\.[0-9]+" || echo "未找到版本相关分支"

echo
echo "== 检查启用HA相关的版本标注 =="
rg -n "enableHa|@GrayVersion" plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java -B1 -A1 | head -40

Repository: MatheMatrix/zstack

Length of output: 1696


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== UpdateVmEnableHaLiveCmd 完整定义 =="
rg -n "class UpdateVmEnableHaLiveCmd" plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java -A15

echo
echo "== ReconcileVmEnableHaOnHostCmd 完整定义 =="
rg -n "class ReconcileVmEnableHaOnHostCmd" plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java -A15

echo
echo "== 检查这些新增命令类是否被关联的消息类引用 =="
rg -r "UpdateVmEnableHaLiveCmd|ReconcileVmEnableHaOnHostCmd" . --type java | head -20

echo
echo "== 查看 StartVmCmd 的 getter/setter 完整实现 =="
rg -n "setEnableHa|getEnableHa" plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java -B1 -A3

Repository: MatheMatrix/zstack

Length of output: 30493


新增命令类缺少版本标注,且 enableHa 处理逻辑不一致。

  1. UpdateVmEnableHaLiveCmdReconcileVmEnableHaOnHostCmd 均缺少 @GrayVersion 注解。新增的命令类应遵循项目规范,明确标注其首次可用版本。

  2. StartVmCmd.enableHa 标注为 @GrayVersion("5.5.12"),但项目当前版本为 5.5.0,且同文件其他 5.5.x 特性标注为 5.5.0 或 5.5.6。版本号应与实际功能首次可用版本对齐,避免灰度阶段低版本 agent 接收不到该字段。

  3. UpdateVmEnableHaLiveCmd.setEnableHa() 无 null 处理,而 StartVmCmd.setEnableHa() 做了 enableHa == null ? false : enableHa 的转换。两者应保持一致的 null 处理策略,以确保灰度下的行为预期一致。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java` around lines
2272 - 2273, Add `@GrayVersion` to the two new command classes
(UpdateVmEnableHaLiveCmd and ReconcileVmEnableHaOnHostCmd) to match project
convention, change StartVmCmd.enableHa's `@GrayVersion` from "5.5.12" to the
correct initial rollout version (use "5.5.0" to align with project current
version), and make null handling consistent by updating
UpdateVmEnableHaLiveCmd.setEnableHa(...) to mirror StartVmCmd.setEnableHa(...)
(convert null to false via enableHa == null ? false : enableHa) so both setter
behaviors are identical.

@MatheMatrix MatheMatrix force-pushed the sync/haoyu.ding/fv-81413@@3 branch 2 times, most recently from 05389f8 to 92ed618 Compare March 2, 2026 11:05
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

♻️ Duplicate comments (1)
plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java (1)

1019-1041: ⚠️ Potential issue | 🟠 Major

@GrayVersion 版本号高于当前分支版本线,存在灰度下字段被过滤风险。

UpdateVmEnableHaLiveCmd.enableHaReconcileVmEnableHaOnHostCmd.neverStopVmUuidsStartVmCmd.enableHa 当前都标注为 5.5.12。在 feature-5.5.6-dpu-net-ha2 版本线下,这会导致新字段在混部/灰度时可能不下发到对应 agent,从而使 HA 开关与对账参数失效。

🔧 建议修复
-        `@GrayVersion`(value = "5.5.12")
+        `@GrayVersion`(value = "5.5.6")
         private Boolean enableHa = false;
...
-        `@GrayVersion`(value = "5.5.12")
+        `@GrayVersion`(value = "5.5.6")
         private List<String> neverStopVmUuids;
...
-        `@GrayVersion`(value = "5.5.12")
+        `@GrayVersion`(value = "5.5.6")
         private Boolean enableHa = false;

As per coding guidelines "向后兼容原则:之前的代码产生的行为不要直接去改动... 实在需要改动已有行为,应当对原状态做好记录,做好二次确认,做好回退准备,这个非常重要"。

Also applies to: 2274-2275

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java` around lines
1019 - 1041, The `@GrayVersion` on new fields is higher than the branch line
causing fields like UpdateVmEnableHaLiveCmd.enableHa,
ReconcileVmEnableHaOnHostCmd.neverStopVmUuids and StartVmCmd.enableHa to be
filtered out during mixed-version/gray deployments; fix by aligning the
annotation to the branch-compatible version (or removing the `@GrayVersion`) so
the fields are present for this branch (e.g. change "5.5.12" to the current
branch baseline such as "5.5.6" or drop the annotation) and ensure
setters/getters remain unchanged to preserve backward compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorController.java`:
- Around line 708-724: The handlers updateVmEnableHaLive and
reconcileVmEnableHaOnHost currently call
config.updateVmEnableHaLiveCmds.add(cmd) and
config.reconcileVmEnableHaOnHostCmds.add(cmd) on plain ArrayLists without
synchronization; make these writes thread-safe by either replacing those lists
with a thread-safe collection (e.g., Collections.synchronizedList or
CopyOnWriteArrayList) or synchronizing around the add (e.g.,
synchronized(config.updateVmEnableHaLiveCmds){...}), and apply the same
protection for config.reconcileVmEnableHaOnHostCmds so concurrent HTTP requests
cannot cause races.

---

Duplicate comments:
In `@plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java`:
- Around line 1019-1041: The `@GrayVersion` on new fields is higher than the
branch line causing fields like UpdateVmEnableHaLiveCmd.enableHa,
ReconcileVmEnableHaOnHostCmd.neverStopVmUuids and StartVmCmd.enableHa to be
filtered out during mixed-version/gray deployments; fix by aligning the
annotation to the branch-compatible version (or removing the `@GrayVersion`) so
the fields are present for this branch (e.g. change "5.5.12" to the current
branch baseline such as "5.5.6" or drop the annotation) and ensure
setters/getters remain unchanged to preserve backward compatibility.

ℹ️ 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 05389f8 and 92ed618.

⛔ 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 (7)
  • 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
  • simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorConfig.java
  • simulator/simulatorImpl/src/main/java/org/zstack/simulator/kvm/KVMSimulatorController.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 (1)
  • conf/db/upgrade/V5.5.12__schema.sql

@MatheMatrix MatheMatrix force-pushed the sync/haoyu.ding/fv-81413@@3 branch 4 times, most recently from d5f2e45 to aa3fc92 Compare March 3, 2026 10:39
@MatheMatrix
Copy link
Owner

Comment from yaohua.wu:

Review: MR !9250 — ZSTAC-81413

Feature: Network group high availability strategy (DPU 多业务网络 HA 精细化控制)
Target branch: feature-5.5.6-dpu-net-ha2


🔴 Critical

1. @GrayVersion("5.5.12") 与目标分支版本线不符,灰度场景下新字段将被过滤

本 MR 目标分支为 feature-5.5.6-dpu-net-ha2(版本线 5.5.6),但以下三处新增字段均标注了 @GrayVersion(value = "5.5.12")

  • UpdateVmEnableHaLiveCmd.enableHa(KVMAgentCommands.java:1019)
  • ReconcileVmEnableHaOnHostCmd.neverStopVmUuids(KVMAgentCommands.java:1040)
  • StartVmCmd.enableHa(KVMAgentCommands.java:2274)

GrayVersion 语义是「此字段只在 agent 版本 >= 标注版本时才下发」。5.5.12 高于当前版本线 5.5.6,意味着在混部/灰度升级期间,管理端可能运行 5.5.6 而 agent 尚未升级到 5.5.12,导致这三个字段不会被下发到 agent,HA 控制逻辑静默失效。

同文件中同期引入的 5.5.6 版本特性使用的是 @GrayVersion(value = "5.5.6")(见 KVMAgentCommands.java:2972/2974),应与之保持一致。

建议修复:将上述三处 "5.5.12" 改为 "5.5.6"


🟡 Warning

2. UpdateVmEnableHaLiveCmd.vmUuid 缺少 @GrayVersion 注解,与项目规范不一致

vmUuid 字段(KVMAgentCommands.java:1018)未标注 @GrayVersion,而同类命令(如 ChangeVmNicStateCommandCheckVmStateCmd 等)的所有字段都有 @GrayVersion 注解。这会导致 GrayUpgradeAgent 过滤逻辑无法感知该字段的版本信息。

建议:为 vmUuid 添加 @GrayVersion(value = "5.5.6")

3. HostHaNetworkGroupStatusVO 表缺少 (hostUuid, networkGroupUuid) 联合唯一约束

V5.5.12__schema.sqlHostHaNetworkGroupStatusVO 表的 hostUuidnetworkGroupUuid 有各自的单列索引,但没有联合唯一约束:

-- 当前:仅有两个单列索引
INDEX `idxHostHaNetworkGroupStatusVOhostUuid` (`hostUuid`),
INDEX `idxHostHaNetworkGroupStatusVOnetworkGroupUuid` (`networkGroupUuid`),

从语义上看,一个 host 对一个 networkGroup 应该只有一条状态记录。如果缺少联合唯一约束,并发场景下可能产生重复记录,导致查询结果不确定。

建议:添加 UNIQUE INDEXCONSTRAINT 保证 (hostUuid, networkGroupUuid) 组合唯一。

4. KVMSimulatorConfig 新增的三个 List 未用 volatile 修饰,与现有字段风格不一致

// 新增(无 volatile):
public List<UpdateVmEnableHaLiveCmd> updateVmEnableHaLiveCmds = new ArrayList<>();
public List<ReconcileVmEnableHaOnHostCmd> reconcileVmEnableHaOnHostCmds = new ArrayList<>();
public List<String> syncHaNetworkGroupConfigCmds = new ArrayList<>();

// 现有同类字段(有 volatile):
public volatile List<StopVmCmd> stopVmCmds = new ArrayList<>();
public volatile List<RebootVmCmd> rebootVmCmds = new ArrayList<>();

KVMSimulatorController 中的写操作已经用 synchronized 块保护,但测试用例通常在不同线程中读这些 List。volatile 保证读线程能看到引用本身的最新值(尽管对于 synchronized 内部的 add 操作,可见性由 monitor 保证)。为保持一致性并避免潜在的内存可见性问题,建议加上 volatile


🟢 Suggestion

5. ReconcileVmEnableHaOnHostCmd 缺少主键字段

该命令只有 neverStopVmUuids(KVMAgentCommands.java:1041),没有 hostUuid 或其他标识字段。agent 侧收到该命令时无法知道是针对哪个 host 的对账请求(agent 运行在 host 上,可以隐式确定,但缺少显式字段会增加调试难度)。可考虑是否需要补充 hostUuid 字段。

6. CloudOperationsErrorCode 新增的 16 个错误码(10019–10034)无注释说明

CloudOperationsErrorCode.java 中新增了 16 个 ORG_ZSTACK_HA_10019ORG_ZSTACK_HA_10034 的常量,但没有任何注释说明每个错误码的用途。建议至少用行内注释标明各错误码对应的场景,便于后续排查和维护。

7. KVMSimulator.groovy 注册的三个 handler 没有 volatile 开关控制

现有的大多数 simulator handler 都有对应的 config.xxxSuccess 开关(如 startVmSuccessstopVmSuccess),可以在测试中模拟失败场景。新增的三个 handler(UPDATE_VM_ENABLE_HA_LIVE_PATHRECONCILE_VM_ENABLE_HA_LIVE_PATHHA_NETWORK_GROUP_SYNC_PATH)目前固定返回成功,无法注入失败。如果后续需要测试 HA 异常路径,建议预先添加失败控制开关。


Verdict: REVISION_REQUIRED

主要阻塞点:Critical #1@GrayVersion 版本号与目标分支不符)会导致灰度部署场景下 HA 功能静默失效,需修复后再合入。


🤖 Robot Reviewer

@MatheMatrix MatheMatrix force-pushed the sync/haoyu.ding/fv-81413@@3 branch from aa3fc92 to acafa83 Compare March 4, 2026 07:21
DBImpact

Resolves: ZSTAC-81413

Change-Id: I6a7574656467636e686377756f716d67707a7063
@MatheMatrix MatheMatrix force-pushed the sync/haoyu.ding/fv-81413@@3 branch from acafa83 to 57f9210 Compare March 4, 2026 10:50
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.

3 participants