Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions compute/src/main/java/org/zstack/compute/vm/StopVmGC.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected void triggerNow(GCCompletion completion) {
public void run(FlowTrigger trigger, Map data) {
StopVmOnHypervisorMsg msg = new StopVmOnHypervisorMsg();
msg.setVmInventory(inventory);
msg.setIgnoreNotFoundError(true);
bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, hostUuid);
bus.send(msg, new CloudBusCallBack(trigger) {
@Override
Expand All @@ -66,6 +67,16 @@ public void run(MessageReply reply) {
}).then(new NoRollbackFlow() {
@Override
public void run(FlowTrigger trigger, Map data) {
String vmHostUuid = Q.New(VmInstanceVO.class).select(VmInstanceVO_.hostUuid)
.eq(VmInstanceVO_.uuid, inventory.getUuid()).findValue();
if (!hostUuid.equals(vmHostUuid)) {
logger.debug(String.format("skip changing vm[uuid:%s] state to stopped after StopVmGC, " +
"current host[uuid:%s] is not gc host[uuid:%s]", inventory.getUuid(),
vmHostUuid, hostUuid));
trigger.next();
return;
}

ChangeVmStateMsg cmsg = new ChangeVmStateMsg();
cmsg.setVmInstanceUuid(inventory.getUuid());
cmsg.setStateEvent(VmInstanceStateEvent.stopped.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class StopVmOnHypervisorMsg extends NeedReplyMessage implements HostMessa
private VmInstanceInventory vmInventory;
private String type;
private boolean debug;
private Boolean ignoreNotFoundError;

public VmInstanceInventory getVmInventory() {
return vmInventory;
Expand Down Expand Up @@ -36,4 +37,12 @@ public boolean isDebug() {
public void setDebug(boolean debug) {
this.debug = debug;
}

public Boolean isIgnoreNotFoundError() {
return ignoreNotFoundError;
}

public void setIgnoreNotFoundError(Boolean ignoreNotFoundError) {
this.ignoreNotFoundError = ignoreNotFoundError;
}
}
10 changes: 10 additions & 0 deletions plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -3328,6 +3328,8 @@ public static class StopVmCmd extends AgentCommand {
private String type;
@GrayVersion(value = "5.0.0")
private long timeout;
@GrayVersion(value = "5.5.22")
private Boolean ignoreNotFoundError;
private List<VmNicInventory> vmNics;

public String getUuid() {
Expand All @@ -3354,6 +3356,14 @@ public void setType(String type) {
this.type = type;
}

public Boolean isIgnoreNotFoundError() {
return ignoreNotFoundError;
}

public void setIgnoreNotFoundError(Boolean ignoreNotFoundError) {
this.ignoreNotFoundError = ignoreNotFoundError;
}

public List<VmNicInventory> getVmNics() {
return vmNics;
}
Expand Down
1 change: 1 addition & 0 deletions plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -3872,6 +3872,7 @@ protected void stopVm(final StopVmOnHypervisorMsg msg, final NoErrorCompletion c
cmd.setUuid(vminv.getUuid());
cmd.setType(msg.getType());
cmd.setTimeout(120);
cmd.setIgnoreNotFoundError(msg.isIgnoreNotFoundError());
cmd.setVmNics(vminv.getVmNics());

try {
Expand Down