Skip to content

<fix>[zbs]: fix linked-clone parent volume residual#4166

Open
MatheMatrix wants to merge 1 commit into
5.5.28from
sync/jin.ma/fix/ZSTAC-85707
Open

<fix>[zbs]: fix linked-clone parent volume residual#4166
MatheMatrix wants to merge 1 commit into
5.5.28from
sync/jin.ma/fix/ZSTAC-85707

Conversation

@MatheMatrix
Copy link
Copy Markdown
Owner

Summary

【zbs主存储】删除链接克隆子卷后,链接克隆的父卷和快照残留。

Root cause

ZBS stats()/flatten() 把卷的 installPath 归一化成 zbs:// 路径,但 parentUri 原样存成 agent 返回的 cbd: 路径。快照引用 GC 沿 backing chain 回溯时把这个 cbd: 路径再喂回 controller.stats()prepareCmd() 二次执行 convertZbsPathToCbdPathgetPoolFromVolumePath 把物理池名误解析,backing chain 查询以 ORG_ZSTACK_STORAGE_ZBS_10026 失败并回滚,导致父卷与快照残留在存储上。

Changes

  • ZbsHelper.normalizeToZbsPath():仅对 cbd: 前缀路径转回 zbs://convertCbdPathToZbsPath 非幂等,带 guard)
  • ZbsStorageController stats()/flatten():设置 parentUri 时归一化,使 backing chain 全程只跑 zbs://
 ZbsHelper.java            |  4 +++
 ZbsStorageController.java |  4 +--
 ZbsPrimaryStorageCase.groovy | 41 +++++++++

Testing

  • 全量编译通过(AspectJ 织入)
  • ZbsPrimaryStorageCase 新增 testGetBackingChainNormalizesCbdParentUri,红绿验证:修复前以 ZBS_10026 失败、修复后通过(Tests run: 1, Failures: 0)
  • CI pipeline

影响版本:5.5.12 / 5.5.16 / 5.5.22 / 5.5.24 / 5.5.28(master 不受影响,ZBS 已重写)

Resolves: ZSTAC-85707

sync from gitlab !10071

stats() and flatten() returned parentUri as the agent cbd path while
installPath was a zbs:// path. The snapshot-reference GC walked the
backing chain and fed the cbd parentUri back into stats(); prepareCmd()
converted it a second time, getPoolFromVolumePath() mis-parsed the
physical pool, and the chain query failed with ZBS_10026, rolling back
the cleanup and leaving the parent volume and snapshot on storage.

Normalize parentUri to a zbs:// path so the backing chain walk stays
in one path namespace.

Resolves: ZSTAC-85707

Change-Id: I1c3dbe96086b681b83a4a627bdce37e76575564f
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c1dccd89-3521-44d2-96a1-1a2741e86a5f

📥 Commits

Reviewing files that changed from the base of the PR and between c25b97b and da8d3e8.

📒 Files selected for processing (3)
  • plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsHelper.java
  • plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsStorageController.java
  • test/src/test/groovy/org/zstack/test/integration/storage/primary/addon/zbs/ZbsPrimaryStorageCase.groovy

Walkthrough

此变更为 ZBS 存储添加了 CBD 路径规范化功能。新增 normalizeToZbsPath 工具方法将 cbd: 前缀路径转换为 zbs:// 格式。该方法在 ZbsStorageController 的两处卷统计回调中应用,规范化返回的 parentUri。新增集成测试验证此规范化在 backing chain 查询中正确执行。

Changes

CBD 路径规范化工具与应用

Layer / File(s) Summary
路径规范化工具方法
plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsHelper.java
新增 normalizeToZbsPath(String path) 静态方法,当输入路径以 cbd: 开头时通过 convertCbdPathToZbsPath 转换为 zbs:// 格式,否则原样返回。
存储控制器中的路径规范化应用
plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsStorageController.java
flattenVolumestats 两处成功回调中对返回的 VolumeStats.parentUri 应用 normalizeToZbsPath 进行规范化处理。
集成测试覆盖
test/src/test/groovy/org/zstack/test/integration/storage/primary/addon/zbs/ZbsPrimaryStorageCase.groovy
更新 import 语句以支持新测试;在 test() 执行列表中加入 testGetBackingChainNormalizesCbdParentUri() 调用;新增测试方法通过模拟 QUERY_VOLUME_PATH 返回 cbd: 形式 parentUri,验证 backing chain 获取时路径被正确规范化为 zbs://

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

兔兔欢呼路径归一化,
cbd: 摇身变 zbs://,
存储链路更整洁,
测试保驾测梦翔,
小改动,大保障呢~ 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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 PR标题清晰准确地描述了主要改动:修复ZBS链接克隆父卷残留问题,与代码变更内容完全相符。
Description check ✅ Passed PR描述详细完整,包括问题现象、根本原因分析、具体改动方案和测试验证,与代码变更高度相关。
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.

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

✨ 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/jin.ma/fix/ZSTAC-85707

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