firecrackerbootprobelease

package
v0.0.0-...-804b954 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package firecrackerbootprobelease owns the private persisted lease guard for one sealed Firecracker boot probe.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidState identifies a malformed or non-canonical persisted boot-probe lease state.
	ErrInvalidState = errors.New("invalid Firecracker boot-probe lease state")
	// ErrRenewalRefused identifies a stale, forked, mismatched, or non-successive authenticated renewal.
	ErrRenewalRefused = errors.New("Firecracker boot-probe renewal refused")
	// ErrLeaseExpired identifies an expired lease that must remain cleanup-pending.
	ErrLeaseExpired = errors.New("Firecracker boot-probe lease expired")
	// ErrProbeAlreadyStarted identifies a duplicate probe-start transition.
	ErrProbeAlreadyStarted = errors.New("Firecracker boot probe already started")
)

Functions

func Encode

func Encode(state State) ([]byte, error)

Encode writes canonical private state bytes suitable for persistence or replay.

Types

type Guard

type Guard struct {
	// contains filtered or unexported fields
}

Guard serializes transitions for one recovered or newly sealed State. Persist callers store Snapshot with their own expected-version/CAS boundary; Guard prevents in-process renewal forks.

func NewGuard

func NewGuard(initial firecrackerlaunchgrant.Grant, now time.Time) (*Guard, error)

NewGuard seals an already-authenticated initial grant into an active private lease state.

func Restore

func Restore(state State) (*Guard, error)

Restore recovers a Guard from an already-decoded, validated state snapshot.

func (*Guard) AdvanceTime

func (guard *Guard) AdvanceTime(now time.Time) (State, error)

AdvanceTime records expiry as cleanup-pending. It never infers cleanup and never revives an expired lease.

func (*Guard) RecordProbeStarted

func (guard *Guard) RecordProbeStarted(now time.Time) (State, error)

RecordProbeStarted records one durable probe-start intent without launching a Jailer, VMM, guest, or PING.

func (*Guard) RenewAuthenticated

func (guard *Guard) RenewAuthenticated(renewal firecrackerlaunchgrant.Grant, now time.Time) (State, error)

RenewAuthenticated accepts exactly the next already-authenticated renewal for this Guard. Callers authenticate the M3 envelope and derive the trusted M4 identity before passing renewal here. A renewal changes only Current and RenewalCount; it cannot create a new probe-start authorization.

func (*Guard) Snapshot

func (guard *Guard) Snapshot() State

Snapshot returns the exact serializable state after the last accepted transition.

type Phase

type Phase string

Phase is the durable lifecycle phase of a private boot-probe lease.

const (
	// PhaseActive means the current grant is not yet expired and may be renewed or recorded as started.
	PhaseActive Phase = "active"
	// PhaseExpiredCleanupPending means expiry was observed and no later transition may revive or launch the probe.
	PhaseExpiredCleanupPending Phase = "expired-cleanup-pending"
)

type Probe

type Probe string

Probe is the persisted, effect-free boot-probe intent state.

const (
	// ProbePending means no probe start was durably recorded.
	ProbePending Probe = "pending"
	// ProbeStarted means the one allowed probe start was durably recorded; a restart or renewal must never start it again.
	ProbeStarted Probe = "started"
)

type State

type State struct {
	Version          string                       `json:"version"`
	Initial          firecrackerlaunchgrant.Grant `json:"initial"`
	Current          firecrackerlaunchgrant.Grant `json:"current"`
	Phase            Phase                        `json:"phase"`
	Probe            Probe                        `json:"probe"`
	ProbeStartedAt   time.Time                    `json:"probe_started_at,omitempty"`
	CleanupPendingAt time.Time                    `json:"cleanup_pending_at,omitempty"`
	RenewalCount     uint64                       `json:"renewal_count"`
}

State is the serializable, redacted snapshot for one sealed private boot-probe lease. Initial never changes. Current advances only through the next exact authenticated delivery tuple and fence. The state includes no control signature, raw request, credential, host path, or guest output.

func Decode

func Decode(wire []byte) (State, error)

Decode reads one canonical persisted private state snapshot.

func (State) CleanupPending

func (state State) CleanupPending() bool

CleanupPending reports whether expiry has been durably surfaced for operator-owned cleanup.

func (State) Validate

func (state State) Validate() error

Validate verifies that State is a redacted replay-safe snapshot of one linear lease chain.

Jump to

Keyboard shortcuts

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