Documentation
¶
Overview ¶
Package lifecycle defines the controller's view of a job's phases and the rules that move a job between them. It is deliberately small: the jobagent inside each container owns the fine-grained execution state; the controller only needs a coarse phase per run plus a restart policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanTransition ¶
CanTransition reports whether from → to is a legal edge.
Types ¶
type Phase ¶
type Phase string
Phase is the controller-level state of a run. It is a superset of the jobagent phases: the controller adds Submitted (accepted but not yet launched) and Cancelled (a user-requested stop, distinct from a job that finished on its own).
type RestartPolicy ¶
type RestartPolicy struct {
MaxAttempts int // 0 disables automatic restart
BaseBackoff time.Duration // backoff = BaseBackoff * 2^(attempt-1), capped
MaxBackoff time.Duration
}
RestartPolicy bounds automatic restarts of a job whose desired state is running but whose container exited unexpectedly.
func DefaultRestartPolicy ¶
func DefaultRestartPolicy() RestartPolicy
DefaultRestartPolicy is a conservative default: a few tries with exponential backoff.
func (RestartPolicy) Backoff ¶
func (p RestartPolicy) Backoff(attempt int) time.Duration
Backoff returns how long to wait before the given attempt number (1-based). Exponential, capped at MaxBackoff.
func (RestartPolicy) ShouldRestart ¶
func (p RestartPolicy) ShouldRestart(phase Phase, attempt int) bool
ShouldRestart reports whether a run that just reached `phase` on its `attempt` should be restarted. Only unexpected failures restart; a clean Finished or a user Cancelled does not.