Help us shape the future of Go! Take the 2026 Go Developer Survey

disklimit

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

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

View Source
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.

View Source
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

func Used

func Used(r api.BundleUsage) (used int64, known bool)

Used is what an app's containers and volumes hold. A part the runtime cannot measure (-1) is left out, so the figure is never more than the truth, and known is false only when nothing could be measured.

Types

type Auditor

type Auditor interface {
	Write(ctx context.Context, e audit.Event) error
}

Auditor writes audit events.

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.

func (*Pass) Once

func (p *Pass) Once(ctx context.Context)

Once runs one pass.

func (*Pass) Run

func (p *Pass) Run(ctx context.Context)

Run passes until ctx is canceled.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL