Skip to content

Commit c555e02

Browse files
authored
Merge pull request containerd#4383 from ningmingxiao/fix_health_check
bugfix:wait health check log complete
2 parents 90e0caa + 7f8422b commit c555e02

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/healthcheck/executor.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ func probeHealthCheck(ctx context.Context, task containerd.Task, hc *Healthcheck
8989
select {
9090
case <-time.After(hc.Timeout):
9191
_ = process.Kill(ctx, syscall.SIGKILL)
92-
go func() { <-exitStatusC }()
93-
92+
<-exitStatusC
93+
process.IO().Wait()
94+
process.IO().Close()
9495
msg := fmt.Sprintf("Health check exceeded timeout (%v)", hc.Timeout)
9596
if out := outputBuf.String(); len(out) > 0 {
9697
msg = fmt.Sprintf("Health check exceeded timeout (%v): %s", hc.Timeout, out)
@@ -105,6 +106,8 @@ func probeHealthCheck(ctx context.Context, task containerd.Task, hc *Healthcheck
105106
}, nil
106107

107108
case exitStatus := <-exitStatusC:
109+
process.IO().Wait()
110+
process.IO().Close()
108111
code, _, _ := exitStatus.Result()
109112
return &HealthcheckResult{
110113
ExitCode: int(code),

0 commit comments

Comments
 (0)