-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
1.34 - "minikube delete --purge" deletes entire MINIKUBE_HOME directory if env var does not end with "/.minikube" #19769
Comments
I think I may have found a fix for this issue. I'd like to work on this. |
This bug seems to come from this function.
The problem is that whether the legacy home directory functionality is used depends on the existence of a directory at The pull request that introduced this behavior was intending to make backwards compatibility more convenient but it seems to have caused a bigger problem. The pull request was resolving an issue about the confusing behavior of MiniPath. However, this seems to have created a bigger issue. I think it would be best to move back to the old version of the code and add some tests that demonstrate the backwards compatible behavior better. |
I made a pr with some changes that fix this bug. |
I think we kind of did a mistake in the previous release not to think about this, the rightthing to do is, alternatvely we should enforce users to set their minikube home folder to something that is called .minikube, so in the purge we only delete .minikube folder I wish there was a way to Tag or label files and folders created by minikube (like when u create a docker resource) that way we could be 100% sure we deleting only minikube |
It seems like there are two options.
From what I understand, the goal going forward is to require the base name of the config directory to be ".minikube". Option 1 allows users to use a non-standard directory name for their minikube config. However, option 2 still requires a ".minikube" directory to exist somewhere on someone's system in order for their minikube instance to work. I think option 2 is more in line with the overall goal of getting everyone switched over having their minikube config directory be named ".minikube". If you go with option 1 it allows people to use a directory named "mini-kube" for their config which would get you further away from the end goal. |
I still dont know the right solution but I know for sure we have to add these guard rails regarless of the solution 1- if $HOME dir is the same as "minikube home folder" we should NOT delete it and tell the user they gotta do it manually and be cautious
3- would be create a Flag File inside minikube with some signature that shows this folder was created by minikube however we wont be able to do that in next 1-2 versions because the next version of minikube wont be able to delete the .minikube folder that doesnt have the flag (created by previous versions) so we should have a main function called "IsItMinikubeCreatedFolder" and we can use option 2 and 3 to verify 4- We can also check the folders/files listed in 2 and the first time that we create/start the minikube home folder we should Warn them that they have chosen a Non Empty Directory for their home folder. |
@afbjorklund @prezha wdyt |
I think the way to go is to accept MINIKUBE_HOME as the directory where the .minikube directory is created. There is no reason to let the user chose the ".minikube" part, and deleting MINIKUBE_HOME is wrong as deleting HOME. There is no need to check the contents of the .minikube directory, it belongs to minikube and users should not keep their files there. If a user configures MINIKUBE_HOME= |
it would be hard to tract which folders and files we (ie, minikube) created and which ones user added/modified in minikube home dir (eg, solutions relying on any filesystem features would be "impossible" to implement for all possible filesystems users might have, also, maintaining some kind of list of files/folders minikube created could be error-prone and unreliable, etc.) on the other hand, there are cases where we do want minikube home dir completely removed (eg, sometimes that's used to check if it fixes an issue user is facing, in CI to "start from scratch", etc.) up until v1.34.0 hence, "merging" the minikube-related stuff with other stuff is generally not a good idea therefore, we could revert the change so that MiniPath() again always returns however, if the only potential issue is while purging, whereas MiniPath() does not return
|
Thank you both @nirs and @prezha based on both above here is what I think, it is perfectly okay for minikube to have mandatory ".minikube" home folder name so if the user wants to force minikube to use a not .minikube name seems to be a very odd request for not clear reason however they would still have a chance to do that by makiing a symlink. so I am in favor of reverting the change. wdyt @spowelljr ? one thing that would make sense is, if the user Already specified ".minikube" in their ENV we could ignore avoid making a nested .minikube, wdyt @prezha @nirs |
btw @nirs I have seen your great contributions to minikube I am greatful for having you around, woudld you like to come to our office hours sometime ? our next one Next monday 11 AM Pacific time https://minikube.sigs.k8s.io/community/ |
This fix should be merged rapidly, as this just deleted the entire contents of my work, including commits i had not pushed. |
I had my MINIKUBE_HOME set to a directory i use for all of my work stuff (reason being is that /home/ is a network share and it would be slow to do all of my coding there.) Running minikube delete --purge (which i assumed would be harmless), deleted all of my work. Technically, if someone was particularly absurd (or just set the env variable slightly wrong in a script), this could result in killing a system. |
Thanks, I'll try to join. |
yes, i think that should ok - ie, i if we revert the change, it would be as the previous behavior was:
|
What Happened?
For legacy reasons, my environment had
MINIKUBE_HOME
explicitly specified. Prior to 1.34.0, if theMINIKUBE_HOME
path did not end with/.minikube
, all commands would functionally append/.minikube
to the path before execution. If no.minikube
directory existed in the directory specified byMINIKUBE_HOME
, the commandminikube delete --purge
would have no effect.Now, as of 1.34.0, if
MINIKUBE_HOME
is defined and does not end with/.minikube
, the commandminikube delete --purge
deletes the full directory specified byMINIKUBE_HOME
if no.minikube
directory exists within the directory. This can be extremely destructive ifMINIKUBE_HOME
is specified to a location such as the user's home folder.I verified that rolling back to 1.33.1 prevents the problem, and I reproduced the issue on Windows 10 and 11. I have not had a chance to test it on a Linux distribution.
Configuration documentation for
MINIKUBE_HOME
at the time of writing:Documentation for delete
--purge
flag at the time of writing:To reproduce:
MINIKUBE_HOME
environment variable to a location to which the logged-in user has access.minikube delete --purge
. Note: You do not need to start minikube at all for this issue to occur.The log files below were generated with
MINIKUBE_HOME
set to%HOME%\Desktop\test-minikube
.Attach the log file
1.34.0-with-.minikube-folder.txt
1.34.0-without-.minikube-folder.txt
Operating System
Windows
Driver
N/A
The text was updated successfully, but these errors were encountered: