From 59ef76b38823a71a589934909fece01d8f459a8e Mon Sep 17 00:00:00 2001 From: Tarishi Jain Date: Sat, 2 Dec 2023 22:55:15 +0530 Subject: [PATCH 1/3] suppress error msg --- pkg/minikube/sshagent/sshagent.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/minikube/sshagent/sshagent.go b/pkg/minikube/sshagent/sshagent.go index dc066907c339..a13e2cbfba97 100644 --- a/pkg/minikube/sshagent/sshagent.go +++ b/pkg/minikube/sshagent/sshagent.go @@ -106,6 +106,9 @@ func isRunning(cc *config.ClusterConfig) (bool, error) { func Stop(profile string) error { cc, err := config.Load(profile) if err != nil { + if strings.Contains(fmt.Sprint(err), fmt.Sprintf("cluster %q does not exist", profile)) { + return nil + } return fmt.Errorf("failed loading config: %v", err) } running, err := isRunning(cc) From 9799e5f0886d75bdfaea5089e108d01ff7fa9056 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 20 Mar 2024 14:57:45 -0700 Subject: [PATCH 2/3] use config.IsNotExist --- pkg/minikube/sshagent/sshagent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/sshagent/sshagent.go b/pkg/minikube/sshagent/sshagent.go index a13e2cbfba97..0055b340ece8 100644 --- a/pkg/minikube/sshagent/sshagent.go +++ b/pkg/minikube/sshagent/sshagent.go @@ -106,7 +106,7 @@ func isRunning(cc *config.ClusterConfig) (bool, error) { func Stop(profile string) error { cc, err := config.Load(profile) if err != nil { - if strings.Contains(fmt.Sprint(err), fmt.Sprintf("cluster %q does not exist", profile)) { + if config.IsNotExist(err) { return nil } return fmt.Errorf("failed loading config: %v", err) From e2fcc470acdcfe456dc986c99fd39c61db68fa20 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 20 Mar 2024 15:44:56 -0700 Subject: [PATCH 3/3] bubble up NotExist error --- cmd/minikube/cmd/delete.go | 2 +- pkg/minikube/sshagent/sshagent.go | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index a01a4658f0c1..96e8f7f15720 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -94,7 +94,7 @@ var hostAndDirsDeleter = func(api libmachine.API, cc *config.ClusterConfig, prof if err := killMountProcess(); err != nil { out.FailureT("Failed to kill mount process: {{.error}}", out.V{"error": err}) } - if err := sshagent.Stop(profileName); err != nil { + if err := sshagent.Stop(profileName); err != nil && !config.IsNotExist(err) { out.FailureT("Failed to stop ssh-agent process: {{.error}}", out.V{"error": err}) } diff --git a/pkg/minikube/sshagent/sshagent.go b/pkg/minikube/sshagent/sshagent.go index 0055b340ece8..73ac75876373 100644 --- a/pkg/minikube/sshagent/sshagent.go +++ b/pkg/minikube/sshagent/sshagent.go @@ -106,10 +106,7 @@ func isRunning(cc *config.ClusterConfig) (bool, error) { func Stop(profile string) error { cc, err := config.Load(profile) if err != nil { - if config.IsNotExist(err) { - return nil - } - return fmt.Errorf("failed loading config: %v", err) + return err } running, err := isRunning(cc) if err != nil {