pressuregate

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pressuregate turns local Linux PSI and OOM observations into a bounded, hysteretic Incus cluster-member admission signal.

Index

Constants

View Source
const (
	SchemaVersion = 1
	StateOpen     = "open"
	StateClosed   = "closed"

	MetadataSchema     = "user.gha_pressure.schema"
	MetadataState      = "user.gha_pressure.state"
	MetadataReason     = "user.gha_pressure.reason"
	MetadataObservedAt = "user.gha_pressure.observed_at"
	MetadataStateSince = "user.gha_pressure.state_since"
	MetadataCPUSome    = "user.gha_pressure.cpu_some_avg10"
	MetadataMemoryFull = "user.gha_pressure.memory_full_avg10"
	MetadataIOFull     = "user.gha_pressure.io_full_avg10"
	MetadataOOMKills   = "user.gha_pressure.oom_kills_total"
)

Variables

This section is empty.

Functions

func Metadata

func Metadata(state State, sample Sample) map[string]string

func ParseMetadata

func ParseMetadata(values map[string]string, policy Policy, now time.Time) (State, Sample, error)

Types

type Policy

type Policy struct {
	Required              bool    `json:"required" yaml:"required"`
	StaleAfterSeconds     int     `json:"stale_after_seconds" yaml:"stale_after_seconds"`
	HeartbeatSeconds      int     `json:"heartbeat_seconds" yaml:"heartbeat_seconds"`
	MinimumClosedSeconds  int     `json:"minimum_closed_seconds" yaml:"minimum_closed_seconds"`
	CPUSomeClose          float64 `json:"cpu_some_close" yaml:"cpu_some_close"`
	CPUSomeReopen         float64 `json:"cpu_some_reopen" yaml:"cpu_some_reopen"`
	MemoryFullClose       float64 `json:"memory_full_close" yaml:"memory_full_close"`
	MemoryFullReopen      float64 `json:"memory_full_reopen" yaml:"memory_full_reopen"`
	IOFullClose           float64 `json:"io_full_close" yaml:"io_full_close"`
	IOFullReopen          float64 `json:"io_full_reopen" yaml:"io_full_reopen"`
	MaximumRecentOOMKills uint64  `json:"maximum_recent_oom_kills" yaml:"maximum_recent_oom_kills"`
}

func (Policy) Validate

func (p Policy) Validate() error

type Sample

type Sample struct {
	ObservedAt      time.Time `json:"observed_at"`
	CPUSomeAvg10    float64   `json:"cpu_some_avg10"`
	MemoryFullAvg10 float64   `json:"memory_full_avg10"`
	IOFullAvg10     float64   `json:"io_full_avg10"`
	OOMKillsTotal   uint64    `json:"oom_kills_total"`
}

func (Sample) Validate

func (s Sample) Validate(now time.Time, staleAfter time.Duration) error

type State

type State struct {
	SchemaVersion int       `json:"schema_version"`
	State         string    `json:"state"`
	Reason        string    `json:"reason"`
	StateSince    time.Time `json:"state_since"`
	ObservedAt    time.Time `json:"observed_at"`
	OOMKillsTotal uint64    `json:"oom_kills_total"`
}

func Evaluate

func Evaluate(previous State, sample Sample, policy Policy, now time.Time) (State, error)

func ForceClosed

func ForceClosed(previous State, sample Sample, policy Policy, now time.Time, reason string) (State, error)

func (State) Validate

func (s State) Validate() error

Jump to

Keyboard shortcuts

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