history

package
v0.0.0-...-b79a0d8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package history logs image success/failure to disk.

Data logged includes image name and success/failure counts for imaging and first boot.

IMPORTANT When using in recovery, must add history.RebootHook to log.Preboot.

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxFailuresPerImg uint = 5 //max allowed sum of ImagingFailures and BootFailures

)

Functions

func Check

func Check(name string) (ok bool)

Check returns false if too many failures are recorded for an image, true otherwise.

func Load

func Load() (ok bool)

Reads history file, comparing stored count with MaxFailures

func RebootHook

func RebootHook(success bool)
When added to log.Preboot, RebootHook updates the history file at the end of factory restore.

Updated entry is shuffled to front of list, so RecordBootState can determine which entry to update even if the disktag is missing.

func RecordBootState

func RecordBootState(imgName string, success bool, severity uint, bTime time.Time, notes string)
RecordBootState records boot status (success/failure, how badly failed).

If imgName is empty or otherwise doesn't appear valid, update stats for first entry.

func Rollover

func Rollover(path string)

func SetRoot

func SetRoot(path string)

Sets where the history file can be found. Path is stored for use by other functions in the package.

func WriteArbitraryHistory

func WriteArbitraryHistory(rec string, res ResultList)

Writes arbitrary records to history file, for use in integ tests.

Types

type ImageResult

type ImageResult struct {
	Image           string   //image name
	ImagingAttempts uint     `json:",omitempty"` //currently only written, not used
	ImagingFailures uint     `json:",omitempty"`
	BootAttempts    uint     `json:",omitempty"` //currently only written, not used
	BootFailures    uint     `json:",omitempty"`
	Notes           []string `json:",omitempty"` //record timestamp+reason for failure
}

type ResultList

type ResultList []*ImageResult

Jump to

Keyboard shortcuts

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