Bugfix: switch statements were missing fallthrough statement thus making them retry non-retriable errors. Response is now propagated back up to caller if it's available in order to provide context if needed.

This commit is contained in:
Renan DelValle 2018-10-03 16:51:22 -07:00
parent 9ebf118e71
commit 01911e47dd
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
2 changed files with 10 additions and 8 deletions

View file

@ -15,9 +15,8 @@
package realis
import (
"time"
"math/rand"
"time"
"github.com/paypal/gorealis/gen-go/apache/aurora"
"github.com/paypal/gorealis/response"
@ -178,18 +177,21 @@ func (r *realisClient) thriftCallWithRetries(thriftCall auroraThriftCall) (*auro
case aurora.ResponseCode_OK:
return resp, nil
// If the response code is transient, continue retrying
// If the response code is transient, continue retrying
case aurora.ResponseCode_ERROR_TRANSIENT:
r.logger.Println("Aurora replied with Transient error code, retrying")
continue
// Failure scenarios, these indicate a bad payload or a bad config. Stop retrying.
// Failure scenarios, these indicate a bad payload or a bad config. Stop retrying.
case aurora.ResponseCode_INVALID_REQUEST:
fallthrough
case aurora.ResponseCode_ERROR:
fallthrough
case aurora.ResponseCode_AUTH_FAILED:
fallthrough
case aurora.ResponseCode_JOB_UPDATING_ERROR:
r.logger.Println("Terminal bad reply from Aurora, won't retry")
return nil, errors.New(response.CombineMessage(resp))
r.logger.Printf("Terminal Response Code %v from Aurora, won't retry\n", resp.GetResponseCode().String())
return resp, errors.New(response.CombineMessage(resp))
// The only case that should fall down to here is a WARNING response code.
// It is currently not used as a response in the scheduler so it is unknown how to handle it.