Change the vm state as origin first and check vm state on hypervisor
Avoid sending redundant vm state change from Starting to Stopped
Resovles
Support account login extension point
@@ -4944,16 +4944,10 @@ public class VmInstanceBase extends AbstractVmInstance {
self = dbf.reload(self);
extEmitter.failedToStartVm(VmInstanceInventory.valueOf(self), errCode);
VmInstanceSpec spec = (VmInstanceSpec) data.get(Params.VmInstanceSpec.toString());
- if (HostErrors.FAILED_TO_START_VM_ON_HYPERVISOR.isEqual(errCode.getCode())) {
- checkState(spec.getDestHost().getUuid(), new NoErrorCompletion(completion) {
- @Override
- public void done() {
- completion.fail(errCode);
- }
- });
- return;
- }
+ // update vm state to origin state before checking state
+ // avoid sending redundant vm state change event
+ // refer to: ZSTAC-18174
new SQLBatch() {
@Override
protected void scripts() {
@@ -4963,6 +4957,17 @@ public class VmInstanceBase extends AbstractVmInstance {
self = merge(self);
}
}.execute();
+
+ if (HostErrors.FAILED_TO_START_VM_ON_HYPERVISOR.isEqual(errCode.getCode())) {
+ checkState(spec.getDestHost().getUuid(), new NoErrorCompletion(completion) {
+ @Override
+ public void done() {
+ completion.fail(errCode);
+ }
+ });
+ return;
+ }
+
completion.fail(errCode);
}
}).start();
