From 65a26184852494eb5e963e0dbf7ab600f5ebc871 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Wed, 7 Oct 2020 22:00:26 +0100 Subject: [PATCH 1/2] delete context when minikube is stopped --- cmd/minikube/cmd/stop.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/minikube/cmd/stop.go b/cmd/minikube/cmd/stop.go index dc595cff91..a4cb95616e 100644 --- a/cmd/minikube/cmd/stop.go +++ b/cmd/minikube/cmd/stop.go @@ -115,8 +115,8 @@ func stopProfile(profile string) int { } if !keepActive { - if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil { - exit.Error(reason.HostKubeconfigUnset, "update config", err) + if err := kubeconfig.DeleteContext(profile, kubeconfig.PathFromEnv()); err != nil { + exit.Error(reason.HostKubeconfigUpdate, "update config", err) } } From c63de60aba5682ae564289a1f5017e66ed82155f Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Wed, 7 Oct 2020 22:58:20 +0100 Subject: [PATCH 2/2] add HostKubeconfigDeleteCtx Reason Exit --- cmd/minikube/cmd/stop.go | 2 +- pkg/minikube/reason/reason.go | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/minikube/cmd/stop.go b/cmd/minikube/cmd/stop.go index a4cb95616e..c5a52f4243 100644 --- a/cmd/minikube/cmd/stop.go +++ b/cmd/minikube/cmd/stop.go @@ -116,7 +116,7 @@ func stopProfile(profile string) int { if !keepActive { if err := kubeconfig.DeleteContext(profile, kubeconfig.PathFromEnv()); err != nil { - exit.Error(reason.HostKubeconfigUpdate, "update config", err) + exit.Error(reason.HostKubeconfigDeleteCtx, "delete ctx", err) } } diff --git a/pkg/minikube/reason/reason.go b/pkg/minikube/reason/reason.go index 497f54cfa7..91df1b4787 100644 --- a/pkg/minikube/reason/reason.go +++ b/pkg/minikube/reason/reason.go @@ -199,17 +199,18 @@ var ( Issues: []int{9165}, } - HostCurrentUser = Kind{ID: "HOST_CURRENT_USER", ExitCode: ExHostConfig} - HostDelCache = Kind{ID: "HOST_DEL_CACHE", ExitCode: ExHostError} - HostKillMountProc = Kind{ID: "HOST_KILL_MOUNT_PROC", ExitCode: ExHostError} - HostKubeconfigUnset = Kind{ID: "HOST_KUBECNOFIG_UNSET", ExitCode: ExHostConfig} - HostKubeconfigUpdate = Kind{ID: "HOST_KUBECONFIG_UPDATE", ExitCode: ExHostConfig} - HostKubectlProxy = Kind{ID: "HOST_KUBECTL_PROXY", ExitCode: ExHostError} - HostMountPid = Kind{ID: "HOST_MOUNT_PID", ExitCode: ExHostError} - HostPathMissing = Kind{ID: "HOST_PATH_MISSING", ExitCode: ExHostNotFound} - HostPathStat = Kind{ID: "HOST_PATH_STAT", ExitCode: ExHostError} - HostPurge = Kind{ID: "HOST_PURGE", ExitCode: ExHostError} - HostSaveProfile = Kind{ID: "HOST_SAVE_PROFILE", ExitCode: ExHostConfig} + HostCurrentUser = Kind{ID: "HOST_CURRENT_USER", ExitCode: ExHostConfig} + HostDelCache = Kind{ID: "HOST_DEL_CACHE", ExitCode: ExHostError} + HostKillMountProc = Kind{ID: "HOST_KILL_MOUNT_PROC", ExitCode: ExHostError} + HostKubeconfigUnset = Kind{ID: "HOST_KUBECNOFIG_UNSET", ExitCode: ExHostConfig} + HostKubeconfigUpdate = Kind{ID: "HOST_KUBECONFIG_UPDATE", ExitCode: ExHostConfig} + HostKubeconfigDeleteCtx = Kind{ID: "HOST_KUBECONFIG_DELETE_CTX", ExitCode: ExHostConfig} + HostKubectlProxy = Kind{ID: "HOST_KUBECTL_PROXY", ExitCode: ExHostError} + HostMountPid = Kind{ID: "HOST_MOUNT_PID", ExitCode: ExHostError} + HostPathMissing = Kind{ID: "HOST_PATH_MISSING", ExitCode: ExHostNotFound} + HostPathStat = Kind{ID: "HOST_PATH_STAT", ExitCode: ExHostError} + HostPurge = Kind{ID: "HOST_PURGE", ExitCode: ExHostError} + HostSaveProfile = Kind{ID: "HOST_SAVE_PROFILE", ExitCode: ExHostConfig} ProviderNotFound = Kind{ID: "PROVIDER_NOT_FOUND", ExitCode: ExProviderNotFound} ProviderUnavailable = Kind{ID: "PROVIDER_UNAVAILABLE", ExitCode: ExProviderNotFound, Style: style.Shrug}