Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions internal/oci/runtime_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ func (r *runtimeVM) StopContainer(ctx context.Context, c *Container, timeout int

stopCh := make(chan error)
go func() {
if _, err := r.wait(ctx, c.ID(), ""); err != nil {
// errdefs.ErrNotFound actually comes from a closed connection, which is expected
// when stoping the container, with the agent and the VM going off. In such case.
// let's just ignore the error.
if _, err := r.wait(ctx, c.ID(), ""); err != nil && !errors.Is(err, errdefs.ErrNotFound) {
stopCh <- errdefs.FromGRPC(err)
}

Expand Down Expand Up @@ -629,7 +632,7 @@ func (r *runtimeVM) updateContainerStatus(c *Container) error {
ID: c.ID(),
})
if err != nil {
if errors.Is(err, ttrpc.ErrClosed) {
if !errors.Is(err, ttrpc.ErrClosed) {
return errdefs.FromGRPC(err)
}
return errdefs.ErrNotFound
Expand Down Expand Up @@ -814,7 +817,10 @@ func (r *runtimeVM) wait(ctx context.Context, ctrID, execID string) (int32, erro
ExecID: execID,
})
if err != nil {
return -1, errdefs.FromGRPC(err)
if !errors.Is(err, ttrpc.ErrClosed) {
return -1, errdefs.FromGRPC(err)
}
return -1, errdefs.ErrNotFound
Copy link
Member

Choose a reason for hiding this comment

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

Should we define a custom error here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm really on the fence about this.

Defining a custom error seems the cleanest possible way to proceed, but we need to ensure it'll be handled inside our own code. The reason for that is containerd also returning errdefs.ErrNotFound in case the error is ttrpc.ErrClosed, which makes me think that it's some kind of non-written convention.

Would you be okay with a follow-up PR where I'd switch the ErrNotFound by our own defined error, carefully taking into consideration the places where we actually can do that?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good 👍

}

return int32(resp.ExitStatus), nil
Expand All @@ -837,7 +843,7 @@ func (r *runtimeVM) remove(ctx context.Context, ctrID, execID string) error {
if _, err := r.task.Delete(ctx, &task.DeleteRequest{
ID: ctrID,
ExecID: execID,
}); err != nil {
}); err != nil && !errors.Is(err, ttrpc.ErrClosed) {
return errdefs.FromGRPC(err)
}

Expand Down