countInProgress returns counts of prebuilds in transition states (starting, stopping, deleting). These counts are tracked at the template level, so all presets sharing the same template see the same values.
()
| 452 | // countInProgress returns counts of prebuilds in transition states (starting, stopping, deleting). |
| 453 | // These counts are tracked at the template level, so all presets sharing the same template see the same values. |
| 454 | func (p PresetSnapshot) countInProgress() (starting int32, stopping int32, deleting int32) { |
| 455 | for _, progress := range p.InProgress { |
| 456 | num := progress.Count |
| 457 | switch progress.Transition { |
| 458 | case database.WorkspaceTransitionStart: |
| 459 | starting += num |
| 460 | case database.WorkspaceTransitionStop: |
| 461 | stopping += num |
| 462 | case database.WorkspaceTransitionDelete: |
| 463 | deleting += num |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | return starting, stopping, deleting |
| 468 | } |
| 469 | |
| 470 | // getOldestPrebuildIDs returns the IDs of the N oldest prebuilds, sorted by creation time. |
| 471 | // This is used when we need to delete prebuilds, ensuring we remove the oldest ones first. |