Documentation
¶
Overview ¶
Package housekeeping keeps the pools healthy and the disk clean, by itself.
It never runs `git gc`: gc prunes, and a pool must never lose an object. A pool is repacked with the objects nothing points at kept in a cruft pack that never expires, and only once it has piled up enough loose objects or packs to be worth it.
Index ¶
- Constants
- type Keeper
- func (keeper *Keeper) DiskUsed() int64
- func (keeper *Keeper) Remount(ctx context.Context) int
- func (keeper *Keeper) Retire(ctx context.Context, unusedFor time.Duration) (int, int64)
- func (keeper *Keeper) Run(ctx context.Context)
- func (keeper *Keeper) Sweep()
- func (keeper *Keeper) TemplateTotals() (int, int64)
- func (keeper *Keeper) Totals() (int, int64)
Constants ¶
const MinimumUnused = 24 * time.Hour
MinimumUnused is the least a pool must have gone unused before it is retired on request.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper maintains the pools of one gitd, and sweeps the roots its workspaces are made in. A pool is repacked once it holds looseLimit loose objects or packLimit packs; temporary directories are looked for down to the configured sweep depth under the roots, where the deepest workspace is, and as deep as a repository's path goes under the pools.
func New ¶
func New( pools *pool.Pools, templates *template.Store, overlay *strategy.OverlayMaker, runner *git.Runner, roots []string, settings config.Housekeeping, measured *metrics.Metrics, ) *Keeper
New returns the keeper of pools and templates, whose workspaces are made under roots.
func (*Keeper) DiskUsed ¶
DiskUsed is the disk pools and templates took, as of the last round: what a tenant's disk limit is held to.
func (*Keeper) Remount ¶
Remount mounts again the overlay workspaces that are not mounted — after a reboot, or after somebody unmounted one — and logs what it could not.
func (*Keeper) Retire ¶
Retire removes now every pool no workspace borrows from and nothing has used for at least unusedFor, and says how many there were and the disk they took. Totals then count the pools that are left.
func (*Keeper) Run ¶
Run maintains every pool a minute after starting, so that it does not compete with the first calls after a start, and then every so often, until ctx ends.
func (*Keeper) Sweep ¶
func (keeper *Keeper) Sweep()
Sweep removes what a gitd that died left half built: the temporary directories and files it builds pools and workspaces in before moving them into place.
func (*Keeper) TemplateTotals ¶
TemplateTotals are how many templates there were and the disk they took, as of the last round.