Skip to content

Commit 7d9f09b

Browse files
ningmingxiaok8s-infra-cherrypick-robot
authored andcommitted
bugfix:fix container logs lost because io close too quickly
Signed-off-by: ningmingxiao <[email protected]>
1 parent ffdef24 commit 7d9f09b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd/containerd-shim-runc-v2/process/exec.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/containerd/errdefs"
3636
"github.com/containerd/fifo"
3737
runc "github.com/containerd/go-runc"
38+
"github.com/containerd/log"
3839
specs "github.com/opencontainers/runtime-spec/specs-go"
3940
)
4041

@@ -106,7 +107,9 @@ func (e *execProcess) Delete(ctx context.Context) error {
106107
}
107108

108109
func (e *execProcess) delete(ctx context.Context) error {
109-
waitTimeout(ctx, &e.wg, 2*time.Second)
110+
if err := waitTimeout(ctx, &e.wg, 10*time.Second); err != nil {
111+
log.G(ctx).WithError(err).Errorf("failed to drain exec process %s io", e.id)
112+
}
110113
if e.io != nil {
111114
for _, c := range e.closers {
112115
c.Close()

cmd/containerd-shim-runc-v2/process/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ func (p *Init) Delete(ctx context.Context) error {
293293
}
294294

295295
func (p *Init) delete(ctx context.Context) error {
296-
waitTimeout(ctx, &p.wg, 2*time.Second)
296+
if err := waitTimeout(ctx, &p.wg, 10*time.Second); err != nil {
297+
log.G(ctx).WithError(err).Errorf("failed to drain init process %s io", p.id)
298+
}
297299
err := p.runtime.Delete(ctx, p.id, nil)
298300
// ignore errors if a runtime has already deleted the process
299301
// but we still hold metadata and pipes

0 commit comments

Comments
 (0)