runmarker

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package runmarker detects an unclean stop of the control plane. A marker file written at boot and marked clean at graceful shutdown tells the next boot whether the previous run was killed, and the kernel's oom_kill counter says whether the host killed it for memory.

Index

Constants

View Source
const (

	// EnvWindow sets how long an unclean restart stays in the attention feed.
	EnvWindow = "APP_UNCLEAN_RESTART_WINDOW"
)

Variables

This section is empty.

Functions

func Begin

func Begin(dir string, now time.Time) (*Tracker, *Incident)

Begin reads the previous marker, records an incident when it was not clean and writes a fresh marker for this run. It returns the incident or nil.

func OOMKills

func OOMKills(path string) (n int64, ok bool)

OOMKills reads the oom_kill counter from a vmstat file. ok is false when the file is missing or has no such line, so callers degrade quietly.

func WindowFromEnv

func WindowFromEnv(getenv func(string) string) time.Duration

WindowFromEnv reads EnvWindow as a duration, falling back to three days.

Types

type Incident

type Incident struct {
	At            time.Time `json:"at"`
	PrevStartedAt time.Time `json:"prev_started_at"`
	PrevPID       int       `json:"prev_pid"`
	OOMLikely     bool      `json:"oom_likely"`
}

Incident is one boot that found the previous run had not stopped cleanly.

func Recent

func Recent(dir string, window time.Duration, now time.Time) []Incident

Recent returns incidents newer than window, newest first.

type Marker

type Marker struct {
	PID       int       `json:"pid"`
	StartedAt time.Time `json:"started_at"`
	OOMKill   int64     `json:"oom_kill"`
	Clean     bool      `json:"clean"`
}

Marker is the small file the running process leaves behind. OOMKill is -1 when the counter could not be read.

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker owns the marker for the current process.

func (*Tracker) Clean

func (t *Tracker) Clean()

Clean marks the run as stopped on purpose. Safe on a nil Tracker.

Jump to

Keyboard shortcuts

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