Dont return raw etcd errors

This commit is contained in:
nikhiljindal
2015-06-22 18:19:18 -07:00
parent 764d34d363
commit 4b7f7ce535
8 changed files with 59 additions and 22 deletions

View File

@@ -17,7 +17,6 @@ limitations under the License.
package etcd
import (
"errors"
"fmt"
"sync"
@@ -31,7 +30,8 @@ import (
)
var (
errorUnableToAllocate = errors.New("unable to allocate")
// Placeholder error that should not be surfaced to the user.
errorUnableToAllocate = k8serr.NewInternalError(fmt.Errorf("unable to allocate"))
)
// Etcd exposes a service.Allocator that is backed by etcd.
@@ -121,6 +121,9 @@ func (e *Etcd) AllocateNext() (int, bool, error) {
}
return nil
})
if err != nil && err.Error() == errorUnableToAllocate.Error() {
err = nil
}
return offset, ok, err
}
@@ -161,7 +164,10 @@ func (e *Etcd) tryUpdate(fn func() error) error {
return existing, nil
}),
)
return etcderr.InterpretUpdateError(err, e.kind, "")
if err != nil {
err = etcderr.InterpretUpdateError(err, e.kind, "")
}
return err
}
// Refresh reloads the RangeAllocation from etcd.