Documentation
¶
Overview ¶
Package disklimit holds apps to their disk limits (R-403, issue #130).
Every app has a disk limit (R-240), and until this existed it was only counted: the planner refused a deploy that would commit more disk than the host has (R-242), and then nothing stopped the app writing past it. One app could fill the disk every app and Pando share. A container runtime can only enforce a size on a container's own layer, on some storage drivers, and never on a volume — so Pando measures instead, and stops an app that stays over.
The pass runs on the leader. For each running app it reads what its containers and volumes hold, from the runtime (R-245), and:
- at 90% of the limit, tells the owner once;
- over the limit, tells the owner and records the reading;
- over the limit at the next reading too, stops it.
Two readings rather than one, so a moment over — a large file written and then removed — is a warning and not a stop. An app Pando stopped stays stopped until somebody starts it, and starting it clears every mark in the same write (migration 71), so this package never starts anything.
Index ¶
Constants ¶
const ( WarnAt = 0.9 ClearAt = 0.8 )
WarnAt is the share of its limit at which an app's owner is told it is near it, and ClearAt the share below which that warning is withdrawn, so an app hovering at 90% is not warned every pass.
const DefaultEvery = 10 * time.Minute
DefaultEvery is how often the pass runs, and so how long an app is over its limit before it is stopped: a disk fills in minutes, not days.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, n api.Notification) error
}
Notifier tells people things. subscription.Router is one.
type Pass ¶
type Pass struct {
Store Store
Usage UsageReader
// Notifier and Auditor are optional, and nil says nothing. Production
// wires both.
Notifier Notifier
Auditor Auditor
Clock clock.Clock
Logger *zap.Logger
// Every is how often Run runs a pass. Zero is DefaultEvery.
Every time.Duration
}
Pass is the disk job.
type Store ¶
type Store interface {
DiskCandidates(ctx context.Context) ([]state.DiskApp, error)
SetDiskMark(ctx context.Context, app state.DiskApp, which state.DiskMark, at *time.Time) (bool, error)
StopForDisk(ctx context.Context, app state.DiskApp) (bool, error)
}
Store is the state the pass reads and writes. *state.Disk is one.
type UsageReader ¶
type UsageReader interface {
Usage(ctx context.Context, runtimeRef, appID string) (reading api.BundleUsage, supported bool, err error)
}
UsageReader reads what an app is using from the runtime it runs on. supported is false when that runtime cannot say, and then the pass leaves the app alone.