MCPcopy Create free account
hub / github.com/coder/coder / needsBackoffPeriod

Method needsBackoffPeriod

coderd/prebuilds/preset_snapshot.go:423–438  ·  view source on GitHub ↗

needsBackoffPeriod checks if we should delay prebuild creation due to recent failures. If there were failures, it calculates a backoff period based on the number of failures and returns true if we're still within that period.

(clock quartz.Clock, backoffInterval time.Duration)

Source from the content-addressed store, hash-verified

421// If there were failures, it calculates a backoff period based on the number of failures
422// and returns true if we're still within that period.
423func (p PresetSnapshot) needsBackoffPeriod(clock quartz.Clock, backoffInterval time.Duration) ([]*ReconciliationActions, bool) {
424 if p.Backoff == nil || p.Backoff.NumFailed == 0 {
425 return nil, false
426 }
427 backoffUntil := p.Backoff.LastBuildAt.Add(time.Duration(p.Backoff.NumFailed) * backoffInterval)
428 if clock.Now().After(backoffUntil) {
429 return nil, false
430 }
431
432 return []*ReconciliationActions{
433 {
434 ActionType: ActionTypeBackoff,
435 BackoffUntil: backoffUntil,
436 },
437 }, true
438}
439
440// countEligible returns the number of prebuilds that are ready to be claimed.
441// A prebuild is eligible if it's running and its agents are in ready state.

Callers 1

CalculateActionsMethod · 0.95

Calls 2

DurationMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected