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)
| 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. |
| 423 | func (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. |
no test coverage detected