diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 2b9289bc22..968be90c2f 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -691,6 +691,11 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC cc.KicBaseImage = viper.GetString(kicBaseImage) } + // If this cluster was stopped by a scheduled stop, clear the config + if cc.ScheduledStop != nil && time.Until(time.Unix(cc.ScheduledStop.InitiationTime, 0).Add(cc.ScheduledStop.Duration)) <= 0 { + cc.ScheduledStop = nil + } + return cc } diff --git a/pkg/minikube/schedule/daemonize_unix.go b/pkg/minikube/schedule/daemonize_unix.go index 2544fdd651..83aeb907a0 100644 --- a/pkg/minikube/schedule/daemonize_unix.go +++ b/pkg/minikube/schedule/daemonize_unix.go @@ -38,7 +38,7 @@ import ( func KillExisting(profiles []string) { for _, profile := range profiles { if err := killPIDForProfile(profile); err != nil { - klog.Errorf("error killng PID for profile %s: %v", profile, err) + klog.Warningf("error killng PID for profile %s: %v", profile, err) } _, cc := mustload.Partial(profile) cc.ScheduledStop = nil diff --git a/test/integration/scheduled_stop_test.go b/test/integration/scheduled_stop_test.go index de5183cd00..33b95e3da8 100644 --- a/test/integration/scheduled_stop_test.go +++ b/test/integration/scheduled_stop_test.go @@ -94,29 +94,30 @@ func TestScheduledStopUnix(t *testing.T) { } // schedule a second stop which should cancel the first scheduled stop - stopMinikube(ctx, t, profile, []string{"--schedule", "8s"}) + stopMinikube(ctx, t, profile, []string{"--schedule", "15s"}) if processRunning(t, pid) { t.Fatalf("process %v running but should have been killed on reschedule of stop", pid) } - checkPID(t, profile) + pid = checkPID(t, profile) // cancel the shutdown and make sure minikube is still running after 8 seconds // sleep 12 just to be safe stopMinikube(ctx, t, profile, []string{"--cancel-scheduled"}) - time.Sleep(12 * time.Second) + time.Sleep(25 * time.Second) // make sure minikube status is "Running" ensureMinikubeStatus(ctx, t, profile, "Host", state.Running.String()) // make sure minikube timetoStop is not present ensureTimeToStopNotPresent(ctx, t, profile) // schedule another stop, make sure minikube status is "Stopped" - stopMinikube(ctx, t, profile, []string{"--schedule", "5s"}) + stopMinikube(ctx, t, profile, []string{"--schedule", "15s"}) + time.Sleep(15 * time.Second) if processRunning(t, pid) { t.Fatalf("process %v running but should have been killed on reschedule of stop", pid) } // wait for stop to complete - time.Sleep(25 * time.Second) + time.Sleep(30 * time.Second) // make sure minikube timetoStop is not present ensureTimeToStopNotPresent(ctx, t, profile) // make sure minikube status is "Stopped"