<fix>[compute]: <description#3699
<fix>[compute]: <description#3699zstack-robot-2 wants to merge 1 commit intofeature-zsv-5.0.0-vm-support-vtpm-and-secucebootfrom
Conversation
Resolves: ZSV-11714 Change-Id: I6b6961746e6d7a69776a6d7962746164766a7573
概览在 变更
代码审查工作量评估🎯 2 (简单) | ⏱️ ~10 分钟 诗
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@compute/src/main/java/org/zstack/compute/host/HostManagerImpl.java`:
- Around line 890-905: Restore the commented "Disconnected" branch in
HostManagerImpl: re-enable the
PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData handling that
checks if d.getNewStatus() == PrimaryStorageHostStatus.Disconnected &&
d.getOldStatus() != PrimaryStorageHostStatus.Disconnected &&
noStorageAccessible(d.getHostUuid()), then build and send a
ChangeHostConnectionStateMsg (setHostUuid,
setConnectionStateEvent(HostStatusEvent.disconnected.toString()), setCause),
call bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID,
d.getHostUuid()) and bus.send(msg), and fire new
HostBase.HostDisconnectedCanonicalEvent(d.getHostUuid(), operr(...)) so hosts
with no accessible primary storage are marked disconnected and the
HostDisconnectedCanonicalEvent is emitted.
🪄 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: ca3842c2-3781-4241-9fbe-80220406abbb
📒 Files selected for processing (1)
compute/src/main/java/org/zstack/compute/host/HostManagerImpl.java
| // PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData d = | ||
| // (PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData)data; | ||
| // if (d.getNewStatus() == PrimaryStorageHostStatus.Disconnected && | ||
| // d.getOldStatus() != PrimaryStorageHostStatus.Disconnected && | ||
| // noStorageAccessible(d.getHostUuid())){ | ||
| // ChangeHostConnectionStateMsg msg = new ChangeHostConnectionStateMsg(); | ||
| // msg.setHostUuid(d.getHostUuid()); | ||
| // msg.setConnectionStateEvent(HostStatusEvent.disconnected.toString()); | ||
| // msg.setCause("base cause: host disconnected from other status and has no connected primary storage attached"); | ||
| // bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, d.getHostUuid()); | ||
| // bus.send(msg); | ||
| // | ||
| // new HostBase.HostDisconnectedCanonicalEvent(d.getHostUuid(), | ||
| // operr("primary storage[uuid:%s] becomes disconnected, the host has no connected primary storage attached", | ||
| // d.getPrimaryStorageUuid())).fire(); | ||
| // } |
There was a problem hiding this comment.
恢复主存断连后的 Host 断连处理链路
Line 890-905 把 Disconnected 分支整段注释后,这个 canonical event 回调变成空实现;当前没有其他监听器补上“无可达主存时置 Host 为 disconnected + 发出 HostDisconnectedCanonicalEvent”的逻辑,属于功能回退。
建议的最小修复(恢复原处理分支)
evtf.on(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_HOST_STATUS_CHANGED_PATH, new EventCallback() {
`@Override`
protected void run(Map tokens, Object data) {
-// PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData d =
-// (PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData)data;
-// if (d.getNewStatus() == PrimaryStorageHostStatus.Disconnected &&
-// d.getOldStatus() != PrimaryStorageHostStatus.Disconnected &&
-// noStorageAccessible(d.getHostUuid())){
-// ChangeHostConnectionStateMsg msg = new ChangeHostConnectionStateMsg();
-// msg.setHostUuid(d.getHostUuid());
-// msg.setConnectionStateEvent(HostStatusEvent.disconnected.toString());
-// msg.setCause("base cause: host disconnected from other status and has no connected primary storage attached");
-// bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, d.getHostUuid());
-// bus.send(msg);
-//
-// new HostBase.HostDisconnectedCanonicalEvent(d.getHostUuid(),
-// operr("primary storage[uuid:%s] becomes disconnected, the host has no connected primary storage attached",
-// d.getPrimaryStorageUuid())).fire();
-// }
+ PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData d =
+ (PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData) data;
+ if (d.getNewStatus() == PrimaryStorageHostStatus.Disconnected &&
+ d.getOldStatus() != PrimaryStorageHostStatus.Disconnected &&
+ noStorageAccessible(d.getHostUuid())) {
+ ChangeHostConnectionStateMsg msg = new ChangeHostConnectionStateMsg();
+ msg.setHostUuid(d.getHostUuid());
+ msg.setConnectionStateEvent(HostStatusEvent.disconnected.toString());
+ msg.setCause("base cause: host disconnected from other status and has no connected primary storage attached");
+ bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, d.getHostUuid());
+ bus.send(msg);
+
+ new HostBase.HostDisconnectedCanonicalEvent(
+ d.getHostUuid(),
+ operr("primary storage[uuid:%s] becomes disconnected, the host has no connected primary storage attached",
+ d.getPrimaryStorageUuid())
+ ).fire();
+ }
}
});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@compute/src/main/java/org/zstack/compute/host/HostManagerImpl.java` around
lines 890 - 905, Restore the commented "Disconnected" branch in HostManagerImpl:
re-enable the PrimaryStorageCanonicalEvent.PrimaryStorageHostStatusChangeData
handling that checks if d.getNewStatus() ==
PrimaryStorageHostStatus.Disconnected && d.getOldStatus() !=
PrimaryStorageHostStatus.Disconnected && noStorageAccessible(d.getHostUuid()),
then build and send a ChangeHostConnectionStateMsg (setHostUuid,
setConnectionStateEvent(HostStatusEvent.disconnected.toString()), setCause),
call bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID,
d.getHostUuid()) and bus.send(msg), and fire new
HostBase.HostDisconnectedCanonicalEvent(d.getHostUuid(), operr(...)) so hosts
with no accessible primary storage are marked disconnected and the
HostDisconnectedCanonicalEvent is emitted.
Resolves: ZSV-11714
Change-Id: I6b6961746e6d7a69776a6d7962746164766a7573
sync from gitlab !9562