Skip to content

fix(sdnController): validate L2 network detach before SDN controller delete#3346

Open
ZStack-Robot wants to merge 1 commit into5.5.6from
sync/ye.zou/fix/ZSTAC-80186
Open

fix(sdnController): validate L2 network detach before SDN controller delete#3346
ZStack-Robot wants to merge 1 commit into5.5.6from
sync/ye.zou/fix/ZSTAC-80186

Conversation

@ZStack-Robot
Copy link
Collaborator

Problem

ZSTAC-80186: Deleting an SDN controller without first detaching its L2 vxlan network pools leaves orphaned L2 networks with broken SDN references.

Root Cause

APIRemoveSdnControllerMsg has no validation in the interceptor. The cascade extension handleDeletionCheck() also immediately returns success without checking for attached resources.

Fix

Add validation in SdnControllerApiInterceptor for APIRemoveSdnControllerMsg: check if any HardwareL2VxlanNetworkPoolVO still references this SDN controller UUID. If so, reject the delete with a clear error message asking to detach first.

Changes

  • SdnControllerApiInterceptor.java: Add validate method for APIRemoveSdnControllerMsg
  • CloudOperationsErrorCode.java: Add error code ORG_ZSTACK_SDNCONTROLLER_10031

Testing

  • Compile verified: BUILD SUCCESS

sync from gitlab !9175

…r delete

Resolves: ZSTAC-80186

Change-Id: I8dcb689b022ad907c12bc1b481fb9d0db1e98d06
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

概览

在SDN控制器API拦截器中添加了移除操作的验证逻辑,确保移除前检查是否存在关联的硬件L2 Vxlan网络池;同时在错误码常量库中增加对应的新错误码。

变更

内聚组 / 文件 摘要
SDN控制器移除验证
plugin/sdnController/src/main/java/org/zstack/sdnController/SdnControllerApiInterceptor.java
在API拦截器中新增validate(APIRemoveSdnControllerMsg msg)私有方法,用于验证要移除的SDN控制器是否存在关联的HardwareL2VxlanNetworkPoolVO池;若存在关联池则抛出异常并阻止移除操作。
错误码常量扩展
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
新增错误码常量ORG_ZSTACK_SDNCONTROLLER_10031,用于支持SDN控制器移除时的错误场景。

代码审查估计工作量

🎯 2 (简单) | ⏱️ ~10 分钟

庆祝诗

🐰 SDN控制器有了新卫士,
移除前需三思而行,
池塘未空不得离去,
错误码添新标记,
验证之路更加坚固!✨


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)
Check name Status Explanation Resolution
Title check ❌ Error PR标题超过72字符限制,共75字符;其他方面标题格式正确且准确概括了主要变更内容。 请将标题缩短至72字符以内,例如:'fix(sdnController): validate L2 network before SDN controller delete'
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
Description check ✅ Passed PR描述详细说明了问题、根本原因、修复方案和所做的变更,与代码改动完全相关。
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into 5.5.6
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/ye.zou/fix/ZSTAC-80186

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
plugin/sdnController/src/main/java/org/zstack/sdnController/SdnControllerApiInterceptor.java (1)

316-323: msg.getUuid() 进行 trim 后再查询/报错

拦截器新增校验直接使用了 msg.getUuid()。按项目规范,需要对来自 Message 的参数先 trim;否则带空格的 UUID 可能绕过 pool 关联校验。建议先 StringUtils.trimToNull,用 trim 后的值做查询与提示。

As per coding guidelines "注意检查来自 Message 的参数是否做过 trim,用户可能在浏览器上复制粘贴的数据带有空格、换行符等"

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.40.5)
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java

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

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