Skip to content

Commit 7451dd1

Browse files
Return GRPC not found error instead of plain one
When the shim returns a plain error when a process does not exist, the server is unable to recognise its GRPC status code and assumes UnknownError. This is awkward for containerd client users as they are unable to recognise the actual reason for the error. When the shim returns a NotFound GRPC error, it is properly translated by the server and clients receive a proper NotFound error instead of Unknown Please note that we (CF Garden) would like to have the eventual fix backported to 1.4 as well. Co-authored-by: Danail Branekov <[email protected]> Signed-off-by: Danail Branekov <[email protected]> Signed-off-by: Georgi Sabev <[email protected]>
1 parent 3cd1c83 commit 7451dd1

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

container_linux_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,10 @@ func TestContainerLoadUnexistingProcess(t *testing.T) {
11781178
t.Fatal("an error should have occurred when loading a process that does not exist")
11791179
}
11801180

1181+
if !errdefs.IsNotFound(err) {
1182+
t.Fatalf("an error of type NotFound should have been returned when loading a process that does not exist, got %#v instead ", err)
1183+
}
1184+
11811185
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
11821186
t.Error(err)
11831187
}

runtime/v2/runc/v2/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.
483483
}
484484
p, err := container.Process(r.ExecID)
485485
if err != nil {
486-
return nil, err
486+
return nil, errdefs.ToGRPC(err)
487487
}
488488
st, err := p.Status(ctx)
489489
if err != nil {

0 commit comments

Comments
 (0)