From 1da0a370ffce69b5c21c37f0e4dd21dc41161ccb Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 17 Feb 2020 10:55:53 -0800 Subject: [PATCH] code review comments --- cmd/minikube/cmd/delete.go | 7 ++++--- pkg/drivers/kic/oci/volumes.go | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 1051cae85..1ec4093b1 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 74b84991b..e23b35c39 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) -- GitLab