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
0ffaeeb5d8

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2020-10-29 14:38:50 +11:00
parent 1ae8e81abb
commit e004616b02

View File

@ -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) {