Skip to content

Commit 8cff6b3

Browse files
[release/1.4 backport] 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 Co-authored-by: Danail Branekov <[email protected]> Co-authored-by: Georgi Sabev <[email protected]> Signed-off-by: Danail Branekov <[email protected]> Signed-off-by: Georgi Sabev <[email protected]> (cherry picked from commit 7451dd1)
1 parent 269548f commit 8cff6b3

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
@@ -1068,6 +1068,10 @@ func TestContainerLoadUnexistingProcess(t *testing.T) {
10681068
t.Fatal("an error should have occurred when loading a process that does not exist")
10691069
}
10701070

1071+
if !errdefs.IsNotFound(err) {
1072+
t.Fatalf("an error of type NotFound should have been returned when loading a process that does not exist, got %#v instead ", err)
1073+
}
1074+
10711075
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
10721076
t.Error(err)
10731077
}

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)