Catch 404 and return exists=false from GetTCPLoadBalancer

Previouly getVipByName treated 404 like any other unexpected error
return and passed it up the chain.  This caused the "if ErrNotFound then
exists=false" logic in GetTCPLoadBalancer to never fire.

This change teaches getVipByName to return ErrNotFound on a 404 server
response.
This commit is contained in:
Angus Lees 2015-06-02 13:42:32 +10:00
parent 5520386b18
commit 6491922562

View File

@ -463,6 +463,11 @@ func getVipByName(client *gophercloud.ServiceClient, name string) (*vips.Virtual
return true, nil
})
if err != nil {
if e, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok {
if e.Actual == http.StatusNotFound {
return nil, ErrNotFound
}
}
return nil, err
}