Skip to content

IO.Cancel() becomes a no-op if the FIFOs are already opened #8326

@davidhsingyuchen

Description

@davidhsingyuchen

Description

The comment of IO.Cancel() says "Cancel aborts all current io operations", and I suppose it means stopping the goroutines in copyIO (the FIFOs will remain there, but the content will stop being copied to the provided IO streams). However, cio.Cancel() calls the cancel() function associated with the context that was passed to fifo.OpenFifo, which comment says "Context can be used to cancel this function until open(2) has not returned.", which means that IO.Cancel() becomes a no-op if the FIFOs are already opened.

Steps to reproduce the issue

t, _ := container.NewTask(ctx, cio.NewCreator(cio.WithStdio))
// After the FIFOs are created
t.IO().Cancel()
t.IO().Wait() // this blocks forever

Describe the results you received and expected

Received

IO.Cancel() becomes a no-op if the FIFOs are already opened, and IO.Wait() blocks forever as a result.

Expected

IO.Cancel() should close (not remove) the FIFOs, and IO.Wait() can be used to detect when that's done.

What version of containerd are you using?

containerd github.com/containerd/containerd v1.6.19 1e1ea6e

Any other relevant information

For more context, I'm trying to implement --detach-keys for nerdctl (containerd/nerdctl/pull/2128).

Show configuration if it is related to CRI plugin.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions