Skip to content

Commit f078ceb

Browse files
committed
fix: propagate context deadline exceeded error properly
When a shim becomes unresponsive (e.g., stopped via SIGSTOP), ttrpc communication times out with `context deadline exceeded`. Currently, this error is not properly propagated, causing redundant API calls and slow container listing by client sides. Specifically, when executing the API to check the task state, it appears that the `context deadline exceeded` error via ttrpc is not being handled within `shimTask.State()` and `getProcessState()`. As a result, when this error occurs, clients such as nerdctl cannot recognize this error, and it is thought that the issue described below is occurring: - containerd/nerdctl#4720 Therefore, this commit adds error handling to ensure timeouts are properly handled by client sides. Signed-off-by: Hayato Kiwata <dev@haytok.jp>
1 parent 89c7170 commit f078ceb

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

core/runtime/v2/shim.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,9 @@ func (s *shimTask) State(ctx context.Context) (runtime.State, error) {
835835
ID: s.ID(),
836836
})
837837
if err != nil {
838+
if errdefs.IsDeadlineExceeded(err) {
839+
return runtime.State{}, err
840+
}
838841
if !errors.Is(err, ttrpc.ErrClosed) {
839842
return runtime.State{}, errgrpc.ToNative(err)
840843
}

plugins/services/tasks/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func getProcessState(ctx context.Context, p runtime.Process) (*task.Process, err
349349

350350
state, err := p.State(ctx)
351351
if err != nil {
352-
if errdefs.IsNotFound(err) || errdefs.IsUnavailable(err) {
352+
if errdefs.IsNotFound(err) || errdefs.IsUnavailable(err) || errdefs.IsDeadlineExceeded(err) {
353353
return nil, err
354354
}
355355
log.G(ctx).WithError(err).Errorf("get state for %s", p.ID())

0 commit comments

Comments
 (0)