Skip to content

<fix>[config]: update globalConfigOptions number range#4161

Open
zstack-robot-2 wants to merge 1 commit into
4.8.38from
sync/yaohua.wu/bugfix/ZSTAC-85576@@2
Open

<fix>[config]: update globalConfigOptions number range#4161
zstack-robot-2 wants to merge 1 commit into
4.8.38from
sync/yaohua.wu/bugfix/ZSTAC-85576@@2

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Backport ZSTAC-85576 to 4.8.38 (cross-repo @@2)

Cherry-pick of original fix (含配套测试) to 4.8.38. 本 issue 同时涉及 zstack 与 premium 两仓,分支统一命名 bugfix/ZSTAC-85576@@2 以便 DevOps 关联跑 case。

Sibling repo MR: premium MR (see below)

Commits

commit bf0875dde3 <fix>[config]: update globalConfigOptions number range
 .../zstack/core/config/GlobalConfigFacadeImpl.java    | 19 +++++++++++++------
 .../org/zstack/core/config/GlobalConfigOptions.java   | 18 ++++++++++++++++++
 .../core/config/GlobalConfigOptionsDoc_zh_cn.groovy   | 12 ++++++++++++
 .../main/java/org/zstack/sdk/GlobalConfigOptions.java | 16 ++++++++++++++++
 .../integration/core/config/GlobalConfigCase.groovy   | 12 ++++++------
 5 files changed, 65 insertions(+), 12 deletions(-)

Related: ZSTAC-85576

sync from gitlab !10066

update globalConfigOptions number range,add options field name,
contains number equal scenario

Resolves: ZSTAC-66043

Change-Id: I756562666169776b6563646d6b61617467726a63
(cherry picked from commit bba7d3c)
(cherry picked from commit d56c8c7)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

概览

该PR为ZStack全局配置系统的数值范围验证添加了包含等于边界的约束支持。新增了numberGreaterThanOrEqualnumberLessThanOrEqual两个字段,替换了原先的严格不等式逻辑(numberGreaterThannumberLessThan),并对核心实现的边界推导机制进行了调整。

变更

数值边界约束扩展

层级 / 文件 说明
数值约束数据模型与文档
core/src/main/java/org/zstack/core/config/GlobalConfigOptions.java, sdk/src/main/java/org/zstack/sdk/GlobalConfigOptions.java, core/src/main/java/org/zstack/core/config/GlobalConfigOptionsDoc_zh_cn.groovy
在core和sdk的GlobalConfigOptions中各增加两个Long字段(numberGreaterThanOrEqualnumberLessThanOrEqual)及其访问器,文档中补充了新字段的类型、说明和自版本5.2.0的标记。
约束映射逻辑调整
core/src/main/java/org/zstack/core/config/GlobalConfigFacadeImpl.java
getConfigOptions()方法中新增isInteger布尔变量区分Integer/Long类型,将数值约束从严格的greater/less改为包容性的GreaterThanOrEqual/LessThanOrEqual,并根据类型选择对应的边界范围。
测试用例验证
test/src/test/groovy/org/zstack/test/integration/core/config/GlobalConfigCase.groovy
testGetNumberRange和testGetNumberBoundary的断言从使用numberGreaterThan/numberLessThan改为numberGreaterThanOrEqual/numberLessThanOrEqual,确认新的包含等于边界约束生效。

代码审查工作量估算

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

🐰 数字边界换了衣,
严格不等变包含,
Integer、Long各自界,
约束约束更温柔,
测试验证安心呢~

🚥 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 标题清晰准确地反映了主要变更:更新全局配置选项的数值范围处理逻辑。
Description check ✅ Passed 描述充分关联变更集,详细说明了此次回溯合并的目的、相关问题编号和涉及的文件。
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/yaohua.wu/bugfix/ZSTAC-85576@@2

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
core/src/main/java/org/zstack/core/config/GlobalConfigOptionsDoc_zh_cn.groovy (1)

