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

Delete subnode's machine directories #9955

Merged
merged 1 commit into from
Dec 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/minikube/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ func deleteProfile(profile *config.Profile) error {

// In case DeleteHost didn't complete the job.
deleteProfileDirectory(profile.Name)
deleteMachineDirectories(cc)

if err := deleteConfig(profile.Name); err != nil {
return err
Expand Down Expand Up @@ -496,6 +497,15 @@ func deleteProfileDirectory(profile string) {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for finding out this ! we were not cleaning up the machine folder for multi node

I wonder if there are other places that we are missing this

for example
in func demolish

https://github.com/medyagh/minikube/blob/75cd17801287339a00efe44fbd451b4dbfadef86/pkg/minikube/machine/delete.go#L122

is there a chance we could add this delete Machine directory to wherever it is doing for the single node ?

my undrestanding is, for single node delete the machine folder correctly but for multinode we are not.
is there any other place in the code we could do this ? (as opposed to a deffered clean up?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for the single node, it looks DeleteHost not remove directory.
It's handled by deleteProfileDirectory

// In case DeleteHost didn't complete the job.
deleteProfileDirectory(profile.Name)

❯ minikube start -p test-profile
😄  [test-profile] minikube v1.16.0 on Darwin 10.15.7
✨  Automatically selected the docker driver
👍  Starting control plane node test-profile in cluster test-profile
🔥  Creating docker container (CPUs=2, Memory=1988MB) ...
🐳  Preparing Kubernetes v1.20.0 on Docker 20.10.0 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "test-profile" cluster and "default" namespace by default
❯ minikube delete -p test-profile
🔥  Deleting "test-profile" in docker ...
🔥  Deleting container "test-profile" ...
🔥  Removing /Users/daehyeok/.minikube/machines/test-profile ...
💀  Removed all traces of the "test-profile" cluster.

🔥 Removing /Users/daehyeok/.minikube/machines/test-profile ... this line printed by deleteProfileDirectory

func deleteProfileDirectory(profile string) {
machineDir := filepath.Join(localpath.MiniPath(), "machines", profile)
if _, err := os.Stat(machineDir); err == nil {
out.Step(style.DeletingHost, `Removing {{.directory}} ...`, out.V{"directory": machineDir})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a good idea ! @daehyeok .
admitably our delete code is the messiest and worst part of minikube code (huge huge huge chance for BIG refactor)
once we had an idea to break down the delete code in the CMD package into package.

}

func deleteMachineDirectories(cc *config.ClusterConfig) {
if cc != nil {
for _, n := range cc.Nodes {
machineName := driver.MachineName(*cc, n)
deleteProfileDirectory(machineName)
}
}
}

// killMountProcess kills the mount process, if it is running
func killMountProcess() error {
pidPath := filepath.Join(localpath.MiniPath(), constants.MountProcessFileName)
Expand Down