Skip to content

<fix>[sdnController]: route creation to owner MN#4536

Open
zstack-robot-2 wants to merge 1 commit into
5.4.12from
sync/dejing.liu/codex/ZSTAC-86415-5.4.12@@2
Open

<fix>[sdnController]: route creation to owner MN#4536
zstack-robot-2 wants to merge 1 commit into
5.4.12from
sync/dejing.liu/codex/ZSTAC-86415-5.4.12@@2

Conversation

@zstack-robot-2

Copy link
Copy Markdown
Collaborator

Summary

Backport ZSTAC-86415 to 5.4.12 so SDN controller creation is routed to the management node selected by controller UUID, avoiding OVN initialization on the wrong MN.

Changes

  • Add internal AddSdnControllerMsg and AddSdnControllerReply messages.
  • Carry the controller VO, account UUID, and system tags across the CloudBus request.
  • Route controller creation by controller UUID and publish the API event from the callback.
  • Adapt the SDN controller interface and built-in H3C/Sugon implementations to the internal message.
  • Mark the persisted SDN controller password with @NoLogging.
  • No database schema migration.

Source

  • Jira: ZSTAC-86415 / ZSTAC-73622
  • Source MR: zstack !9028
  • Source commit: 6f33d216223c9c007413c442e88e3c9627b98c60
  • 5.4.12 backport: e52151511af16b7123a274aced48970fb18aa009

Testing

  • Stable patch-id matches the verified 5.4.10 backport.
  • git diff --check origin/5.4.12...HEAD
  • Maven build: header, sdnController, and sugonSdnController
  • Live HA: create from MN1 and handle AddSdnControllerMsg on MN2
  • OVN controller reached Connected; delete succeeded; both MN queries returned empty
  • No target-flow NullPointerException, NoSuchMethodError, or AbstractMethodError

Resolves: ZSTAC-86415

sync from gitlab !10498

DBImpact

Resolves: ZSTAC-73622
JIRA: ZSTAC-86415

Change-Id: I667461766363677373636a6e626f70766e736f6f
(cherry picked from commit 6f33d21)
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Could not fetch remote config from http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml: TimeoutError: The operation was aborted due to timeout
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

本次变更新增 SDN Controller 内部添加消息与回复类型,将控制器创建流程改为 CloudBus 异步处理,并同步更新 H3C、H3C V2、Sugon 实现;同时禁止记录控制器密码字段。

Changes

SDN Controller 创建流程

Layer / File(s) Summary
消息契约与敏感字段
header/.../SdnControllerVO.java, plugin/sdnController/.../SdnController.java, plugin/sdnController/.../header/*
新增 AddSdnControllerMsgAddSdnControllerReply,统一初始化接口参数类型,并为密码字段添加 @NoLogging
控制器创建异步流程
plugin/sdnController/.../SdnControllerManagerImpl.java
管理器接收内部添加消息,通过 CloudBus 执行控制器创建流程,并在回调中返回 inventory 或错误。
控制器实现适配
plugin/sdnController/.../h3cVcfc/*, plugin/sugonSdnController/.../SugonSdnController.java
H3C、H3C V2 和 Sugon 实现切换为 AddSdnControllerMsg,Sugon 从 SdnControllerVO 获取连接 IP。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant API as APIAddSdnControllerMsg
  participant Manager as SdnControllerManagerImpl
  participant Bus as CloudBus
  participant Controller as SDN Controller
  participant DB as SdnControllerDB

  API->>Manager: 提交创建请求
  Manager->>Bus: 发送 AddSdnControllerMsg
  Bus->>Controller: 路由内部消息
  Controller-->>Manager: 返回创建结果
  Manager->>DB: 查询 SdnControllerVO
  Manager-->>API: 返回 inventory 或错误
Loading

Poem

我是兔子蹦蹦跳,
消息换装走云桥。
控制器排队来报到,
密码藏好不喧闹。
回调带着 inventory,
耳朵一摇流程好!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题简洁且准确概括了将创建流程路由到目标管理节点这一核心变更。
Description check ✅ Passed 描述与本次回迁内容一致,准确说明了内部消息、路由和密码日志保护等变更。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/dejing.liu/codex/ZSTAC-86415-5.4.12@@2

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
plugin/sdnController/src/main/java/org/zstack/sdnController/header/AddSdnControllerReply.java (1)

6-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

inventory 字段定义后从未被填充,属于契约与实现不一致。

SdnControllerManagerImpl.handle(AddSdnControllerMsg) 的成功/失败回调均未调用 reply.setInventory(...),而 handle(APIAddSdnControllerMsg)CloudBusCallBack 收到回复后又重新查库构造 inventory。建议在 doCreateSdnController 成功时填充 reply.setInventory(SdnControllerInventory.valueOf(vo)),并在回调中直接使用 reply.getInventory(),避免冗余查询,也让该字段名副其实。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@plugin/sdnController/src/main/java/org/zstack/sdnController/header/AddSdnControllerReply.java`
around lines 6 - 16, 在 SdnControllerManagerImpl 的 doCreateSdnController 成功流程中调用
reply.setInventory(SdnControllerInventory.valueOf(vo)) 填充
AddSdnControllerReply.inventory;同时修改 handle(APIAddSdnControllerMsg) 的
CloudBusCallBack,直接使用 reply.getInventory(),移除成功后的重复查库和 inventory 构造逻辑。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@plugin/sdnController/src/main/java/org/zstack/sdnController/header/AddSdnControllerMsg.java`:
- Around line 1-31: 在 AddSdnControllerMsg 中新增 systemTags 字段,并默认初始化为空列表;补充
getSystemTags 和 setSystemTags 访问器,确保下游调用及遍历时不会出现缺失方法或空值。

---

Nitpick comments:
In
`@plugin/sdnController/src/main/java/org/zstack/sdnController/header/AddSdnControllerReply.java`:
- Around line 6-16: 在 SdnControllerManagerImpl 的 doCreateSdnController 成功流程中调用
reply.setInventory(SdnControllerInventory.valueOf(vo)) 填充
AddSdnControllerReply.inventory;同时修改 handle(APIAddSdnControllerMsg) 的
CloudBusCallBack,直接使用 reply.getInventory(),移除成功后的重复查库和 inventory 构造逻辑。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 04ebdfd2-04e3-45df-be95-36f4ff95a847

📥 Commits

Reviewing files that changed from the base of the PR and between e1a38d3 and e521515.

📒 Files selected for processing (8)
  • header/src/main/java/org/zstack/header/network/sdncontroller/SdnControllerVO.java
  • plugin/sdnController/src/main/java/org/zstack/sdnController/SdnController.java
  • plugin/sdnController/src/main/java/org/zstack/sdnController/SdnControllerManagerImpl.java
  • plugin/sdnController/src/main/java/org/zstack/sdnController/h3cVcfc/H3cVcfcSdnController.java
  • plugin/sdnController/src/main/java/org/zstack/sdnController/h3cVcfc/H3cVcfcV2SdnController.java
  • plugin/sdnController/src/main/java/org/zstack/sdnController/header/AddSdnControllerMsg.java
  • plugin/sdnController/src/main/java/org/zstack/sdnController/header/AddSdnControllerReply.java
  • plugin/sugonSdnController/src/main/java/org/zstack/sugonSdnController/controller/SugonSdnController.java

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