From 2175fbc16c0128d9617380338c02460d6ddd59f2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 20 May 2024 11:52:21 -0400 Subject: [PATCH] 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 --- pkg/bootc/bootc_disk.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/bootc/bootc_disk.go b/pkg/bootc/bootc_disk.go index 54aeed1..73262de 100644 --- a/pkg/bootc/bootc_disk.go +++ b/pkg/bootc/bootc_disk.go @@ -335,10 +335,14 @@ func (p *BootcDisk) runInstallContainer(quiet bool, config DiskImageConfig) (err } logrus.Debugf("Started install container") + // Ensure we've cancelled the container attachment when exiting this function, as + // it takes over stdout/stderr handling + attachCancelCtx, cancelAttach := context.WithCancel(p.Ctx) + defer cancelAttach() var exitCode int32 if !quiet { attachOpts := new(containers.AttachOptions).WithStream(true) - if err := containers.Attach(p.Ctx, p.bootcInstallContainerId, os.Stdin, os.Stdout, os.Stderr, nil, attachOpts); err != nil { + if err := containers.Attach(attachCancelCtx, p.bootcInstallContainerId, nil, os.Stdout, os.Stderr, nil, attachOpts); err != nil { return fmt.Errorf("attaching: %w", err) } }