Skip to content

Commit 2175fbc

Browse files
committed
disk: Don't pass stdin to install run, also set up cancellation
This fixes a regression in the previous commit; the attachment takes over stdin and was competing with the ssh client. We have no need for interactivity, so don't pass stdin. While we're here, also set up cancellation for the attachment so that we know the operation is done when exiting the function, as we also want to transfer ownership of stdout/stderr back. Signed-off-by: Colin Walters <[email protected]>
1 parent 7ad20a0 commit 2175fbc

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)