Skip to content

Commit 0ab8e82

Browse files
committed
bypass on no hosts found
1 parent 934910c commit 0ab8e82

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

cmd/freno/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/github/freno/pkg/http"
1212
"github.com/github/freno/pkg/throttle"
1313
"github.com/outbrain/golib/log"
14+
"os"
15+
"strconv"
1416
)
1517

1618
// AppVersion has to be filled by ldflags:
@@ -120,6 +122,12 @@ func httpServe() error {
120122
throttler := throttle.NewThrottler()
121123
log.Infof("Starting consensus service")
122124
log.Infof("- forced leadership: %+v", group.ForceLeadership)
125+
126+
bypassEnabled, err := strconv.ParseBool(os.Getenv("FRENO_BYPASS_ENABLED"))
127+
if err != nil {
128+
bypassEnabled = false
129+
}
130+
throttler.BypassOnNoHostsFound = bypassEnabled
123131
consensusServiceProvider, err := group.NewConsensusServiceProvider(throttler)
124132
if err != nil {
125133
return err

pkg/throttle/throttler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ type Throttler struct {
7878

7979
nonLowPriorityAppRequestsThrottled *cache.Cache
8080
httpClient *http.Client
81+
82+
BypassOnNoHostsFound bool
8183
}
8284

8385
func NewThrottler() *Throttler {
@@ -331,6 +333,10 @@ func (throttler *Throttler) refreshMySQLInventory() error {
331333
}
332334
}
333335
if len(totalHosts) == 0 {
336+
if throttler.bypassOnNoHostsFound {
337+
log.Debugf("No hosts for pool: %+v, but bypass is enabled", poolName)
338+
return nil
339+
}
334340
return log.Errorf("Unable to get any HAproxy hosts for pool: %+v", poolName)
335341
}
336342

0 commit comments

Comments
 (0)