Skip to content

integration/client: fix TestContainerExecLargeOutputWithTTY - #14120

Merged
mxpv merged 1 commit into
containerd:mainfrom
fuweid:drain-io-before-delete
Sep 8, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
fuweid:drain-io-before-delete

Conversation

@fuweid

@fuweid fuweid commented Sep 6, 2026

Copy link
Copy Markdown
Member

Wait for IO copying to complete before deleting the exec process. Delete cancels outstanding IO operations, which can truncate the output.

=== NAME  TestContainerExecLargeOutputWithTTY
    container_test.go:1990: process output does not end with "999999 1000000" at iteration 1, here are the last 20 characters of the output:

         "1150 991151 991152 9"
--- FAIL: TestContainerExecLargeOutputWithTTY (2.00s)

In a follow-up, we should add comment for Delete API and document that the caller should take responsibility to drain IO before Delete.

Copilot AI lite review requested due to automatic review settings September 6, 2026 20:58
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Sep 6, 2026
Wait for IO copying to complete before deleting the exec process. Delete
cancels outstanding IO operations, which can truncate the output.

```
=== NAME  TestContainerExecLargeOutputWithTTY
    container_test.go:1990: process output does not end with "999999 1000000" at iteration 1, here are the last 20 characters of the output:

         "1150 991151 991152 9"
--- FAIL: TestContainerExecLargeOutputWithTTY (2.00s)
```

In a follow-up, we should add comment for Delete API and document that the
caller should take responsibility to drain IO before Delete.

Signed-off-by: Wei Fu <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is minimal, aligns with the stated root cause (Delete cancels IO), and mirrors established test patterns for draining IO before deletion.

Pull request overview

This PR fixes a flaky integration test by ensuring exec process stdout is fully drained before the exec process is deleted, avoiding truncation caused by Delete cancelling in-flight IO copy operations.

Changes:

  • Add an explicit process.IO().Wait() in TestContainerExecLargeOutputWithTTY before calling process.Delete(ctx).
File summaries
File Description
integration/client/container_test.go Ensures exec IO copying completes before Delete cancels IO, preventing truncated output in the large TTY exec test.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ningmingxiao

Copy link
Copy Markdown
Contributor
func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStatus, error) {
	for _, o := range opts {
		if err := o(ctx, p); err != nil {
			return nil, err
		}
	}
	status, err := p.Status(ctx)
	if err != nil {
		return nil, err
	}
	switch status.Status {
	case Running, Paused, Pausing:
		return nil, fmt.Errorf("current process state: %s, process must be stopped before deletion: %w", status.Status, errdefs.ErrFailedPrecondition)
	}
	r, err := p.task.client.TaskService().DeleteProcess(ctx, &tasks.DeleteProcessRequest{
		ContainerID: p.task.id,
		ExecID:      p.id,
	})
	if err != nil {
		return nil, errdefs.FromGRPC(err)
	}
	if p.io != nil {
		p.io.Cancel()
		p.io.Wait()
		p.io.Close()
	}
	return &ExitStatus{code: r.ExitStatus, exitedAt: protobuf.FromTimestamp(r.ExitedAt)}, nil
}

I find there is already an io wait "p.io.Wait()" after delete. @fuweid

@fuweid

fuweid commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

I find there is already an io wait "p.io.Wait()" after delete

If task has been deleted, shim will not wait for IO copying to complete.
The caller should take responsibility for that.

@thaJeztah thaJeztah 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.

LGTM

@ningmingxiao

Copy link
Copy Markdown
Contributor

@fuweid

fuweid commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

do we need add some wait here https://github.com/containerd/containerd/blob/v2.3.5/internal/cri/server/container_execsync.go#L192

Please checkout the end of function and you will see we already drain IO coping.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 8, 2026
@mxpv
mxpv added this pull request to the merge queue Sep 8, 2026
Merged via the queue into containerd:main with commit 94443b7 Sep 8, 2026
55 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Sep 8, 2026
@samuelkarp

Copy link
Copy Markdown
Member

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0

@samuelkarp samuelkarp added cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 labels Oct 6, 2026
@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@samuelkarp: new pull request created: #14303

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@samuelkarp: new pull request created: #14304

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@samuelkarp: new pull request created: #14305

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 size/XS

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants