MCPcopy Create free account
hub / github.com/cortexproject/cortex / cleanUnhealthy

Method cleanUnhealthy

pkg/ring/client/pool.go:177–189  ·  view source on GitHub ↗

cleanUnhealthy loops through all servers and deletes any that fails a healthcheck.

()

Source from the content-addressed store, hash-verified

175
176// cleanUnhealthy loops through all servers and deletes any that fails a healthcheck.
177func (p *Pool) cleanUnhealthy() {
178 for _, addr := range p.RegisteredAddresses() {
179 client, ok := p.fromCache(addr)
180 // not ok means someone removed a client between the start of this loop and now
181 if ok {
182 err := healthCheck(client, p.cfg.HealthCheckTimeout)
183 if err != nil {
184 level.Warn(p.logger).Log("msg", fmt.Sprintf("removing %s failing healthcheck", p.clientName), "addr", addr, "reason", err)
185 p.RemoveClientFor(addr)
186 }
187 }
188 }
189}
190
191// healthCheck will check if the client is still healthy, returning an error if it is not
192func healthCheck(client PoolClient, timeout time.Duration) error {

Callers 2

iterationMethod · 0.95
TestCleanUnhealthyFunction · 0.95

Calls 5

RegisteredAddressesMethod · 0.95
fromCacheMethod · 0.95
RemoveClientForMethod · 0.95
healthCheckFunction · 0.70
LogMethod · 0.45

Tested by 1

TestCleanUnhealthyFunction · 0.76