runtime: handle unimplemented RPC call by NotFound status code

For now, agent return status of NotFound when calling getOOMEvents, runtime should handle it correctly.

Fixes: #393

Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
bin liu 2020-07-08 11:51:48 +08:00
parent 350831b18b
commit a0a96db217
2 changed files with 3 additions and 1 deletions

View File

@ -35,5 +35,6 @@ func TestIsGRPCErrorCode(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
assert.True(isGRPCErrorCode(codes.Unimplemented, status.New(codes.Unimplemented, "foobar").Err())) assert.True(isGRPCErrorCode(codes.Unimplemented, status.New(codes.Unimplemented, "foobar").Err()))
assert.True(isGRPCErrorCode(codes.NotFound, status.New(codes.NotFound, "foobar").Err()))
assert.False(isGRPCErrorCode(codes.Unimplemented, errors.New("foobar"))) assert.False(isGRPCErrorCode(codes.Unimplemented, errors.New("foobar")))
} }

View File

@ -145,7 +145,8 @@ func watchOOMEvents(ctx context.Context, s *service) {
logrus.WithField("sandbox", s.sandbox.ID()).WithError(err).Warn("failed to get OOM event from sandbox") logrus.WithField("sandbox", s.sandbox.ID()).WithError(err).Warn("failed to get OOM event from sandbox")
// If the GetOOMEvent call is not implemented, then the agent is most likely an older version, // If the GetOOMEvent call is not implemented, then the agent is most likely an older version,
// stop attempting to get OOM events. // stop attempting to get OOM events.
if isGRPCErrorCode(codes.Unimplemented, err) { // for rust agent, the response code is not found
if isGRPCErrorCode(codes.NotFound, err) {
return return
} }
continue continue