From 1ae8e81abb1e89623a64b02d6579c8b04db76b03 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 29 Oct 2020 14:34:52 +1100 Subject: [PATCH 1/2] runtime/network: Correct error reporting in listInterfaces() If the upcast from resultingInterfaces to *grpc.Interfaces fails, we return (nil, err), but previous code ensures that err is nil at that point, so we return no error. Forward port of https://github.com/kata-containers/runtime/pull/3033/commits/b86e904c2d13dfd148b3bcf2ad93748e2b45a886 fixes #1206 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 9f5228373f..89db575385 100644 --- a/src/runtime/virtcontainers/kata_agent.go +++ b/src/runtime/virtcontainers/kata_agent.go @@ -635,10 +635,10 @@ func (k *kataAgent) listInterfaces() ([]*pbTypes.Interface, error) { return nil, err } resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces) - if ok { - return resultInterfaces.Interfaces, err + if !ok { + return nil, fmt.Errorf("Unexpected type %T for interfaces", resultingInterfaces) } - return nil, err + return resultInterfaces.Interfaces, nil } func (k *kataAgent) listRoutes() ([]*pbTypes.Route, error) { From e004616b027de07b6c7f9fe7fd82fe20fa04cdd5 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 29 Oct 2020 14:38:50 +1100 Subject: [PATCH 2/2] 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) {