failure

package
v1.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package failure classifies a failed, held or unhealthy deploy into one structured object shared by the API, CLI and MCP surfaces.

Index

Constants

View Source
const (
	CodeDockerfileError     = "dockerfile_error"
	CodeDependencyInstall   = "dependency_install_failed"
	CodeCompileError        = "compile_error"
	CodeBuildStepFailed     = "build_step_failed"
	CodeBuildConfigError    = "build_config_error"
	CodeBuildOOM            = "build_out_of_memory"
	CodeBuildTimeout        = "build_timeout"
	CodeImagePullFailed     = "image_pull_failed"
	CodeRegistryAuthFailed  = "registry_auth_failed"
	CodeRegistryRateLimited = "registry_rate_limited"
	CodePlatformMismatch    = "platform_mismatch"
	CodeLockfileOutOfSync   = "lockfile_out_of_sync"
	CodePortNotListening    = "port_not_listening"
	CodeHealthCheckFailed   = "health_check_failed"
	CodeContainerCrashed    = "container_crashed"
	CodeOOMKilled           = "oom_killed"
	CodeMissingEnv          = "missing_env"
	CodeRegistryPushFailed  = "registry_push_failed"
	CodeDiskFull            = "disk_full"
	CodeNodeOutOfRoom       = "node_out_of_room"
	CodeImageCorrupt        = "image_corrupt"
	CodeFreezeWindow        = "freeze_window_hold"
	CodeApprovalPending     = "approval_pending"
	CodeScanGateBlocked     = "scan_gate_blocked"
	CodeRollbackTargetGone  = "rollback_target_gone"
	CodeDockerUnreachable   = "docker_unreachable"
	CodeBuildEngineNoBuild  = "build_engine_unsupported"
	CodeGitHostUnreachable  = "git_host_unreachable"
	CodeSourceNotCached     = "source_not_cached"
	CodeUnknown             = "unknown"
)

Failure codes.

View Source
const (
	EnvExcerptLines = "APP_FAILURE_EXCERPT_LINES"
	EnvExcerptBytes = "APP_FAILURE_EXCERPT_BYTES"
)

Env vars that bound the log excerpt.

View Source
const EnvRolloutCrashLoopRestarts = "APP_DEPLOY_ROLLOUT_CRASHLOOP_RESTARTS"

EnvRolloutCrashLoopRestarts is how many restarts a rollout that never served may take before its CrashLoopBackOff counts as a failed deploy.

Variables

RolloutFailureReasons are the reconcile condition reasons that mean a finished build did not converge into a healthy container.

Functions

func IsRolloutCrashLoop

func IsRolloutCrashLoop(reason, message string, limit int) bool

IsRolloutCrashLoop reports a CrashLoopBackOff condition whose restart count reached limit.

func RolloutCrashLoopRestarts

func RolloutCrashLoopRestarts(lookup func(string) (string, bool)) int

RolloutCrashLoopRestarts reads EnvRolloutCrashLoopRestarts from lookup.

Types

type Condition

type Condition struct {
	Reason  string
	Message string
}

Condition is one failing reconcile condition.

type Failure

type Failure struct {
	Code         string    `json:"code"`
	Cause        string    `json:"cause"`
	FailingStep  string    `json:"failing_step,omitempty"`
	LogExcerpt   string    `json:"log_excerpt,omitempty"`
	SuggestedFix string    `json:"suggested_fix"`
	DocsURL      string    `json:"docs_url"`
	Retryable    bool      `json:"retryable"`
	AlsoMatched  []string  `json:"also_matched,omitempty"`
	Fixes        []Fix     `json:"fixes,omitempty"`
	DeployID     string    `json:"deploy_id"`
	App          string    `json:"app"`
	At           time.Time `json:"at"`
}

Failure is the structured description of why a deploy did not succeed.

func Classify

func Classify(in Input, opts Options) (Failure, bool)

Classify returns the Failure for in, or false when the deploy is not in a failing or blocked state.

type Fix

type Fix struct {
	Code   string `json:"code"`
	Kind   string `json:"kind"`
	Target string `json:"target,omitempty"`
	Hint   string `json:"hint"`
	Match  string `json:"match"`
}

Fix is a typed build-log suggestion: Kind says whether the control plane or the operator acts, Target names where a guided fix lives.

type Input

type Input struct {
	App         string
	DeployID    string
	Status      string
	Reason      string
	Error       string
	FailingStep string
	Condition   *Condition
	LogLines    []string
	Crashloop   bool
	At          time.Time
}

Input is everything Classify reads. Only Status is required.

type Options

type Options struct {
	MaxLines int
	MaxBytes int
	// DocsBase prefixes guide links; empty keeps them as site-relative paths.
	DocsBase string
}

Options bound the log excerpt.

func OptionsFromEnv

func OptionsFromEnv(lookup func(string) (string, bool)) Options

OptionsFromEnv reads Options from lookup, falling back to defaults.

Jump to

Keyboard shortcuts

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