Merge pull request #12923 from sharifelgamal/sched-ctd

fix scheduled stop test for containerd on docker driver
pull/12940/head
Medya Ghazizadeh 2021-11-11 12:45:12 -08:00 committed by GitHub
commit 75e2466cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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"