From 2c2c45d7a6dfcaa058d1b34a90ee5fc6a82833b9 Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Mon, 23 Oct 2017 11:23:58 -0700 Subject: [PATCH] DOM_SHUTDOWN should return state.Running Technically, DOMAIN_SHUTDOWN just means that the VM is in the process of shutting down. We should still return state.Running so that we don't return from `minikube stop` before the domain is actually stopped. This should fix a few flakes. --- pkg/drivers/kvm/kvm.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/drivers/kvm/kvm.go b/pkg/drivers/kvm/kvm.go index 48bb3460d59f..71c3318a2817 100644 --- a/pkg/drivers/kvm/kvm.go +++ b/pkg/drivers/kvm/kvm.go @@ -129,14 +129,28 @@ func (d *Driver) GetState() (state.State, error) { return state.None, errors.Wrap(err, "getting domain state") } + // Possible States: + // + // VIR_DOMAIN_NOSTATE no state + // VIR_DOMAIN_RUNNING the domain is running + // VIR_DOMAIN_BLOCKED the domain is blocked on resource + // VIR_DOMAIN_PAUSED the domain is paused by user + // VIR_DOMAIN_SHUTDOWN the domain is being shut down + // VIR_DOMAIN_SHUTOFF the domain is shut off + // VIR_DOMAIN_CRASHED the domain is crashed + // VIR_DOMAIN_PMSUSPENDED the domain is suspended by guest power management + // VIR_DOMAIN_LAST this enum value will increase over time as new events are added to the libvirt API. It reflects the last state supported by this version of the libvirt API. + switch libvirtState { - case libvirt.DOMAIN_RUNNING: + // DOMAIN_SHUTDOWN technically means the VM is still running, but in the + // process of being shutdown, so we return state.Running + case libvirt.DOMAIN_RUNNING, libvirt.DOMAIN_SHUTDOWN: return state.Running, nil case libvirt.DOMAIN_BLOCKED, libvirt.DOMAIN_CRASHED: return state.Error, nil case libvirt.DOMAIN_PAUSED: return state.Paused, nil - case libvirt.DOMAIN_SHUTDOWN, libvirt.DOMAIN_SHUTOFF: + case libvirt.DOMAIN_SHUTOFF: return state.Stopped, nil case libvirt.DOMAIN_PMSUSPENDED: return state.Saved, nil @@ -299,7 +313,7 @@ func (d *Driver) Stop() error { if s == state.Stopped { return nil } - log.Info("Waiting for machine to stop %d/%d", i, 60) + log.Infof("Waiting for machine to stop %d/%d", i, 60) time.Sleep(1 * time.Second) }