<fix>[zbs]: fix linked-clone parent volume residual#4166
Conversation
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
|
Warning
|
| 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 |
在 flattenVolume 和 stats 两处成功回调中对返回的 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 | 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.
Summary
【zbs主存储】删除链接克隆子卷后,链接克隆的父卷和快照残留。
Root cause
ZBS
stats()/flatten()把卷的installPath归一化成zbs://路径,但parentUri原样存成 agent 返回的cbd:路径。快照引用 GC 沿 backing chain 回溯时把这个cbd:路径再喂回controller.stats(),prepareCmd()二次执行convertZbsPathToCbdPath,getPoolFromVolumePath把物理池名误解析,backing chain 查询以ORG_ZSTACK_STORAGE_ZBS_10026失败并回滚,导致父卷与快照残留在存储上。Changes
ZbsHelper.normalizeToZbsPath():仅对cbd:前缀路径转回zbs://(convertCbdPathToZbsPath非幂等,带 guard)ZbsStorageControllerstats()/flatten():设置parentUri时归一化,使 backing chain 全程只跑zbs://Testing
ZbsPrimaryStorageCase新增testGetBackingChainNormalizesCbdParentUri,红绿验证:修复前以 ZBS_10026 失败、修复后通过(Tests run: 1, Failures: 0)影响版本:5.5.12 / 5.5.16 / 5.5.22 / 5.5.24 / 5.5.28(master 不受影响,ZBS 已重写)
Resolves: ZSTAC-85707
sync from gitlab !10071