|
|
@ -2,7 +2,6 @@ package api
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -362,15 +361,11 @@ WAIT:
|
|
|
|
RETRY:
|
|
|
|
RETRY:
|
|
|
|
pair, meta, err := kv.Get(l.opts.Key, opts)
|
|
|
|
pair, meta, err := kv.Get(l.opts.Key, opts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
// TODO (slackpad) - Make a real error type here instead of using
|
|
|
|
|
|
|
|
// a string check.
|
|
|
|
|
|
|
|
const serverError = "Unexpected response code: 500"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If configured we can try to ride out a brief Consul unavailability
|
|
|
|
// If configured we can try to ride out a brief Consul unavailability
|
|
|
|
// by doing retries. Note that we have to attempt the retry in a non-
|
|
|
|
// by doing retries. Note that we have to attempt the retry in a non-
|
|
|
|
// blocking fashion so that we have a clean place to reset the retry
|
|
|
|
// blocking fashion so that we have a clean place to reset the retry
|
|
|
|
// counter if service is restored.
|
|
|
|
// counter if service is restored.
|
|
|
|
if retries > 0 && strings.Contains(err.Error(), serverError) {
|
|
|
|
if retries > 0 && IsServerError(err) {
|
|
|
|
time.Sleep(l.opts.MonitorRetryTime)
|
|
|
|
time.Sleep(l.opts.MonitorRetryTime)
|
|
|
|
retries--
|
|
|
|
retries--
|
|
|
|
opts.WaitIndex = 0
|
|
|
|
opts.WaitIndex = 0
|
|
|
|