Documentation
¶
Overview ¶
Package reconcile defines restart-safe assignment recovery decisions.
Index ¶
- Variables
- type Action
- type AssignmentState
- type AssignmentWorker
- type Claim
- type Decision
- type FailureClass
- type PostgresStore
- func (store *PostgresStore) AdvanceFencedGeneration(ctx context.Context, assignmentID string, expectedRevision int64, ...) (int64, error)
- func (store *PostgresStore) ApplyDecision(ctx context.Context, claim Claim, decision Decision, ...) error
- func (store *PostgresStore) ClaimNext(ctx context.Context, workerID string, claimExpiresAt time.Time, now time.Time) (Claim, bool, error)
- func (store *PostgresStore) Close()
- func (store *PostgresStore) MarkExpiredRunners(ctx context.Context, heartbeatCutoff time.Time, now time.Time) (int64, error)
- func (store *PostgresStore) RequestRunnerDrain(ctx context.Context, runnerID string, drainCommand *runnerv1.DrainCommand, ...) error
- type WorkerStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrClaimLost = errors.New("SecondBox reconciliation claim is no longer current") ErrFenceProofAbsent = errors.New("SecondBox reconciliation cannot advance without fence proof") )
Functions ¶
This section is empty.
Types ¶
type AssignmentState ¶
type AssignmentState struct {
State string
Generation int64
FenceProofDigest string
FailureClass FailureClass
RetryCount int
RetryLimit int
Deadline time.Time
}
AssignmentState is durable evidence used to compute one reconciliation action.
type AssignmentWorker ¶
type AssignmentWorker struct {
Store WorkerStore
WorkerID string
ClaimDuration time.Duration
PollInterval time.Duration
CommandDeadline time.Duration
HeartbeatTimeout time.Duration
NewCommandID func(string) string
}
AssignmentWorker reconciles deadline and Runner-loss evidence without process-local ownership.
type Claim ¶
type Claim struct {
AssignmentID string
SandboxID string
InstanceID string
RunnerID string
WorkerID string
FencingToken []byte
Correlation *runnerv1.Correlation
Revision int64
State AssignmentState
ClaimExpiresAt time.Time
}
Claim is one revision-fenced bounded reconciliation work item.
type Decision ¶
Decision is one idempotent action. Runner loss can advance authority only through the current home runner's durable local Workspace receipt.
func DecideAssignment ¶
func DecideAssignment(state AssignmentState, now time.Time) Decision
DecideAssignment classifies bounded retry, deadlines, and terminal failures.
func DecideRunnerLoss ¶
func DecideRunnerLoss(state AssignmentState, now time.Time) Decision
DecideRunnerLoss fences uncertain compute before queuing a local generation advance.
type FailureClass ¶
type FailureClass string
const ( FailureTransient FailureClass = "transient" FailureCompatibility FailureClass = "compatibility" FailureFencing FailureClass = "fencing" FailureStartupTimeout FailureClass = "startup_timeout" )
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore coordinates restart-safe reconciliation workers.
func NewPostgresStore ¶
func NewPostgresStore(ctx context.Context, databaseURL string) (*PostgresStore, error)
NewPostgresStore connects the reconciler to PostgreSQL authority.
func (*PostgresStore) AdvanceFencedGeneration ¶
func (store *PostgresStore) AdvanceFencedGeneration( ctx context.Context, assignmentID string, expectedRevision int64, now time.Time, ) (int64, error)
AdvanceFencedGeneration converts proven Runner loss into the same runner-local generation-advance boundary used by an ordinary stop. It never relocates the Sandbox or advances PostgreSQL ahead of the home runner's durable receipt.
func (*PostgresStore) ApplyDecision ¶
func (store *PostgresStore) ApplyDecision( ctx context.Context, claim Claim, decision Decision, fenceCommand *runnerv1.FenceCommand, nextReconcileAt time.Time, now time.Time, ) error
ApplyDecision commits one idempotent revision-fenced reconciliation transition.
func (*PostgresStore) ClaimNext ¶
func (store *PostgresStore) ClaimNext( ctx context.Context, workerID string, claimExpiresAt time.Time, now time.Time, ) (Claim, bool, error)
ClaimNext leases one due assignment using SKIP LOCKED across control-plane replicas.
func (*PostgresStore) Close ¶
func (store *PostgresStore) Close()
func (*PostgresStore) MarkExpiredRunners ¶
func (store *PostgresStore) MarkExpiredRunners( ctx context.Context, heartbeatCutoff time.Time, now time.Time, ) (int64, error)
MarkExpiredRunners makes assignments uncertain without authorizing replacement.
func (*PostgresStore) RequestRunnerDrain ¶
func (store *PostgresStore) RequestRunnerDrain( ctx context.Context, runnerID string, drainCommand *runnerv1.DrainCommand, now time.Time, ) error
RequestRunnerDrain records the admission barrier before a Drain command is sent.
type WorkerStore ¶
type WorkerStore interface {
MarkExpiredRunners(context.Context, time.Time, time.Time) (int64, error)
ClaimNext(context.Context, string, time.Time, time.Time) (Claim, bool, error)
ApplyDecision(context.Context, Claim, Decision, *runnerv1.FenceCommand, time.Time, time.Time) error
AdvanceFencedGeneration(context.Context, string, int64, time.Time) (int64, error)
}
WorkerStore owns durable Assignment claims, commands, and generation advancement.