Skip to content

<fix>[vm]: avoid StopVmGC stopping live vm#3972

Open
zstack-robot-2 wants to merge 1 commit into
5.5.22from
sync/hanyu.liang/fix-84174
Open

<fix>[vm]: avoid StopVmGC stopping live vm#3972
zstack-robot-2 wants to merge 1 commit into
5.5.22from
sync/hanyu.liang/fix-84174

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Only allow StopVmGC to send StopVmOnHypervisorMsg while the VM is still Stopped. If the VM has already been started again before the GC runs, cancel the GC job instead.

Resolves: ZSTAC-84174

Change-Id: Ib58111c4237bd41abc7c9b0d1b4e05f9bee24ec4

sync from gitlab !9863

Only allow StopVmGC to send StopVmOnHypervisorMsg while the VM is still Stopped. If the VM has already been started again before the GC runs, cancel the GC job instead.

Resolves: ZSTAC-84174

Change-Id: Ib58111c4237bd41abc7c9b0d1b4e05f9bee24ec4
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: 6159f745-f95a-4a82-82f1-7db8178edc56

📥 Commits

Reviewing files that changed from the base of the PR and between 4cdaed7 and d7b3c12.

📒 Files selected for processing (2)
  • compute/src/main/java/org/zstack/compute/vm/StopVmGC.java
  • test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmGCCase.groovy

总体概览

该变更在StopVmGC中添加了针对VM状态的守卫逻辑,当VM不处于Stopped状态时将取消垃圾回收完成;同时添加了集成测试来验证VM重新启动后此保护机制的正确行为。

变更内容

VM停止垃圾回收状态守卫

层级 / 文件 摘要
StopVmGC 状态检查实现
compute/src/main/java/org/zstack/compute/vm/StopVmGC.java
triggerNow 方法中添加条件判断:当VM状态不为 Stopped 时,记录包含VM和主机详情的信息日志并取消GC完成;之前仅在状态为 nullDestroyed 时才会取消。
VM启动后GC取消测试
test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmGCCase.groovy
新增 testStopVmGCJobCancelAfterVmStarted 测试方法验证当VM重新启动时GC被正确取消的场景。测试创建停止VM并启用GC失败启动,重新启动VM后重连主机触发GC,验证停止/GC命令未被发送且GC作业以 Done 状态完成。集成测试套件在环境重建后调用该新测试方法。

代码评审工作量估算

🎯 2 (简单) | ⏱️ ~10 分钟

诗歌献礼

垃圾回收需守护,
状态检查来把关,
启动的兔子再跑,
GC安心不骚扰,
测试验证更放心! 🐰✨

🚥 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 标题遵循了指定的 [scope]: 格式,长度为42个字符,符合72个字符以内的要求。标题清晰地描述了主要改动:避免StopVmGC停止活跃的虚拟机。
Description check ✅ Passed 拉取请求描述与代码变更内容相关。描述明确说明了允许StopVmGC仅在VM处于Stopped状态时发送消息,以及如果VM已被重新启动则取消GC任务的改动,与代码摘要中的内容相符。
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/hanyu.liang/fix-84174

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