Skip to content

<fix>[volume-cache]: expose cache capacity fields#4211

Open
zstack-robot-1 wants to merge 1 commit into
feature-5.5.6-local-cachefrom
sync/haidong.pang/feature-5.5.6-local-cache@@3
Open

<fix>[volume-cache]: expose cache capacity fields#4211
zstack-robot-1 wants to merge 1 commit into
feature-5.5.6-local-cachefrom
sync/haidong.pang/feature-5.5.6-local-cache@@3

Conversation

@zstack-robot-1

Copy link
Copy Markdown
Collaborator

Summary

Expose runtime volume cache capacity fields on VolumeCacheInventory for the new GetVolumeCache API response, and publish the generated Java SDK/API helper surface for the same API.

Changes

  • Add virtualSize and actualSize to VolumeCacheInventory.
  • Add generated API doc entries for the new capacity fields.
  • Generate GetVolumeCacheAction and GetVolumeCacheResult for the Java SDK.
  • Generate ApiHelper.getVolumeCache(...) for testlib/API helper users.

Testing

  • git diff --check upstream/feature-5.5.6-local-cache..HEAD
  • git diff --cached --check after SDK/API helper generation
  • scripts/backend-build-container/container-run sdk
    • Result: TestGenerateSDK passed; BUILD SUCCESS
  • scripts/backend-build-container/container-run apihelper
    • Result: TestGenerateApiHelper passed; BUILD SUCCESS
  • Full backend container build passed before commit on the same source tree
  • scripts/backend-build-container/container-run exec --workdir /zstack-workspace/zstack/premium/test-premium -- mvn clean test -Dclean -Djacoco.skip=true -Dtest=VolumeCacheCase
    • Result: Tests run: 1, Failures: 0, Errors: 0, Skipped: 0; BUILD SUCCESS
  • scripts/backend-build-container/container-run docpremium
    • Result: TestGenerateDocTemplate passed; BUILD SUCCESS
  • CI pipeline

Notes:

  • The wrapper command scripts/backend-build-container/container-run test-premium VolumeCacheCase hit an environment resource failure (Too many open files in system) before executing the case (Tests run: 0). The direct clean Maven run above passed.

Resolves: ZSTAC-85172

sync from gitlab !10084

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@MatheMatrix, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 26 minutes and 13 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5f43e449-1ee9-4fac-a2ca-33b97203e4e9

📥 Commits

Reviewing files that changed from the base of the PR and between 7a3b393 and a4e53f4.

📒 Files selected for processing (6)
  • header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java
  • header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovy
  • sdk/src/main/java/org/zstack/sdk/GetVolumeCacheAction.java
  • sdk/src/main/java/org/zstack/sdk/GetVolumeCacheResult.java
  • sdk/src/main/java/org/zstack/sdk/VolumeCacheInventory.java
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy

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

总览

该 PR 向 ZStack 卷缓存模块添加了虚拟大小与实际大小容量字段,并实现了获取卷缓存信息的 SDK API 操作类、对应的结果数据类和测试支持方法。

变更说明

卷缓存容量字段与 API 接口

层 / 文件(s) 摘要
Header 数据模型扩展
header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java, header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovy
在基础类中添加 virtualSizeactualSize 两个 Long 字段及其 getter/setter 方法,文档中标注新字段自版本 5.5.28 起引入。
SDK API 操作类实现
sdk/src/main/java/org/zstack/sdk/GetVolumeCacheAction.java, sdk/src/main/java/org/zstack/sdk/GetVolumeCacheResult.java
实现 GetVolumeCacheAction 类用于向 /volumes/volume-cache 发送 GET 请求,包括参数映射、同步/异步调用方式和错误处理;GetVolumeCacheResult 包含 inventories 列表字段。
SDK 数据模型同步
sdk/src/main/java/org/zstack/sdk/VolumeCacheInventory.java
在 SDK 端 VolumeCacheInventory 中同步添加 virtualSizeactualSize 字段及访问方法。
测试帮助方法
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
新增 getVolumeCache 方法用于测试中创建并执行 GetVolumeCacheAction,支持闭包委托配置和 API 路径追踪。

🎯 2 (Simple) | ⏱️ ~12 分钟

🐰 卷缓存大小新添加,
虚实容量now齐全;
API 接口已完成,
测试方法配套全!

🚥 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 标题「[volume-cache]: expose cache capacity fields」清晰准确地概括了PR的主要变更:向VolumeCacheInventory暴露缓存容量字段。
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/haidong.pang/feature-5.5.6-local-cache@@3

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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java (1)

27-37: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

缺少新增容量字段的 VO→Inventory 映射,导致接口返回值丢失。

valueOf(VolumeCacheVO vo) 未设置 virtualSize/actualSize,会让本次新增字段在返回中始终为空。

建议修复
     inv.setCacheMode(vo.getCacheMode());
     inv.setStatus(vo.getStatus());
+    inv.setVirtualSize(vo.getVirtualSize());
+    inv.setActualSize(vo.getActualSize());
     inv.setCreateDate(vo.getCreateDate());
     inv.setLastOpDate(vo.getLastOpDate());
🤖 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 `@header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java`
around lines 27 - 37, The VolumeCacheInventory.valueOf(VolumeCacheVO vo) method
is missing mapping for the new size fields; update valueOf to copy
vo.getVirtualSize() and vo.getActualSize() into the inventory by calling
inv.setVirtualSize(vo.getVirtualSize()) and
inv.setActualSize(vo.getActualSize()), ensuring VolumeCacheVO’s
virtualSize/actualSize are propagated to VolumeCacheInventory before returning
inv.
🤖 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
`@header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovy`:
- Around line 52-63: The documentation fields for
VolumeCacheInventoryDoc_zh_cn.groovy — specifically the field entries with name
"virtualSize" and "actualSize" — have empty desc values; update their desc to
concise Chinese descriptions (e.g. virtualSize: "逻辑容量(字节)" and actualSize:
"实际占用容量(字节)" or equivalent wording) so the API docs are readable and
unambiguous; locate and edit the field blocks for virtualSize and actualSize to
set the desc strings accordingly.

---

Outside diff comments:
In
`@header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java`:
- Around line 27-37: The VolumeCacheInventory.valueOf(VolumeCacheVO vo) method
is missing mapping for the new size fields; update valueOf to copy
vo.getVirtualSize() and vo.getActualSize() into the inventory by calling
inv.setVirtualSize(vo.getVirtualSize()) and
inv.setActualSize(vo.getActualSize()), ensuring VolumeCacheVO’s
virtualSize/actualSize are propagated to VolumeCacheInventory before returning
inv.
🪄 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: fda2d717-2483-4be2-b047-f25fd8cf2c44

📥 Commits

Reviewing files that changed from the base of the PR and between 513465d and 7a3b393.

📒 Files selected for processing (6)
  • header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java
  • header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovy
  • sdk/src/main/java/org/zstack/sdk/GetVolumeCacheAction.java
  • sdk/src/main/java/org/zstack/sdk/GetVolumeCacheResult.java
  • sdk/src/main/java/org/zstack/sdk/VolumeCacheInventory.java
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy

Expose runtime capacity fields on VolumeCacheInventory for GetVolumeCache, and include generated API docs, Java SDK action/result, and ApiHelper surface.

Resolves: ZSTAC-85172

Change-Id: I9db2260710e085de51213538f1dba31053b27af1
@MatheMatrix MatheMatrix force-pushed the sync/haidong.pang/feature-5.5.6-local-cache@@3 branch from 7a3b393 to a4e53f4 Compare June 10, 2026 03:01
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.

1 participant