Skip to content

Commit f0597fc

Browse files
committed
fix rebase
1 parent b34ee64 commit f0597fc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cli/docker.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func dockerCmd() *cobra.Command {
167167
)
168168

169169
// We technically leak a context here, but it's impact is negligible.
170-
signalCtx, signalCancel := context.WithCancel(cmd.Context())
170+
signalCtx, signalCancel := context.WithCancel(ctx)
171171
sigs := make(chan os.Signal, 1)
172172
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGWINCH)
173173

@@ -179,8 +179,6 @@ func dockerCmd() *cobra.Command {
179179
log.Info(ctx, "got signal, canceling context")
180180
}()
181181

182-
cmd.SetContext(ctx)
183-
184182
if flags.noStartupLogs {
185183
log = slog.Make(slogjson.Sink(io.Discard))
186184
blog = buildlog.NopLogger{}
@@ -827,15 +825,19 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Client
827825

828826
go func() {
829827
defer resp.Close()
828+
go func() {
829+
// Also close the response reader when the context is canceled.
830+
defer resp.Close()
831+
<-ctx.Done()
832+
}()
830833
rd := io.LimitReader(resp.Reader, 1<<10)
831834
_, err := io.Copy(blog, rd)
832835
if err != nil {
833836
log.Error(ctx, "copy bootstrap output", slog.Error(err))
834837
}
838+
log.Debug(ctx, "bootstrap output copied")
835839
}()
836840

837-
// We can't just call ExecInspect because there's a race where the cmd
838-
// hasn't been assigned a PID yet.
839841
return bootstrapExec.ID, nil
840842
}
841843

0 commit comments

Comments
 (0)