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
- func AnalyzeResult(result model.JobResult, log string, readErr error) model.JobResult
- func Diagnose(errorText, log string, rules []Rule) []model.RuleDiagnosis
- func DiagnoseDefault(job Job) []model.RuleDiagnosis
- func LastOutputLine(log string) string
- func MatchesAny(value string, patterns []*regexp.Regexp) bool
- func MatchesResultSelectors(selectors []string, result model.JobResult, log string) bool
- func MatchesRuleSelectors(selectors []string, job Job) bool
- func Outdated(result model.JobResult) bool
- func ResolveRuleSelectors(values []string) error
- func RuleID(rule Rule) string
- func RulesVersion() string
- func TailLog(value string, limit int) string
- type Job
- type Rule
Constants ¶
const ( // NoMatchNext follows a failure that no rule matched. NoMatchNext = "Inspect the full job output and scheduler accounting for the failure details." 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 ¶
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
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 MatchesResultSelectors ¶
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 ¶
MatchesRuleSelectors recomputes diagnosis using the current default rules and reports whether any diagnosis matches a requested selector.
func Outdated ¶
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 ¶
ResolveRuleSelectors validates diagnosis filter values. A slug ID is preferred; otherwise the display name is matched case-insensitively as a substring.
func RuleID ¶
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.