Fix error propagation bug in client FindUsableStore
We were always propagating the "not found" error from local storage
lookup, even when we found a global storage system.
@@ -171,10 +171,11 @@ func (c *Client) DeleteGlobalStore(in *Store) (Response, error) {
func (c *Client) FindUsableStore(tenant *Tenant, q string, fuzzy bool) (*Store, error) {
store, err := c.FindStore(tenant, q, fuzzy)
- if err != nil {
- if store, _ = c.FindGlobalStore(q, fuzzy); store == nil {
- return nil, err
+ if err == nil {
+ return store, nil
}
+ if store, _ := c.FindGlobalStore(q, fuzzy); store != nil {
+ return store, nil
}
- return store, err
+ return nil, err
}
