Skip to content

Commit 7bfc98c

Browse files
test
1 parent 41c3616 commit 7bfc98c

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

hack/prow/common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ echo $PATH
176176
gotestsum --jsonfile "${JSON_OUT}" --junitfile="${JUNIT_OUT}" -f standard-verbose --raw-command -- \
177177
go tool test2json -t \
178178
${E2E_BIN} \
179+
-test.run TestScheduledStopUnix \
179180
-minikube-start-args="--driver=${DRIVER} ${EXTRA_START_ARGS}" \
180181
-test.timeout=${TIMEOUT} -test.v \
181182
${EXTRA_TEST_ARGS} \

out.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go build -tags "libvirt_dlopen" -ldflags="-X k8s.io/minikube/pkg/version.version=v1.37.0 -X k8s.io/minikube/pkg/version.isoVersion=v1.37.0-1762018871-21834 -X k8s.io/minikube/pkg/version.gitCommitID="8f3cadfdfdc7d39f951f3d645b177c153316cc08-dirty" -X k8s.io/minikube/pkg/version.storageProvisionerVersion=v5" -o out/minikube k8s.io/minikube/cmd/minikube

pkg/minikube/schedule/daemonize_unix.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ package schedule
2121
import (
2222
"fmt"
2323
"os"
24+
"os/exec"
2425
"strconv"
26+
"syscall"
2527
"time"
2628

2729
"github.com/VividCortex/godaemon"
@@ -38,11 +40,13 @@ import (
3840
func KillExisting(profiles []string, options *run.CommandOptions) {
3941
for _, profile := range profiles {
4042
if err := killPIDForProfile(profile); err != nil {
43+
fmt.Printf("error killing PID for profile %s: %v\n", profile, err)
4144
klog.Warningf("error killng PID for profile %s: %v", profile, err)
4245
}
4346
_, cc := mustload.Partial(profile, options)
4447
cc.ScheduledStop = nil
4548
if err := config.SaveProfile(profile, cc); err != nil {
49+
fmt.Printf("error saving profile for profile %s: %v\n", profile, err)
4650
klog.Errorf("error saving profile for profile %s: %v", profile, err)
4751
}
4852
}
@@ -71,9 +75,28 @@ func killPIDForProfile(profile string) error {
7175
return errors.Wrap(err, "finding process")
7276
}
7377
klog.Infof("killing process %v as it is an old scheduled stop", pid)
78+
7479
if err := p.Kill(); err != nil {
80+
klog.Errorf("error killing %v: %v", pid, err)
81+
fmt.Printf("error killing %v: %v\n", pid, err)
7582
return errors.Wrapf(err, "killing %v", pid)
7683
}
84+
for i := 0; i < 50; i++ {
85+
err := p.Signal(syscall.Signal(0))
86+
if err != nil {
87+
klog.Infof("process %v has exited", pid)
88+
fmt.Printf("process %v has exited\n", pid)
89+
return nil
90+
}
91+
time.Sleep(100 * time.Millisecond)
92+
}
93+
cmd := exec.Command("ps", "--format","pid,ppid,user,stat,%cpu,%mem,cmd")
94+
95+
cmd.Stdout = os.Stdout
96+
cmd.Stderr = os.Stderr
97+
if err := cmd.Run(); err != nil {
98+
fmt.Println("error running ps:", err)
99+
}
77100
return nil
78101
}
79102

test/integration/scheduled_stop_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestScheduledStopUnix(t *testing.T) {
9393
}
9494

9595
// schedule a second stop which should cancel the first scheduled stop
96-
stopMinikube(ctx, t, profile, []string{"--schedule", "15s"})
96+
stopMinikube(ctx, t, profile, []string{"--schedule", "15s", "-v=5", "--alsologtostderr"})
9797
if processRunning(t, pid) {
9898
t.Fatalf("process %v running but should have been killed on reschedule of stop", pid)
9999
}
@@ -138,6 +138,9 @@ func stopMinikube(ctx context.Context, t *testing.T, profile string, additionalA
138138
if err != nil {
139139
t.Fatalf("stopping minikube: %v\n%s", err, rr.Output())
140140
}
141+
fmt.Println("minikube stop output:")
142+
fmt.Println(rr.Output())
143+
141144
}
142145

143146
func checkPID(t *testing.T, profile string) string {
@@ -167,7 +170,17 @@ func processRunning(t *testing.T, pid string) bool {
167170
}
168171
err = process.Signal(syscall.Signal(0))
169172
t.Log("signal error was: ", err)
170-
return err == nil
173+
if err != nil {
174+
return false
175+
}
176+
// then check if this process has become a zombie process
177+
// which is also not running
178+
data, _ := os.ReadFile(fmt.Sprintf("/proc/%s/status", pid))
179+
if strings.Contains(string(data), "State:\tZ") {
180+
t.Logf("process %s is a zombie", pid)
181+
return false
182+
}
183+
return true
171184
}
172185
func ensureMinikubeStatus(ctx context.Context, t *testing.T, profile, key string, wantStatus string) {
173186
checkStatus := func() error {

0 commit comments

Comments
 (0)