Skip to content

<fix>[ceph]: handle empty installPath in capacity calc#3802

Open
zstack-robot-2 wants to merge 1 commit intozsv_5.0.0from
sync/tao.gan/ZSV-11968
Open

<fix>[ceph]: handle empty installPath in capacity calc#3802
zstack-robot-2 wants to merge 1 commit intozsv_5.0.0from
sync/tao.gan/ZSV-11968

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Resolves: ZSV-11968

Change-Id: I7a6e706d6e647570756b76676b6c736f61786362

sync from gitlab !9672

Resolves: ZSV-11968

Change-Id: I7a6e706d6e647570756b76676b6c736f61786362
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

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: f898ceba-c090-4e9c-ae2c-c9e5f8937cd7

📥 Commits

Reviewing files that changed from the base of the PR and between d514231 and 2332cce.

📒 Files selected for processing (2)
  • plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/capacity/CephOsdGroupCapacityHelper.java
  • test/src/test/groovy/org/zstack/test/integration/storage/primary/ceph/xsky/capacity/CephXskyPoolCapacityCase.groovy

Walkthrough

将容量计算逻辑修改为在按 poolName 安装路径前缀对卷、镜像和快照进行分组时,将空字符串字段视为无效。从单纯的非空检查更新为空字符串或非空检查,并添加相应的测试用例以验证此行为。

Changes

Cohort / File(s) Summary
容量计算验证逻辑更新
plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/capacity/CephOsdGroupCapacityHelper.java
修改 calculateAvailableCapacityByRatio 方法中的字段验证逻辑,将 VolumeVO.getInstallPath()ImageCacheVO.getInstallUrl()VolumeSnapshotVO.getPrimaryStorageInstallPath() 的检查从 != null 改为 !StringUtils.isEmpty(...),以排除空字符串。添加 StringUtils 导入以支持更新后的验证逻辑。
容量计算测试用例扩展
test/src/test/groovy/org/zstack/test/integration/storage/primary/ceph/xsky/capacity/CephXskyPoolCapacityCase.groovy
新增测试方法 testSkipCalculateCapacityWhichInstallPathIsEmpty() 用于验证空字符串安装路径场景,通过将数据库字段更新为空字符串后重新连接主存储来测试容量计算跳过逻辑,补充现有的空值测试覆盖。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

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 标题准确概括了主要变更,即在容量计算中处理空的installPath字段。
Description check ✅ Passed 描述与变更集相关,提到了解决的问题编号ZSV-11968和同步来源。

✏️ 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/tao.gan/ZSV-11968

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