From d02eabb8354e50ec90156b88b939784ade16ecc3 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 1 Feb 2021 12:44:43 -0800 Subject: [PATCH 1/7] Add 2 minute timeout to deleting a profile --- cmd/minikube/cmd/delete.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index dbc4bd47fd..e2c9f4829a 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -23,6 +23,7 @@ import ( "os/exec" "path/filepath" "strconv" + "time" "github.com/docker/machine/libmachine/mcnerror" "github.com/mitchellh/go-ps" @@ -206,7 +207,7 @@ func DeleteProfiles(profiles []*config.Profile) []error { klog.Infof("DeleteProfiles") var errs []error for _, profile := range profiles { - err := deleteProfile(profile) + err := timedDeleteProfile(2*time.Minute, profile) if err != nil { mm, loadErr := machine.LoadMachine(profile.Name) @@ -276,6 +277,34 @@ func deletePossibleKicLeftOver(cname string, driverName string) { } } +// timedDeleteProfile puts a time limit on deleting a profile +func timedDeleteProfile(timeoutDuration time.Duration, profile *config.Profile) error { + timeout := make(chan bool, 1) + go func() { + time.Sleep(timeoutDuration) + timeout <- true + }() + + createFinished := make(chan bool, 1) + var err error + go func() { + err = deleteProfile(profile) + createFinished <- true + }() + + select { + case <-createFinished: + if err != nil { + // Wait for all the logs to reach the client + time.Sleep(2 * time.Second) + return errors.Wrap(err, "create") + } + return nil + case <-timeout: + return fmt.Errorf("deleting profile %s timed out in %f seconds", profile.Name, timeoutDuration.Seconds()) + } +} + func deleteProfile(profile *config.Profile) error { klog.Infof("Deleting %s", profile.Name) register.Reg.SetStep(register.Deleting) From 4bda151a6219613b39a63f0dfeb06f10353ebd59 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 1 Feb 2021 12:47:46 -0800 Subject: [PATCH 2/7] Fix delete var --- cmd/minikube/cmd/delete.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index e2c9f4829a..60eda7b8a0 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -285,19 +285,19 @@ func timedDeleteProfile(timeoutDuration time.Duration, profile *config.Profile) timeout <- true }() - createFinished := make(chan bool, 1) + deleteFinished := make(chan bool, 1) var err error go func() { err = deleteProfile(profile) - createFinished <- true + deleteFinished <- true }() select { - case <-createFinished: + case <-deleteFinished: if err != nil { // Wait for all the logs to reach the client time.Sleep(2 * time.Second) - return errors.Wrap(err, "create") + return errors.Wrap(err, "delete") } return nil case <-timeout: From a6372b35a3909079c6b9890e567dba189dbb963b Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 8 Feb 2021 15:15:08 -0800 Subject: [PATCH 3/7] Add 5 minute timeout to deleting leftover cvolumes and containers --- cmd/minikube/cmd/delete.go | 10 ++++++---- pkg/drivers/kic/kic.go | 5 +++-- pkg/drivers/kic/oci/oci.go | 14 +++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 60eda7b8a0..7f0c1f4529 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -17,6 +17,7 @@ limitations under the License. package cmd import ( + "context" "fmt" "io/ioutil" "os" @@ -241,14 +242,15 @@ func deletePossibleKicLeftOver(cname string, driverName string) { return } - klog.Infof("deleting possible KIC leftovers for %s (driver=%s) ...", cname, driverName) - + klog.Infof("deleting possible KIC leftovers for %s (driver=%s) with timeout of 5m...", cname, driverName) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() delLabel := fmt.Sprintf("%s=%s", oci.ProfileLabelKey, cname) - cs, err := oci.ListContainersByLabel(bin, delLabel) + cs, err := oci.ListContainersByLabel(ctx, bin, delLabel) if err == nil && len(cs) > 0 { for _, c := range cs { out.Step(style.DeletingHost, `Deleting container "{{.name}}" ...`, out.V{"name": cname}) - err := oci.DeleteContainer(bin, c) + err := oci.DeleteContainer(ctx, bin, c) if err != nil { // it will error if there is no container to delete klog.Errorf("error deleting container %q. You may want to delete it manually :\n%v", cname, err) } diff --git a/pkg/drivers/kic/kic.go b/pkg/drivers/kic/kic.go index 9cbc9152b5..a3b16f5e45 100644 --- a/pkg/drivers/kic/kic.go +++ b/pkg/drivers/kic/kic.go @@ -72,6 +72,7 @@ func NewDriver(c Config) *Driver { // Create a host using the driver's config func (d *Driver) Create() error { + ctx := context.Background() params := oci.CreateParams{ Mounts: d.NodeConfig.Mounts, Name: d.NodeConfig.MachineName, @@ -136,7 +137,7 @@ func (d *Driver) Create() error { // if container was created by minikube it is safe to delete and recreate it. if oci.IsCreatedByMinikube(d.OCIBinary, params.Name) { klog.Info("Found already existing abandoned minikube container, will try to delete.") - if err := oci.DeleteContainer(d.OCIBinary, params.Name); err != nil { + if err := oci.DeleteContainer(ctx, d.OCIBinary, params.Name); err != nil { klog.Errorf("Failed to delete a conflicting minikube container %s. You might need to restart your %s daemon and delete it manually and try again: %v", params.Name, params.OCIBinary, err) } } else { @@ -338,7 +339,7 @@ func (d *Driver) Remove() error { klog.Infof("could not find the container %s to remove it. will try anyways", d.MachineName) } - if err := oci.DeleteContainer(d.NodeConfig.OCIBinary, d.MachineName); err != nil { + if err := oci.DeleteContainer(context.Background(), d.NodeConfig.OCIBinary, d.MachineName); err != nil { if strings.Contains(err.Error(), "is already in progress") { return errors.Wrap(err, "stuck delete") } diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index 1a66f0f15e..27f7a49a73 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -43,8 +43,8 @@ import ( // if there no containers found with the given label, it will return nil func DeleteContainersByLabel(ociBin string, label string) []error { var deleteErrs []error - - cs, err := ListContainersByLabel(ociBin, label) + ctx := context.Background() + cs, err := ListContainersByLabel(ctx, ociBin, label) if err != nil { return []error{fmt.Errorf("listing containers by label %q", label)} } @@ -75,7 +75,7 @@ func DeleteContainersByLabel(ociBin string, label string) []error { } // DeleteContainer deletes a container by ID or Name -func DeleteContainer(ociBin string, name string) error { +func DeleteContainer(ctx context.Context, ociBin string, name string) error { _, err := ContainerStatus(ociBin, name) if err == context.DeadlineExceeded { out.WarningT("{{.ocibin}} is taking an unsually long time to respond, consider restarting {{.ocibin}}", out.V{"ociBin": ociBin}) @@ -87,7 +87,7 @@ func DeleteContainer(ociBin string, name string) error { klog.Infof("couldn't shut down %s (might be okay): %v ", name, err) } - if _, err := runCmd(exec.Command(ociBin, "rm", "-f", "-v", name)); err != nil { + if _, err := runCmd(exec.CommandContext(ctx, ociBin, "rm", "-f", "-v", name)); err != nil { return errors.Wrapf(err, "delete %s", name) } return nil @@ -373,7 +373,7 @@ func IsCreatedByMinikube(ociBin string, nameOrID string) bool { // ListOwnedContainers lists all the containres that kic driver created on user's machine using a label func ListOwnedContainers(ociBin string) ([]string, error) { - return ListContainersByLabel(ociBin, ProfileLabelKey) + return ListContainersByLabel(context.Background(), ociBin, ProfileLabelKey) } // inspect return low-level information on containers @@ -503,8 +503,8 @@ func withPortMappings(portMappings []PortMapping) createOpt { } // ListContainersByLabel returns all the container names with a specified label -func ListContainersByLabel(ociBin string, label string, warnSlow ...bool) ([]string, error) { - rr, err := runCmd(exec.Command(ociBin, "ps", "-a", "--filter", fmt.Sprintf("label=%s", label), "--format", "{{.Names}}"), warnSlow...) +func ListContainersByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) ([]string, error) { + rr, err := runCmd(exec.CommandContext(ctx, ociBin, "ps", "-a", "--filter", fmt.Sprintf("label=%s", label), "--format", "{{.Names}}"), warnSlow...) if err != nil { return nil, err } From 51169d68eab11f3a573baca10b9e2cd244091268 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 8 Feb 2021 15:19:01 -0800 Subject: [PATCH 4/7] Add context to remaining necessary functions --- cmd/minikube/cmd/delete.go | 9 +++++---- pkg/drivers/kic/oci/volumes.go | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 7f0c1f4529..d961b3337e 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -110,7 +110,8 @@ func deleteContainersAndVolumes(ociBin string) { klog.Infof("error delete containers by label %q (might be okay): %+v", delLabel, errs) } - errs = oci.DeleteAllVolumesByLabel(ociBin, delLabel) + ctx := context.Background() + errs = oci.DeleteAllVolumesByLabel(ctx, ociBin, delLabel) if len(errs) > 0 { // it will not error if there is nothing to delete klog.Warningf("error delete volumes by label %q (might be okay): %+v", delLabel, errs) } @@ -120,7 +121,7 @@ func deleteContainersAndVolumes(ociBin string) { return } - errs = oci.PruneAllVolumesByLabel(ociBin, delLabel) + errs = oci.PruneAllVolumesByLabel(ctx, ociBin, delLabel) if len(errs) > 0 { // it will not error if there is nothing to delete klog.Warningf("error pruning volumes by label %q (might be okay): %+v", delLabel, errs) } @@ -258,7 +259,7 @@ func deletePossibleKicLeftOver(cname string, driverName string) { } } - errs := oci.DeleteAllVolumesByLabel(bin, delLabel) + errs := oci.DeleteAllVolumesByLabel(ctx, bin, delLabel) if errs != nil { // it will not error if there is nothing to delete klog.Warningf("error deleting volumes (might be okay).\nTo see the list of volumes run: 'docker volume ls'\n:%v", errs) } @@ -273,7 +274,7 @@ func deletePossibleKicLeftOver(cname string, driverName string) { return } - errs = oci.PruneAllVolumesByLabel(bin, delLabel) + errs = oci.PruneAllVolumesByLabel(ctx, bin, delLabel) if len(errs) > 0 { // it will not error if there is nothing to delete klog.Warningf("error pruning volume (might be okay):\n%v", errs) } diff --git a/pkg/drivers/kic/oci/volumes.go b/pkg/drivers/kic/oci/volumes.go index 5a6ff27d75..a32492892e 100644 --- a/pkg/drivers/kic/oci/volumes.go +++ b/pkg/drivers/kic/oci/volumes.go @@ -19,6 +19,7 @@ package oci import ( "bufio" "bytes" + "context" "fmt" "os/exec" "runtime" @@ -31,7 +32,7 @@ import ( // DeleteAllVolumesByLabel deletes all volumes that have a specific label // if there is no volume to delete it will return nil -func DeleteAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []error { +func DeleteAllVolumesByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) []error { var deleteErrs []error klog.Infof("trying to delete all %s volumes with label %s", ociBin, label) @@ -42,7 +43,7 @@ func DeleteAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []er } for _, v := range vs { - if _, err := runCmd(exec.Command(ociBin, "volume", "rm", "--force", v), warnSlow...); err != nil { + if _, err := runCmd(exec.CommandContext(ctx, ociBin, "volume", "rm", "--force", v), warnSlow...); err != nil { deleteErrs = append(deleteErrs, fmt.Errorf("deleting %q", v)) } } @@ -53,10 +54,10 @@ func DeleteAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []er // PruneAllVolumesByLabel 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 PruneAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []error { +func PruneAllVolumesByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) []error { var deleteErrs []error klog.Infof("trying to prune all %s volumes with label %s", ociBin, label) - cmd := exec.Command(ociBin, "volume", "prune", "-f", "--filter", "label="+label) + cmd := exec.CommandContext(ctx, ociBin, "volume", "prune", "-f", "--filter", "label="+label) if _, err := runCmd(cmd, warnSlow...); err != nil { deleteErrs = append(deleteErrs, errors.Wrapf(err, "prune volume by label %s", label)) } From 8f02a5851e24785e65a028259e7ad53509bebd77 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 8 Feb 2021 15:24:41 -0800 Subject: [PATCH 5/7] Time everything via context --- cmd/minikube/cmd/delete.go | 46 +++++++-------------------------- cmd/minikube/cmd/node_delete.go | 7 ++++- cmd/minikube/cmd/start.go | 9 ++++--- 3 files changed, 21 insertions(+), 41 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index d961b3337e..a71b3fc330 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -166,6 +166,8 @@ func runDelete(cmd *cobra.Command, args []string) { if len(args) > 0 { exit.Message(reason.Usage, "usage: minikube delete") } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() cname := ClusterFlagValue() profile, err := config.LoadProfile(cname) @@ -185,8 +187,8 @@ func runDelete(cmd *cobra.Command, args []string) { if orphan { // TODO: generalize for non-KIC drivers: #8040 - deletePossibleKicLeftOver(cname, driver.Docker) - deletePossibleKicLeftOver(cname, driver.Podman) + deletePossibleKicLeftOver(ctx, cname, driver.Docker) + deletePossibleKicLeftOver(ctx, cname, driver.Podman) } } @@ -209,7 +211,9 @@ func DeleteProfiles(profiles []*config.Profile) []error { klog.Infof("DeleteProfiles") var errs []error for _, profile := range profiles { - err := timedDeleteProfile(2*time.Minute, profile) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + err := deleteProfile(ctx, profile) if err != nil { mm, loadErr := machine.LoadMachine(profile.Name) @@ -227,7 +231,7 @@ func DeleteProfiles(profiles []*config.Profile) []error { } // TODO: remove and/or move to delete package: #8040 -func deletePossibleKicLeftOver(cname string, driverName string) { +func deletePossibleKicLeftOver(ctx context.Context, cname string, driverName string) { bin := "" switch driverName { case driver.Docker: @@ -244,8 +248,6 @@ func deletePossibleKicLeftOver(cname string, driverName string) { } klog.Infof("deleting possible KIC leftovers for %s (driver=%s) with timeout of 5m...", cname, driverName) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) - defer cancel() delLabel := fmt.Sprintf("%s=%s", oci.ProfileLabelKey, cname) cs, err := oci.ListContainersByLabel(ctx, bin, delLabel) if err == nil && len(cs) > 0 { @@ -280,35 +282,7 @@ func deletePossibleKicLeftOver(cname string, driverName string) { } } -// timedDeleteProfile puts a time limit on deleting a profile -func timedDeleteProfile(timeoutDuration time.Duration, profile *config.Profile) error { - timeout := make(chan bool, 1) - go func() { - time.Sleep(timeoutDuration) - timeout <- true - }() - - deleteFinished := make(chan bool, 1) - var err error - go func() { - err = deleteProfile(profile) - deleteFinished <- true - }() - - select { - case <-deleteFinished: - if err != nil { - // Wait for all the logs to reach the client - time.Sleep(2 * time.Second) - return errors.Wrap(err, "delete") - } - return nil - case <-timeout: - return fmt.Errorf("deleting profile %s timed out in %f seconds", profile.Name, timeoutDuration.Seconds()) - } -} - -func deleteProfile(profile *config.Profile) error { +func deleteProfile(ctx context.Context, profile *config.Profile) error { klog.Infof("Deleting %s", profile.Name) register.Reg.SetStep(register.Deleting) @@ -321,7 +295,7 @@ func deleteProfile(profile *config.Profile) error { out.Step(style.DeletingHost, `Deleting "{{.profile_name}}" in {{.driver_name}} ...`, out.V{"profile_name": profile.Name, "driver_name": profile.Config.Driver}) for _, n := range profile.Config.Nodes { machineName := config.MachineName(*profile.Config, n) - deletePossibleKicLeftOver(machineName, profile.Config.Driver) + deletePossibleKicLeftOver(ctx, machineName, profile.Config.Driver) } } } else { diff --git a/cmd/minikube/cmd/node_delete.go b/cmd/minikube/cmd/node_delete.go index 56e14d9e2d..8701bb236f 100644 --- a/cmd/minikube/cmd/node_delete.go +++ b/cmd/minikube/cmd/node_delete.go @@ -17,6 +17,9 @@ limitations under the License. package cmd import ( + "context" + "time" + "github.com/spf13/cobra" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/driver" @@ -48,7 +51,9 @@ var nodeDeleteCmd = &cobra.Command{ if driver.IsKIC(co.Config.Driver) { machineName := config.MachineName(*co.Config, *n) - deletePossibleKicLeftOver(machineName, co.Config.Driver) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + deletePossibleKicLeftOver(ctx, machineName, co.Config.Driver) } out.Step(style.Deleted, "Node {{.name}} was successfully deleted.", out.V{"name": name}) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 08b9b0a212..edf48e1633 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -17,6 +17,7 @@ limitations under the License. package cmd import ( + "context" "encoding/json" "fmt" "math" @@ -130,7 +131,7 @@ func platform() string { // runStart handles the executes the flow of "minikube start" func runStart(cmd *cobra.Command, args []string) { register.SetEventLogPath(localpath.EventLog(ClusterFlagValue())) - + ctx := context.Background() out.SetJSON(outputFormat == "json") if err := pkgtrace.Initialize(viper.GetString(trace)); err != nil { exit.Message(reason.Usage, "error initializing tracing: {{.Error}}", out.V{"Error": err.Error()}) @@ -219,7 +220,7 @@ func runStart(cmd *cobra.Command, args []string) { klog.Warningf("%s profile does not exist, trying anyways.", ClusterFlagValue()) } - err = deleteProfile(profile) + err = deleteProfile(ctx, profile) if err != nil { out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": ClusterFlagValue()}) } @@ -482,7 +483,7 @@ func maybeDeleteAndRetry(cmd *cobra.Command, existing config.ClusterConfig, n co out.ErrT(style.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": existing.Name}) } - err = deleteProfile(profile) + err = deleteProfile(context.Background(), profile) if err != nil { out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": existing.Name}) } @@ -697,7 +698,7 @@ func validateSpecifiedDriver(existing *config.ClusterConfig) { out.ErrT(style.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": existing.Name}) } - err = deleteProfile(profile) + err = deleteProfile(context.Background(), profile) if err != nil { out.WarningT("Failed to delete cluster {{.name}}.", out.V{"name": existing.Name}) } From 53dad6a4ae7f6c8b24fa99b5f97a7f94fd2e6618 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 8 Feb 2021 15:26:04 -0800 Subject: [PATCH 6/7] fix log --- cmd/minikube/cmd/delete.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index a71b3fc330..a010572848 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -247,7 +247,7 @@ func deletePossibleKicLeftOver(ctx context.Context, cname string, driverName str return } - klog.Infof("deleting possible KIC leftovers for %s (driver=%s) with timeout of 5m...", cname, driverName) + klog.Infof("deleting possible KIC leftovers for %s (driver=%s) ...", cname, driverName) delLabel := fmt.Sprintf("%s=%s", oci.ProfileLabelKey, cname) cs, err := oci.ListContainersByLabel(ctx, bin, delLabel) if err == nil && len(cs) > 0 { From 6ed56d842e4e7865f8dc30967a7c1f91ade91393 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 9 Feb 2021 10:51:51 -0800 Subject: [PATCH 7/7] Rename to delCtx --- cmd/minikube/cmd/delete.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index a010572848..09c8ae4d58 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -96,7 +96,7 @@ func init() { } // shotgun cleanup to delete orphaned docker container data -func deleteContainersAndVolumes(ociBin string) { +func deleteContainersAndVolumes(ctx context.Context, ociBin string) { if _, err := exec.LookPath(ociBin); err != nil { klog.Infof("skipping deleteContainersAndVolumes for %s: %v", ociBin, err) return @@ -110,7 +110,6 @@ func deleteContainersAndVolumes(ociBin string) { klog.Infof("error delete containers by label %q (might be okay): %+v", delLabel, errs) } - ctx := context.Background() errs = oci.DeleteAllVolumesByLabel(ctx, ociBin, delLabel) if len(errs) > 0 { // it will not error if there is nothing to delete klog.Warningf("error delete volumes by label %q (might be okay): %+v", delLabel, errs) @@ -149,10 +148,12 @@ func runDelete(cmd *cobra.Command, args []string) { } exit.Message(reason.Usage, "Usage: minikube delete --all --purge") } + delCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() if deleteAll { - deleteContainersAndVolumes(oci.Docker) - deleteContainersAndVolumes(oci.Podman) + deleteContainersAndVolumes(delCtx, oci.Docker) + deleteContainersAndVolumes(delCtx, oci.Podman) errs := DeleteProfiles(profilesToDelete) register.Reg.SetStep(register.Done) @@ -166,8 +167,6 @@ func runDelete(cmd *cobra.Command, args []string) { if len(args) > 0 { exit.Message(reason.Usage, "usage: minikube delete") } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) - defer cancel() cname := ClusterFlagValue() profile, err := config.LoadProfile(cname) @@ -187,8 +186,8 @@ func runDelete(cmd *cobra.Command, args []string) { if orphan { // TODO: generalize for non-KIC drivers: #8040 - deletePossibleKicLeftOver(ctx, cname, driver.Docker) - deletePossibleKicLeftOver(ctx, cname, driver.Podman) + deletePossibleKicLeftOver(delCtx, cname, driver.Docker) + deletePossibleKicLeftOver(delCtx, cname, driver.Podman) } }