Merge pull request #1207 from dgibson/bug1206

Fix error reporting in listInterfaces() and listRoutes()
This commit is contained in:
David Gibson 2021-01-05 12:02:07 +11:00 committed by GitHub
commit e9e39fd081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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