Skip to content

Commit 8797213

Browse files
committed
<fix>[vm]: always submit DeleteVmGC on create rollback
Resolves: ZSTAC-68874 Change-Id: I49fd973a29ddea3299acfca2d9c70f88ea5e7906
1 parent 8117a99 commit 8797213

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

compute/src/main/java/org/zstack/compute/vm/VmCreateOnHypervisorFlow.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,23 @@ public void run(MessageReply reply) {
7979
spec.getVmInventory().getUuid(), spec.getVmInventory().getName(),
8080
spec.getDestHost().getUuid(), spec.getDestHost().getName(), reply.getError()));
8181

82-
if (reply.getError().isError(HostErrors.OPERATION_FAILURE_GC_ELIGIBLE)) {
83-
String gcName = String.format("gc-vm-%s-on-host-%s", spec.getVmInventory().getUuid(), spec.getDestHost().getUuid());
84-
85-
DeleteVmGC gc = new DeleteVmGC();
86-
gc.NAME = gcName;
87-
gc.hostUuid = spec.getVmInventory().getHostUuid();
88-
gc.inventory = spec.getVmInventory();
89-
if (gc.existedAndNotCompleted()) {
90-
logger.debug(String.format("There is already a DeleteVmGC of vm[uuid:%s] " +
91-
"on host[uuid:%s], skip.", spec.getVmInventory().getUuid(), spec.getDestHost().getUuid()));
92-
} else {
93-
gc.submit();
94-
}
82+
// Always submit GC to clean up the VM on the hypervisor,
83+
// regardless of whether the error is GC_ELIGIBLE or not.
84+
// This prevents orphaned VMs and GPU dirty data (ZSTAC-68874).
85+
String gcName = String.format("gc-vm-%s-on-host-%s", spec.getVmInventory().getUuid(), spec.getDestHost().getUuid());
86+
87+
DeleteVmGC gc = new DeleteVmGC();
88+
gc.NAME = gcName;
89+
gc.hostUuid = spec.getVmInventory().getHostUuid();
90+
gc.inventory = spec.getVmInventory();
91+
if (gc.existedAndNotCompleted()) {
92+
logger.debug(String.format("There is already a DeleteVmGC of vm[uuid:%s] " +
93+
"on host[uuid:%s], skip.", spec.getVmInventory().getUuid(), spec.getDestHost().getUuid()));
9594
} else {
95+
gc.submit();
96+
}
97+
98+
if (!reply.getError().isError(HostErrors.OPERATION_FAILURE_GC_ELIGIBLE)) {
9699
VmTracerCanonicalEvents.OperateFailOnHypervisorData data = new VmTracerCanonicalEvents.OperateFailOnHypervisorData();
97100
data.setHostUuid(spec.getVmInventory().getHostUuid());
98101
data.setVmUuid(spec.getVmInventory().getUuid());

0 commit comments

Comments
 (0)