diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 1051cae854c8259c5744322dc382c9f4b54095c7..1ec4093b13b32c9f5c46e7038c8711556d919798 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -97,9 +97,10 @@ func runDelete(cmd *cobra.Command, args []string) { profileFlag := viper.GetString(config.MachineProfile) validProfiles, invalidProfiles, err := pkg_config.ListProfiles() + glog.Warningf("Couldn't find any profiles in minikube home %q: %v", localpath.MiniPath(), err) profilesToDelete := append(validProfiles, invalidProfiles...) - glog.Infof("error listing profiless %v", err) - // If the purge flag is set, go ahead and delete the .minikube directory. + // in the case user has more than 1 profile and runs --purge + // to prevent abandoned VMs/containers, force user to run with delete --all if purge && len(profilesToDelete) > 1 && !deleteAll { out.ErrT(out.Notice, "Multiple minikube profiles were found - ") for _, p := range profilesToDelete { @@ -115,7 +116,7 @@ func runDelete(cmd *cobra.Command, args []string) { err := oci.DeleteAllVolumesByLabel(oci.Docker, fmt.Sprintf("%s=%s", oci.CreatedByLabelKey, "=true")) if err != nil { // if there is no volume there won't be any error - glog.Warningf("error deleting left docker volumes. To see the list of volumes run: 'docker volume ls' \n%v:", err) + glog.Warningf("error deleting left docker volumes. \n%v:\nfor more information please refer to docker documentation: https://docs.docker.com/engine/reference/commandline/volume_prune/", err) } errs := DeleteProfiles(profilesToDelete) diff --git a/pkg/drivers/kic/oci/volumes.go b/pkg/drivers/kic/oci/volumes.go index 74b84991bf95ca7f8853613366bcc9464016053d..e23b35c394dbaa0805f890a3036dfad8f6dc649a 100644 --- a/pkg/drivers/kic/oci/volumes.go +++ b/pkg/drivers/kic/oci/volumes.go @@ -23,7 +23,8 @@ import ( "github.com/pkg/errors" ) -// DeleteAllVolumesByLabel delets all volumes that have a specific label +// DeleteAllVolumesByLabel deletes all volumes that have a specific label +// if there is no volume to delete it will return nil // example: docker volume prune -f --filter label=name.minikube.sigs.k8s.io=minikube func DeleteAllVolumesByLabel(ociBin string, label string) error { glog.Infof("trying to prune all %s volumes with label %s", ociBin, label)