Skip to content

Commit c7ee261

Browse files
authored
Merge pull request #41 from cgwalters/attach-cancel
disk: Don't pass stdin to install run, also set up cancellation
2 parents 7ad20a0 + 2175fbc commit c7ee261

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/bootc/bootc_disk.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,14 @@ func (p *BootcDisk) runInstallContainer(quiet bool, config DiskImageConfig) (err
335335
}
336336
logrus.Debugf("Started install container")
337337

338+
// Ensure we've cancelled the container attachment when exiting this function, as
339+
// it takes over stdout/stderr handling
340+
attachCancelCtx, cancelAttach := context.WithCancel(p.Ctx)
341+
defer cancelAttach()
338342
var exitCode int32
339343
if !quiet {
340344
attachOpts := new(containers.AttachOptions).WithStream(true)
341-
if err := containers.Attach(p.Ctx, p.bootcInstallContainerId, os.Stdin, os.Stdout, os.Stderr, nil, attachOpts); err != nil {
345+
if err := containers.Attach(attachCancelCtx, p.bootcInstallContainerId, nil, os.Stdout, os.Stderr, nil, attachOpts); err != nil {
342346
return fmt.Errorf("attaching: %w", err)
343347
}
344348
}

0 commit comments

Comments
 (0)