Skip to content

Commit

Permalink
[TT-716] Handle HostDown check when host checker manager isn't initia…
Browse files Browse the repository at this point in the history
…lized (#3350)

Workaround for TT-716, using the same check that's performed by `HostCheckerManager.AmIPolling` but excluding any additional behavior.
From the logic that's implemented in `server.go` we don't expect the host checker to be initialized when `disable_management_poller` is set to `true`.
Disabling `check_host_against_uptime_tests` could be a config-level workaround for the issue as well.
  • Loading branch information
matiasinsaurralde committed Oct 7, 2020
1 parent adca606 commit 481eae9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gateway/host_checker_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestHostCheckerManagerInit(t *testing.T) {
func TestAmIPolling(t *testing.T) {
hc := HostCheckerManager{}

pooling := hc.AmIPolling()
if pooling {
polling := hc.AmIPolling()
if polling {
t.Error("HostCheckerManager storage not configured, it should have failed.")
}

Expand All @@ -51,9 +51,9 @@ func TestAmIPolling(t *testing.T) {
hc2 := HostCheckerManager{}
hc2.Init(redisStorage)

pooling = hc.AmIPolling()
poolingHc2 := hc2.AmIPolling()
if !pooling && poolingHc2 {
polling = hc.AmIPolling()
pollingHc2 := hc2.AmIPolling()
if !polling && pollingHc2 {
t.Error("HostCheckerManager storage configured, it shouldn't have failed.")
}

Expand Down
4 changes: 4 additions & 0 deletions gateway/reverse_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func nextTarget(targetData *apidef.HostList, spec *APISpec) (string, error) {
if !spec.Proxy.CheckHostAgainstUptimeTests {
return host, nil // we don't care if it's up
}
// As checked by HostCheckerManager.AmIPolling
if GlobalHostChecker.store == nil {
return host, nil
}
if !GlobalHostChecker.HostDown(host) {
return host, nil // we do care and it's up
}
Expand Down

0 comments on commit 481eae9

Please sign in to comment.