marker

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package marker records what a load run's real tasks did, in files under a directory the harness owns: one exec file per process the no-op command started, refreshed while the process lives, and one output file per task key, appended to by every process that writes the task's output. The chaos checks read them to find a process that outlived its worker and an output that two attempts wrote at once.

Index

Constants

View Source
const (
	RoleMain   = "main"   // the task's own process
	RoleChatty = "chatty" // a child printing to the task's stdout
	RoleSilent = "silent" // a child with no stdio of the task's
)

The roles of an exec.

View Source
const (
	ExecsDir   = "execs"   // one <exec id>.json per process
	OutputsDir = "outputs" // <key hash>.out and <key hash>.key per task key
	LogsDir    = "logs"    // the silent children's stdio files
)

The marker directory's subdirectories.

View Source
const ConfigArgPrefix = "--sqi-load-config="

ConfigArgPrefix starts the no-op command's argument naming its noop.json. The managed target puts it first when a job class has real_task; without it the no-op prints one line and exits.

View Source
const RefreshInterval = 250 * time.Millisecond

RefreshInterval is how often a live exec's LastSeen is rewritten.

Variables

This section is empty.

Functions

func ConfigArg

func ConfigArg(path string) string

ConfigArg returns the argument naming the config file at path.

func NewID

func NewID() (string, error)

NewID returns a random exec ID.

func Output

func Output(dir, key, execID string, at time.Time) error

Output appends "<execID> <RFC3339Nano>\n" to <dir>/outputs/<hex sha256(key)[:16]>.out, and remembers key in <dir>/outputs/<same>.key on first use. Writers of one key may make their first call at once.

func Outputs

func Outputs(dir string) (map[string][]OutputLine, error)

Outputs reads every output file in dir: key -> lines in file order. A line cut short by a writer that died mid-write is skipped.

func WriteConfig

func WriteConfig(path string, cfg NoopConfig) error

WriteConfig writes cfg to path.

Types

type Exec

type Exec struct {
	ID          string     `json:"id"`          // random, unique per process
	Key         string     `json:"key"`         // the task key, see scenario.KeyArg
	Incarnation string     `json:"incarnation"` // SQILOAD_INCARNATION
	Role        string     `json:"role"`        // "main", "chatty" or "silent"
	PID         int        `json:"pid"`
	PGID        int        `json:"pgid"` // 0 on Windows
	Start       time.Time  `json:"start"`
	LastSeen    time.Time  `json:"last_seen"` // refreshed every 250ms while alive
	End         *time.Time `json:"end,omitempty"`
	ExitCode    int        `json:"exit_code"`
}

Exec is one process the no-op started: the main task process or a child.

func ReadAll

func ReadAll(dir string) (execs []Exec, skipped int, err error)

ReadAll reads every exec file in dir. Unreadable or torn files are skipped and counted. A missing directory holds no execs.

type NoopClass

type NoopClass struct {
	DurationMS  int  `json:"duration_ms"`
	LogEveryMS  int  `json:"log_every_ms"`
	ChattyChild bool `json:"chatty_child"`
	SilentChild bool `json:"silent_child"`
	// ScratchBytes is how many bytes the main process writes to scratch.bin
	// in its working directory over the duration.
	ScratchBytes int64 `json:"scratch_bytes"`
}

NoopClass is one class's real_task.

type NoopConfig

type NoopConfig struct {
	MarkerDir string               `json:"marker_dir"`
	Classes   map[string]NoopClass `json:"classes"`
}

NoopConfig is noop.json: where real tasks write their markers and how each job class with real_task behaves. A class it does not list behaves as the default no-op.

func ReadConfig

func ReadConfig(path string) (NoopConfig, error)

ReadConfig reads the noop.json at path.

type OutputLine

type OutputLine struct {
	ExecID string
	At     time.Time
}

OutputLine is one line of an output file.

type Writer

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

Writer keeps one exec file current.

func Begin

func Begin(dir, key, incarnation, role string) (*Writer, error)

Begin writes <dir>/execs/<id>.json for this process under a random ID and starts refreshing its LastSeen every 250ms.

func BeginID

func BeginID(dir, id, key, incarnation, role string) (*Writer, error)

BeginID is Begin under an ID the caller chose, as a parent that names its child's files before starting it does.

func (*Writer) Finish

func (w *Writer) Finish(exitCode int) error

Finish stops refreshing and writes End and ExitCode. Only the first call does anything.

func (*Writer) ID

func (w *Writer) ID() string

ID is the exec's ID.

Jump to

Keyboard shortcuts

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