Adding a check for 401. This reduces the retries on the end to end test and fails fast when a wrong/unathorized username and password are provided to interact with Aurora.

This commit is contained in:
Renan DelValle 2018-12-18 17:14:48 -08:00
parent 71d41de2e4
commit e4e8a1c0b3
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
2 changed files with 13 additions and 3 deletions

View file

@ -17,7 +17,10 @@ package realis
import (
"io"
"math/rand"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"git.apache.org/thrift.git/lib/go/thrift"
@ -163,6 +166,12 @@ func (c *Client) thriftCallWithRetries(thriftCall auroraThriftCall) (*aurora.Res
if ok {
c.logger.DebugPrint("Encountered a transport exception")
// TODO(rdelvalle): Figure out a better way to obtain the error code as this is a very brittle solution
// 401 Unauthorized means the wrong username and password were provided
if strings.Contains(e.Error(), strconv.Itoa(http.StatusUnauthorized)) {
return nil, errors.Wrap(clientErr, "wrong username or password provided")
}
e, ok := e.Err().(*url.Error)
if ok {
// EOF error occurs when the server closes the read buffer of the client. This is common