<fix>[vm]: publish HA start state change#3910
Conversation
Resolves: ZSTAC-84266 Change-Id: Ib8851991f035890cac610ac0fb3829e6780ded0f
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
通览此变更为VM状态变化规范事件添加了源追踪能力。新增stateChangeSource字段到VmStateChangedData,扩展changeVmStateInDb方法接收此参数,并在HA启动处理中将状态转换从手动SQL改为调用新增的API。 变更VM状态变化源追踪
代码审查工作量估计🎯 2 (简单) | ⏱️ ~12 分钟 诗歌
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.1)compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.javaComment |
Root Cause
VmInstanceBase.handle(HaStartVmInstanceMsg)directly updatedVmInstanceVO.statetoStoppedthrough SQL before HA start. This bypassedchangeVmStateInDb(), so the VM state transition log,/vm/state/changecanonical event, andVmStateChangedExtensionPointcallback were not emitted for the HA internalUnknown -> Stoppedtransition.Resolve
stateChangeSourcetoVmCanonicalEvents.VmStateChangedData; existing events keep the defaultnullvalue.changeVmStateInDb(VmInstanceStateEvent.stopped, ..., HaStartVmInstanceMsg.class.getName())instead of direct SQL update.Verification
Remote environment:
root@172.20.18.132/home/zstack/header:/usr/local/maven/bin/mvn clean install -Dmaven.test.skip=true-> BUILD SUCCESS/home/zstack/compute:/usr/local/maven/bin/mvn clean install -Dmaven.test.skip=true-> BUILD SUCCESS/home/zstack/premium/mevoco:/usr/local/maven/bin/mvn clean install -Dmaven.test.skip=true-> BUILD SUCCESS/home/zstack/premium/test-premium:/usr/local/maven/bin/mvn test -T 1C -Dtest=VmHaStartStateChangeEventCase-> Tests run: 1, Failures: 0, Errors: 0Jira: ZSTAC-84266
Supersedes wrong branch-name MR: http://dev.zstack.io:9080/zstackio/zstack/-/merge_requests/9794
sync from gitlab !9795