MCPcopy
hub / github.com/grafana/dskit / CheckReady

Method CheckReady

ring/lifecycler.go:255–281  ·  view source on GitHub ↗

CheckReady is used to rate limit the number of ingesters that can be coming or going at any one time, by only returning true if all ingesters are active. The state latches: once we have gone ready we don't go un-ready

(ctx context.Context)

Source from the content-addressed store, hash-verified

253// going at any one time, by only returning true if all ingesters are active.
254// The state latches: once we have gone ready we don't go un-ready
255func (i *Lifecycler) CheckReady(ctx context.Context) error {
256 i.readyLock.Lock()
257 defer i.readyLock.Unlock()
258
259 if i.ready {
260 return nil
261 }
262
263 if err := i.checkRingHealthForReadiness(ctx); err != nil {
264 // Reset the min ready duration counter.
265 i.readySince = time.Time{}
266
267 return err
268 }
269
270 // Honor the min ready duration. The duration counter start after all readiness checks have
271 // passed.
272 if i.readySince.IsZero() {
273 i.readySince = time.Now()
274 }
275 if time.Since(i.readySince) < i.cfg.MinReadyDuration {
276 return fmt.Errorf("waiting for %v after being ready", i.cfg.MinReadyDuration)
277 }
278
279 i.ready = true
280 return nil
281}
282
283func (i *Lifecycler) checkRingHealthForReadiness(ctx context.Context) error {
284 // Ensure the instance holds some tokens.

Calls 2

ErrorfMethod · 0.80