forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[compute]: <description #3183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ZStack-Robot
wants to merge
2
commits into
zsv_4.10.28
Choose a base branch
from
sync/tao.gan/res-vm-ZSV-1@@4
base: zsv_4.10.28
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+762
−50
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
compute/src/main/java/org/zstack/compute/vm/UpdateVmInstanceMetadataGC.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package org.zstack.compute.vm; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.zstack.core.cloudbus.CloudBusCallBack; | ||
| import org.zstack.core.gc.GC; | ||
| import org.zstack.core.gc.GCCompletion; | ||
| import org.zstack.core.gc.TimeBasedGarbageCollector; | ||
| import org.zstack.core.thread.ChainTask; | ||
| import org.zstack.core.thread.SyncTaskChain; | ||
| import org.zstack.core.thread.ThreadFacade; | ||
| import org.zstack.header.core.progress.ChainInfo; | ||
| import org.zstack.header.message.MessageReply; | ||
| import org.zstack.header.vm.UpdateVmInstanceMetadataMsg; | ||
| import org.zstack.header.volume.VolumeConstant; | ||
| import org.zstack.header.volume.VolumeVO; | ||
|
|
||
| public class UpdateVmInstanceMetadataGC extends TimeBasedGarbageCollector { | ||
| @GC | ||
| public String vmInstanceUuid; | ||
|
|
||
| @Autowired | ||
| protected ThreadFacade thdf; | ||
|
|
||
| static public String getUpdateVmInstanceMetadataSyncSignature(String vmInstanceUuid) { | ||
| return String.format("update-vm-%s-metadata", vmInstanceUuid); | ||
| } | ||
|
|
||
| @Override | ||
| protected void triggerNow(GCCompletion completion) { | ||
| if (!dbf.isExist(vmInstanceUuid, VolumeVO.class)) { | ||
| completion.cancel(); | ||
| return; | ||
| } | ||
|
|
||
| String queueName = getUpdateVmInstanceMetadataSyncSignature(vmInstanceUuid); | ||
| ChainInfo chainInfo = thdf.getChainTaskInfo(queueName); | ||
| if (!chainInfo.getPendingTask().isEmpty()) { | ||
| completion.cancel(); | ||
| return; | ||
| } | ||
|
|
||
| thdf.chainSubmit(new ChainTask(completion) { | ||
| @Override | ||
| public String getSyncSignature() { | ||
| return queueName; | ||
| } | ||
|
|
||
| @Override | ||
| public void run(final SyncTaskChain chain) { | ||
| UpdateVmInstanceMetadataMsg msg = new UpdateVmInstanceMetadataMsg(); | ||
| msg.setUuid(vmInstanceUuid); | ||
| bus.makeTargetServiceIdByResourceUuid(msg, VolumeConstant.SERVICE_ID, vmInstanceUuid); | ||
| bus.send(msg, new CloudBusCallBack(completion) { | ||
| @Override | ||
| public void run(MessageReply reply) { | ||
| if (!reply.isSuccess()) { | ||
| completion.fail(reply.getError()); | ||
| } else { | ||
| completion.success(); | ||
| } | ||
| } | ||
| }); | ||
|
Comment on lines
+49
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 异步回调未释放链,可能阻塞后续任务。 🛠 建议修改- bus.send(msg, new CloudBusCallBack(completion) {
+ bus.send(msg, new CloudBusCallBack(completion) {
`@Override`
public void run(MessageReply reply) {
- if (!reply.isSuccess()) {
- completion.fail(reply.getError());
- } else {
- completion.success();
- }
+ try {
+ if (!reply.isSuccess()) {
+ completion.fail(reply.getError());
+ } else {
+ completion.success();
+ }
+ } finally {
+ chain.next();
+ }
}
});🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return queueName; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
消息路由使用了错误的 SERVICE_ID
UpdateVmInstanceMetadataMsg实现了VmInstanceMessage接口,应路由到 VM 服务,而非 Volume 服务。当前使用VolumeConstant.SERVICE_ID会导致消息被发送到错误的服务处理。🛠️ 建议修改
🤖 Prompt for AI Agents