Fix health race (#645)
* Revert "middleware/proxy: Make Unhealthy a pointer (#615)"
This reverts commit acbf522ceb
.
* middleware/proxy: add proper locking
This add the proper locking around `Unhealthy`.
This commit is contained in:
parent
bfa18470e5
commit
003b1bf678
6 changed files with 26 additions and 28 deletions
|
@ -28,16 +28,13 @@ func (r *customPolicy) Select(pool HostPool) *UpstreamHost {
|
|||
func testPool() HostPool {
|
||||
pool := []*UpstreamHost{
|
||||
{
|
||||
Name: workableServer.URL, // this should resolve (healthcheck test)
|
||||
Unhealthy: newBool(),
|
||||
Name: workableServer.URL, // this should resolve (healthcheck test)
|
||||
},
|
||||
{
|
||||
Name: "http://shouldnot.resolve", // this shouldn't
|
||||
Unhealthy: newBool(),
|
||||
Name: "http://shouldnot.resolve", // this shouldn't
|
||||
},
|
||||
{
|
||||
Name: "http://C",
|
||||
Unhealthy: newBool(),
|
||||
Name: "http://C",
|
||||
},
|
||||
}
|
||||
return HostPool(pool)
|
||||
|
@ -57,7 +54,7 @@ func TestRoundRobinPolicy(t *testing.T) {
|
|||
t.Error("Expected second round robin host to be third host in the pool.")
|
||||
}
|
||||
// mark host as down
|
||||
*pool[0].Unhealthy = true
|
||||
pool[0].Unhealthy = true
|
||||
h = rrPolicy.Select(pool)
|
||||
if h != pool[1] {
|
||||
t.Error("Expected third round robin host to be first host in the pool.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue