From e004616b027de07b6c7f9fe7fd82fe20fa04cdd5 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 29 Oct 2020 14:38:50 +1100 Subject: [PATCH] runtime/network: Fix error reporting in listRoutes() If the upcast from resultingRoutes to *grpc.IRoutes fails, we return (nil, err), but previous code ensures that err is nil at that point, so we return no error. fixes #1206 Forward port of https://github.com/kata-containers/runtime/pull/3033/commits/0ffaeeb5d84054cf2726e5fbdfbfde54c75ec6d7 Signed-off-by: David Gibson --- src/runtime/virtcontainers/kata_agent.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/virtcontainers/kata_agent.go b/src/runtime/virtcontainers/kata_agent.go index 89db575385..1ce2f8e74a 100644 --- a/src/runtime/virtcontainers/kata_agent.go +++ b/src/runtime/virtcontainers/kata_agent.go @@ -648,10 +648,10 @@ func (k *kataAgent) listRoutes() ([]*pbTypes.Route, error) { return nil, err } resultRoutes, ok := resultingRoutes.(*grpc.Routes) - if ok { - return resultRoutes.Routes, err + if !ok { + return nil, fmt.Errorf("Unexpected type %T for routes", resultingRoutes) } - return nil, err + return resultRoutes.Routes, nil } func (k *kataAgent) getAgentURL() (string, error) {