Skip to content

exec: wait for I/O completion before return - #4392

Merged
fahedouch merged 1 commit into
containerd:mainfrom
swagatbora90:wait_for_process_io
Jul 1, 2025
Merged

fahedouch merged 1 commit into
containerd:mainfrom
swagatbora90:wait_for_process_io

Conversation

@swagatbora90

Copy link
Copy Markdown
Contributor

Fixes #4380

@swagatbora90

Copy link
Copy Markdown
Contributor Author

@apostasie PTAL

@apostasie

Copy link
Copy Markdown
Contributor

LGTM.

Failures are unrelated:

@apostasie

Copy link
Copy Markdown
Contributor

cc @AkihiroSuda for maintainers review & merge.

@apostasie

Copy link
Copy Markdown
Contributor

@swagatbora90 this is obviously in the same vein as #4383
We may have more of these.
Would you have time and interest in reviewing all similar patterns involving task IO in the codebase?

@fahedouch fahedouch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@fahedouch fahedouch added this to the v2.1.3 milestone Jul 1, 2025
@fahedouch
fahedouch merged commit 02cfb57 into containerd:main Jul 1, 2025
@swagatbora90

Copy link
Copy Markdown
Contributor Author

Would you have time and interest in reviewing all similar patterns involving task IO in the codebase?

Yes, I can take a look. Thanks for the review.

taylorsilva added a commit to concourse/concourse that referenced this pull request Oct 26, 2026
We were still getting intermittent errors related to stdout not being
captured from `get` and `put` steps. The error we'd get, which is one we
return when stdout from a resource step is empty:

```
resource script (/opt/resource/out /tmp/build/put) output a null version
```

I took a look at the same lines from last time that call `Cancel()`,
`Wait()`, `Close()` on the process's IO. I had previously debated the
order of operations and if we even needed to call them.

I _think_ we may have been introducing a race by calling `Cancel()`
first. My thought is that IO copy operations would not finish because of
our early `Cancel()` call.

I've done a fresh round of research and found the following examples
within the containerd ecosystem where the preference appears to be
closing the process's IO with: `Wait()`, `Close()`. Don't call
`Cancel()` at all.

Main example I saw was from here: https://github.com/containerd/nerdctl/blob/127dce535ff237bebdeab638d272fcfb9813d744/pkg/cmd/container/exec.go#L150-L151

Which appears to be trying to fix the same issue as us: containerd/nerdctl#4392

They ended up making the same change here: https://github.com/containerd/nerdctl/pull/4383/changes

This seems to be the preferred way to close the process IO for nerdctl.
Let's try this because the current setup is definitely not working 100%
of the time. It's annoying to have a job fail because we never captured
the stdout

I don't have any way of reproducing this, so this is a "hope and pray it
works" commit.

Other interesting thing to note: I made the previous change in this file
in Feb 2025. nerdctl made their changes in June/July 2025. Seems like
something in containerd probably introduced this flakey behaviour and we
both tried working around it by manually interacting with the process
IO.

Signed-off-by: Taylor Silva <[email protected]>
taylorsilva added a commit to concourse/concourse that referenced this pull request Oct 26, 2026
We were still getting intermittent errors related to stdout not being
captured from `get` and `put` steps. The error we'd get, which is one we
return when stdout from a resource step is empty:

```
resource script (/opt/resource/out /tmp/build/put) output a null version
```

I took a look at the same lines from last time that call `Cancel()`,
`Wait()`, `Close()` on the process's IO. I had previously debated the
order of operations and if we even needed to call them.

I _think_ we may have been introducing a race by calling `Cancel()`
first. My thought is that IO copy operations would not finish because of
our early `Cancel()` call.

I've done a fresh round of research and found the following examples
within the containerd ecosystem where the preference appears to be
closing the process's IO with: `Wait()`, `Close()`. Don't call
`Cancel()` at all.

Main example I saw was from here: https://github.com/containerd/nerdctl/blob/127dce535ff237bebdeab638d272fcfb9813d744/pkg/cmd/container/exec.go#L150-L151

Which appears to be trying to fix the same issue as us: containerd/nerdctl#4392

They ended up making the same change here: https://github.com/containerd/nerdctl/pull/4383/changes

This seems to be the preferred way to close the process IO for nerdctl.
Let's try this because the current setup is definitely not working 100%
of the time. It's annoying to have a job fail because we never captured
the stdout from the resource step.

I don't have any way of reproducing this, so this is a "hope and pray it
works" commit.

Other interesting thing to note: I made the previous change in this file
in Feb 2025. nerdctl made their changes in June/July 2025. Seems like
something in containerd probably introduced this flakey behaviour and we
both tried working around it by manually interacting with the process
IO.

Signed-off-by: Taylor Silva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] TestComposeExec test is flaky

3 participants