28-39: ⚡ Quick win

建议丰富字段描述信息。

当前描述仅为"大于等于"和"小于等于",建议补充更完整的说明,例如:

  • numberGreaterThanOrEqual: "数值下界(包含边界值)"
  • numberLessThanOrEqual: "数值上界(包含边界值)"

这样可以帮助 API 使用者更清楚地理解字段的用途和约束语义。

🤖 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
`@core/src/main/java/org/zstack/core/config/GlobalConfigOptionsDoc_zh_cn.groovy`
around lines 28 - 39, Update the field descriptions for numberGreaterThanOrEqual
and numberLessThanOrEqual in GlobalConfigOptionsDoc_zh_cn.groovy to be more
descriptive; replace the terse "大于等于" and "小于等于" with fuller explanations such
as "数值下界(包含边界值)" for numberGreaterThanOrEqual and "数值上界(包含边界值)" for
numberLessThanOrEqual so API consumers understand these represent inclusive
lower and upper bounds respectively.
sdk/src/main/java/org/zstack/sdk/GlobalConfigOptions.java (1)

31-45: ⚡ Quick win

建议为新增的公共字段添加 Javadoc 注释。

虽然 SDK DTO 类通常文档较少,但为公共字段添加简短的 Javadoc 说明(如 /** 数值下界(包含等于) */)可以提升 API 的可读性和使用体验。

🤖 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 `@sdk/src/main/java/org/zstack/sdk/GlobalConfigOptions.java` around lines 31 -
45, 为公共字段添加简短的 Javadoc 注释以提升可读性:在 numberGreaterThanOrEqual 和
numberLessThanOrEqual 字段及其访问器方法(setNumberGreaterThanOrEqual,
getNumberGreaterThanOrEqual, setNumberLessThanOrEqual,
getNumberLessThanOrEqual)上添加一行注释说明其含义(例如“数值下界(包含)”/“数值上界(包含)”),保持中文或英文简洁描述并放在字段/方法声明前的
/** ... */ 块中。
🤖 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.

Nitpick comments:
In
`@core/src/main/java/org/zstack/core/config/GlobalConfigOptionsDoc_zh_cn.groovy`:
- Around line 28-39: Update the field descriptions for numberGreaterThanOrEqual
and numberLessThanOrEqual in GlobalConfigOptionsDoc_zh_cn.groovy to be more
descriptive; replace the terse "大于等于" and "小于等于" with fuller explanations such
as "数值下界(包含边界值)" for numberGreaterThanOrEqual and "数值上界(包含边界值)" for
numberLessThanOrEqual so API consumers understand these represent inclusive
lower and upper bounds respectively.

In `@sdk/src/main/java/org/zstack/sdk/GlobalConfigOptions.java`:
- Around line 31-45: 为公共字段添加简短的 Javadoc 注释以提升可读性:在 numberGreaterThanOrEqual 和
numberLessThanOrEqual 字段及其访问器方法(setNumberGreaterThanOrEqual,
getNumberGreaterThanOrEqual, setNumberLessThanOrEqual,
getNumberLessThanOrEqual)上添加一行注释说明其含义(例如“数值下界(包含)”/“数值上界(包含)”),保持中文或英文简洁描述并放在字段/方法声明前的
/** ... */ 块中。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 13b1698d-da26-4185-916f-990dbc1d6986

📥 Commits

Reviewing files that changed from the base of the PR and between 00abf62 and bf0875d.

📒 Files selected for processing (5)
  • core/src/main/java/org/zstack/core/config/GlobalConfigFacadeImpl.java
  • core/src/main/java/org/zstack/core/config/GlobalConfigOptions.java
  • core/src/main/java/org/zstack/core/config/GlobalConfigOptionsDoc_zh_cn.groovy
  • sdk/src/main/java/org/zstack/sdk/GlobalConfigOptions.java
  • test/src/test/groovy/org/zstack/test/integration/core/config/GlobalConfigCase.groovy

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