Skip to content
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

Minikube start deletes an existing VM in 'saved' state and re-creates it #18137

Open
travism-lgm opened this issue Feb 9, 2024 · 7 comments
Open
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@travism-lgm
Copy link

travism-lgm commented Feb 9, 2024

What Happened?

In several scenarios the command minikube start will fail to find the existing but stopped VM and destroy it.

Reproduce this with two powershell terminal windows. In one create the minikube instance, then stop (save) the minikube VM in the Hyper-V manager and in an other powershell window execute minikube start. All PS instances must be in elevated permission mode. This results in the existing VM being deleted, and then re-created.

  1. Create a minikube instance
PS1 > minikube start
  1. Open Hyper-V Manager, right-click the 'minikube' VM and select 'Save'. Wait for the save to complete

  2. In a different powershell terminal instance

PS2 > minikube start

This can also be reproduced by setting the VM to not start automatically, and reboot the host machine.

The logs indicate that the command to get the existing VM status succeeds and no errors occur.

Logs from lastStart.txt

I0209 11:06:07.134692   19392 main.go:141] libmachine: [executing ==>] : C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive ( Hyper-V\Get-VM minikube ).state
I0209 11:06:07.972354   19392 main.go:141] libmachine: [stdout =====>] : Saved
I0209 11:06:07.972354   19392 main.go:141] libmachine: [stderr =====>] : 
I0209 11:06:07.972354   19392 fix.go:102] recreateIfNeeded on minikube: state= err=<nil>
I0209 11:06:07.972354   19392 fix.go:107] machineExists: false. err=machine does not exist
I0209 11:06:07.972724   19392 out.go:177] * hyperv "minikube" VM is missing, will recreate.
I0209 11:06:07.974097   19392 delete.go:124] DEMOLISHING minikube ...
I0209 11:06:07.974097   19392 main.go:141] libmachine: [executing ==>] : C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive ( Hyper-V\Get-VM minikube ).state
I0209 11:06:08.672820   19392 main.go:141] libmachine: [stdout =====>] : Saved
I0209 11:06:08.672820   19392 main.go:141] libmachine: [stderr =====>] : 
I0209 11:06:08.672820   19392 stop.go:79] host is in state 
I0209 11:06:08.672820   19392 main.go:141] libmachine: Stopping "minikube"...
I0209 11:06:08.672820   19392 main.go:141] libmachine: [executing ==>] : C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive ( Hyper-V\Get-VM minikube ).state
I0209 11:06:09.369316   19392 main.go:141] libmachine: [stdout =====>] : Saved

Attach the log file

rebuild-minikube-error-lastStart.txt

Operating System

Windows

Driver

Hyper-V

@travism-lgm
Copy link
Author

The issue is that the docker machine driver for hyperv does not handle the "Saved" state, and returns state.None when queried for the VM status.
ref: https://github.com/docker/machine/blob/b170508bf44c3405e079e26d5fdffe35a64c6972/drivers/hyperv/hyperv.go#L139

The docker/machine repo is in read-only mode so I can't create a PR. Not sure how to fix this.

Perhaps this may be a workaround by forcing the VM to gracefully shutdown. Also, to prevent the API failing to come up when the VM is started early in the startup process I also use the flag to not automatically start the VM.

>  Get-VM minikube | Set-VM -AutomaticStartAction Nothing -AutomaticStopAction ShutDown

@travism-lgm travism-lgm changed the title Minikube start with deletes an existing stopped VM and re-creates it Minikube start with deletes an existing VM in 'saved' state and re-creates it Feb 9, 2024
@travism-lgm travism-lgm changed the title Minikube start with deletes an existing VM in 'saved' state and re-creates it Minikube start deletes an existing VM in 'saved' state and re-creates it Feb 9, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 9, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 8, 2024
@travism-lgm
Copy link
Author

Having the minikube instance destroyed because the 'Saved' state is not handled correctly is a destructive and permanent operation. This happens unexpectedly, and is not immediately apparent why. It leads to wasted time spent rebuilding the environment.

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jun 10, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 8, 2024
@travism-lgm
Copy link
Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 9, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

3 participants