diagnose

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 8 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 diagnose provides rule-based job failure diagnosis.

It matches logs and job state against local diagnosis rules. It should return diagnosis data to callers without owning run orchestration, persistence layout, or user-facing command formatting.

Index

Constants

View Source
const (
	// NoMatchNext follows a failure that no rule matched.
	NoMatchNext = "Inspect the full job output and scheduler accounting for the failure details."
	// UnavailableNext follows a diagnosis that could not read the output.
	UnavailableNext = "Resolve the read error, then inspect the full job output."
	// OutdatedNote marks a diagnosis saved under earlier rules; see Outdated.
	OutdatedNote = "Saved with earlier diagnosis rules; --filter-diagnosis selects by the current rules."
)

Guidance shown with a saved rule diagnosis by show and reports.

Variables

This section is empty.

Functions

func AnalyzeResult

func AnalyzeResult(result model.JobResult, log string, readErr error) model.JobResult

AnalyzeResult saves the default rule-based analysis on a failed result. A successful result, or one that already carries an analysis such as a result carried from an earlier run, is returned unchanged. A non-nil readErr means the job output could not be read, so the analysis is unavailable.

func Diagnose

func Diagnose(errorText, log string, rules []Rule) []model.RuleDiagnosis

Diagnose returns one diagnosis per matching rule, citing the rule's latest matching line. Diagnoses are ordered from the latest evidence to the earliest, because the error that ended a job is normally reported last and earlier matches may be warnings the job recovered from. The scheduler error is recorded after the job output, so it ranks as the latest evidence.

func DiagnoseDefault

func DiagnoseDefault(job Job) []model.RuleDiagnosis

func LastOutputLine added in v0.1.20

func LastOutputLine(log string) string

LastOutputLine returns the last nonblank line of log, without ANSI escapes, surrounding whitespace, or text a carriage return overwrote. It skips the lines TailLog and the stream headers add, which are not output.

func MatchesAny

func MatchesAny(value string, patterns []*regexp.Regexp) bool

func MatchesResultSelectors

func MatchesResultSelectors(selectors []string, result model.JobResult, log string) bool

MatchesResultSelectors reports whether a failed result, diagnosed with the current rules from its error and log, matches any selector. Saved diagnoses are ignored, and a success never matches.

func MatchesRuleSelectors

func MatchesRuleSelectors(selectors []string, job Job) bool

MatchesRuleSelectors recomputes diagnosis using the current default rules and reports whether any diagnosis matches a requested selector.

func Outdated

func Outdated(result model.JobResult) bool

Outdated reports whether a saved matched or no-match analysis was produced by rules other than the current ones. An unavailable analysis never ran the rules, and an unanalyzed result has nothing to refresh.

func ResolveRuleSelectors

func ResolveRuleSelectors(values []string) error

ResolveRuleSelectors validates diagnosis filter values. A slug ID is preferred; otherwise the display name is matched case-insensitively as a substring.

func RuleID

func RuleID(rule Rule) string

RuleID returns a stable selector ID derived from the public rule name; see model.FailureCauseID.

func RulesVersion

func RulesVersion() string

RulesVersion identifies the default rules and matcher. It is derived from the rule definitions, so any rule change produces a new version.

func TailLog

func TailLog(value string, limit int) string

Types

type Job

type Job struct {
	JobID    string
	ExitCode *int
	Error    string
	Log      string
}

type Rule

type Rule struct {
	Name       string
	Patterns   []*regexp.Regexp
	Excludes   []*regexp.Regexp
	Suggestion string
}

func DefaultRules

func DefaultRules() []Rule

Jump to

Keyboard shortcuts

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