Skip to content

[5.4.10] cherry-pick ZSTAC vhost and query fixes#4383

Open
MatheMatrix wants to merge 1 commit into
5.4.10from
sync/shan.wu/backport/5.4.10/ZSTAC-86486-batch@@3
Open

[5.4.10] cherry-pick ZSTAC vhost and query fixes#4383
MatheMatrix wants to merge 1 commit into
5.4.10from
sync/shan.wu/backport/5.4.10/ZSTAC-86486-batch@@3

Conversation

@MatheMatrix

Copy link
Copy Markdown
Owner

Summary

Cherry-pick 5.x fixes for the new 5.4.10 ZSTAC batch.

Included Jira

  • ZSTAC-86468 via ZSTAC-80546
  • ZSTAC-86449 via ZSTAC-80742

Source MR

Testing

  • git diff --check zstack/5.4.10..HEAD

Related: ZSTAC-86468 ZSTAC-86449

sync from gitlab !10343

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

Walkthrough

本次改动将 QueryFacadeImpl 中处理 APIQueryMessage 的逻辑拆分为 doQuery 与 handle 两个方法:doQuery 负责查询执行与异常分类,handle 改为通过 thdf.syncSubmit 同步执行任务并统一处理错误回复。

Changes

查询处理拆分与同步执行

Layer / File(s) Summary
查询核心逻辑提取
search/src/main/java/org/zstack/query/QueryFacadeImpl.java
新增 doQuery(APIQueryMessage msg),负责 @AutoQuery 反射解析、创建 APIQueryReply、调用 queryUseZQL 并写回 total/inventories;OperationFailureException 继续抛出,其它异常包装为 CloudRuntimeException。
同步执行与错误回复重写
search/src/main/java/org/zstack/query/QueryFacadeImpl.java
handle(APIQueryMessage msg) 改为使用 thdf.syncSubmit 在同步任务中调用 doQuery,捕获 OperationFailureException 时构造带错误码的空 APIQueryReply,最终统一通过 bus.reply 返回。

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant handle
  participant syncSubmit
  participant doQuery
  Caller->>handle: APIQueryMessage
  handle->>syncSubmit: 提交同步任务
  syncSubmit->>doQuery: 调用 doQuery(msg)
  doQuery-->>syncSubmit: 返回 reply 或抛出 OperationFailureException
  syncSubmit-->>handle: 结果/异常
  handle->>Caller: bus.reply(msg, reply)
Loading

Poem

小兔跳进代码林,
拆开查询两段行,
同步任务稳稳跑,
异常也能好好回,
耳朵一动查询成~ 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题与该补丁的回溯修复和查询相关修改一致,但表述略偏宽泛。
Description check ✅ Passed 描述明确说明了这是为 5.4.10 批次回溯 5.x 修复,和变更内容一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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/shan.wu/backport/5.4.10/ZSTAC-86486-batch@@3

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

Route AutoQuery handling through the query sync queue so bursty GraphQL refreshes cannot run unlimited APIQueryMessage requests concurrently.

Resolves: ZSTAC-80742

Change-Id: If2c052e539526cd0511e037d1718838bdb65a7a3
@MatheMatrix MatheMatrix force-pushed the sync/shan.wu/backport/5.4.10/ZSTAC-86486-batch@@3 branch from 8c63d20 to ada4787 Compare July 1, 2026 02:50

@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.

Caution

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

⚠️ Outside diff range comments (1)
search/src/main/java/org/zstack/query/QueryFacadeImpl.java (1)

350-381: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

补上 APIQueryMessage 的通用异常回复 search/src/main/java/org/zstack/query/QueryFacadeImpl.java:384-396

doQuery() 仍会把反射/ZQL 异常抛成 CloudRuntimeException,而这里的 call() 只处理 OperationFailureExceptionDispatchQueueImpl.SyncTaskFuture.run() 只会记录异常,不会自动生成 bus.reply,所以这条路径还是会丢回复并让调用方超时。建议补一个通用 catch,或在 doQuery() 内统一转成可回包的失败结果。

🤖 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 `@search/src/main/java/org/zstack/query/QueryFacadeImpl.java` around lines 350
- 381, QueryFacadeImpl.doQuery currently turns reflection/ZQL failures into
CloudRuntimeException, but APIQueryMessage.call only handles
OperationFailureException, so the request can fail without a reply. Update
doQuery and/or call to catch all unexpected exceptions from replyClass
instantiation, replySetter invocation, or queryUseZQL, and convert them into a
proper APIQueryReply failure path that can be sent back via bus.reply instead of
leaking as an unhandled runtime exception.
🤖 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.

Outside diff comments:
In `@search/src/main/java/org/zstack/query/QueryFacadeImpl.java`:
- Around line 350-381: QueryFacadeImpl.doQuery currently turns reflection/ZQL
failures into CloudRuntimeException, but APIQueryMessage.call only handles
OperationFailureException, so the request can fail without a reply. Update
doQuery and/or call to catch all unexpected exceptions from replyClass
instantiation, replySetter invocation, or queryUseZQL, and convert them into a
proper APIQueryReply failure path that can be sent back via bus.reply instead of
leaking as an unhandled runtime exception.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a4b9cbe2-8259-49d7-b890-6257dc1a6edf

📥 Commits

Reviewing files that changed from the base of the PR and between 784c703 and ada4787.

📒 Files selected for processing (1)
  • search/src/main/java/org/zstack/query/QueryFacadeImpl.java

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