updaterecord

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 42 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	UpdateMarkerMaxAgeSeconds  = 20 * 60
	CreateTimeToleranceSeconds = 2.0

	EmptyMarkerGraceSeconds = 5.0
	MarkerName              = ".icebath-update-in-progress"
	CheckoutLockName        = ".icebath-update.lock"
	GitCheckoutLockName     = "icebath-update.lock"
	HandoffPIDEnv           = "ICEBATH_UPDATE_HANDOFF_PID"
	UpdateExitConcurrent    = 2
)
View Source
const (
	OwnPIDTmpStaleSeconds         = 60.0
	MutexSuffix                   = ".lock"
	MutexWaitSeconds              = 10.0
	CheckoutContentionWaitSeconds = 3.0
	CreateSuspended               = 0x00000004
)
View Source
const (
	HostObligationName = "host-update-restart.json"
	ProfileMarkerName  = "fleet_restart_pending"
)
View Source
const (
	PauseRecordStem       = ".icebath-update-paused-gateways"
	PauseMutexName        = PauseRecordStem + ".lock"
	PauseMutexWaitSeconds = 10.0
)
View Source
const (
	CommandBoundaryStopReason = "completed at command boundary"
	ExternalState             = "external"
	RestartPendingState       = "restart_pending"
	FollowupRetryDefault      = "the next launch or `icebath update` retries it"
)
View Source
const UpdateAvailableNoCount = -1

Behind count of a source check that knows an update exists but not how many commits it is

Variables

View Source
var (

	// Follow-up steps whose failure leaves the source update tail owed
	TailFollowups = map[string]bool{"dependencies": true, "launchers": true, "feature_dependencies": true,
		"maintenance": true, "profile_sync": true, "config_migration": true, "completion": true}
	// Follow-ups meaning the build stage did not succeed
	BuildFollowups = map[string]bool{"launchers": true, "feature_dependencies": true, "completion": true}
)
View Source
var StableTagRE = regexp.MustCompile(`^v(?:0|[1-9]\p{Nd}{0,2})\.(?:0|[1-9]\p{Nd}*)\.(?:0|[1-9]\p{Nd}*)$`)

Stable release tag shape, a three digit major cap keeping CalVer tags out

Functions

func AbandonPause

func AbandonPause(ctx context.Context, intended, adopted map[string]any) error

Puts only an adopted orphan set back on disk unowned after this run rolled its own stops back

func AdoptPauseOrphans

func AdoptPauseOrphans(ctx context.Context) (map[string]any, []string, error)

Claims every orphaned pause for the update command and merges their sets

func AdoptTerminalReceipt

func AdoptTerminalReceipt(ctx context.Context, data any)

A completion child finalized this command's run so its terminal outcome becomes this scope's

func AmendTerminalFollowup

func AmendTerminalFollowup(ctx context.Context, updateID, step, reason string) error

Appends a follow-up that failed after finalize to the run's closed receipt

func ArmHostObligation

func ArmHostObligation(ctx context.Context, marker, expectedSHA string, runtimes []any, profile, owner string) (bool, error)

Arms the host record else the per home marker, false when the debt is hidden, an error for an unserializable inventory

func BeginUpdateReceipt

func BeginUpdateReceipt(ctx context.Context, previous *jsonutil.Object, correlationID string)

Starts a durably running receipt, restoring any enclosing one when it finalizes

func BindChildToUpdateTree

func BindChildToUpdateTree(pid int) error

Binds an update tree child to the kill on close job, POSIX children inherit the lock descriptor instead

func BuildVersion

func BuildVersion() string

Release tag or git describe text the build stamped, empty for an unstamped build

func CheckoutHeld

func CheckoutHeld() bool

Reports whether this process holds or joined the checkout lock

func CheckoutLockFiles

func CheckoutLockFiles(installRoot string) ([]*os.File, error)

Descriptors an update tree child inherits so the checkout stays locked while it runs, POSIX only

func CheckoutLockHeld

func CheckoutLockHeld(ctx context.Context, installRoot string) (bool, error)

Reports whether any process holds the checkout kernel lock, by a shared try that never blocks a holder

func CheckoutLockPath

func CheckoutLockPath(installRoot string) (string, error)

Checkout lock of an install, inside its common git dir for a checkout, the running install when empty

func ClaimPause

func ClaimPause(ctx context.Context, src string) (string, map[string]any, bool, error)

Takes an orphaned record or a dead claimer's claim for this process, false when another launch won it

func ClearCurrentReceipt

func ClearCurrentReceipt(ctx context.Context)

Forgets the open receipt of the context's scope the way the tests reset current

func ClearHostObligation

func ClearHostObligation()

Discharges the record this install's readers judged, never failing

func CollapseUnitsToHostProcesses

func CollapseUnitsToHostProcesses(units []string, mainPID func(string) (int, error)) ([]string, map[string]string)

Splits units into restarts and legacy units covered by another unit sharing their live main pid

func CommittedSuccess

func CommittedSuccess(ctx context.Context) bool

True when this command's run is closed and its receipt says success

func CurrentCorrelationID

func CurrentCorrelationID(ctx context.Context) *string

Update correlation id of the open receipt in this context, nil when none is open

func CustodySpawnFiles

func CustodySpawnFiles() []*os.File

Extra files that keep a checkout mutator child in the update tree's custody, none without a held lock

func DeathSignalAttr

func DeathSignalAttr() *syscall.SysProcAttr

Process attributes that kill a child with its owner thread, nil where the platform has no such signal

func DescribeHolder

func DescribeHolder(holder *UpdateHolder) string

User facing explanation of who holds the update lock or why it could not be taken

func DischargePause

func DischargePause(ctx context.Context, token map[string]any, path string) error

Removes the record only while it still names this pause, decided under the mutex

func DropNeverStopped

func DropNeverStopped(token map[string]any) (map[string]any, error)

Drops entries still served by the same live incarnation that this update never asked to stop

func FinalizeInterruptedUpdateReceipt

func FinalizeInterruptedUpdateReceipt(ctx context.Context, stopReason string, exitCode int) string

Closes a run interrupted after the commit point as interrupted

func FinalizePendingUpdateReceipt

func FinalizePendingUpdateReceipt(ctx context.Context, exitCode *int, stopReason string) string

Command boundary safety net that persists a still open receipt with the exit's outcome

func FinalizeUpdateReceipt

func FinalizeUpdateReceipt(ctx context.Context, outcome string, fleet []any, stopReason string) string

Finalizes and persists the open receipt exactly once, returning its archive path or empty

func FinalizedReceipt

func FinalizedReceipt(updateID string) *jsonutil.Object

Deep copy of the terminal record this process finalized for an update id, nil when none

func FinishPause

func FinishPause(ctx context.Context, token, intended, adopted map[string]any) (map[string]any, error)

Carries the recorded pause identity onto the final token and mirrors it to disk

func GatewayExitCodePath

func GatewayExitCodePath(h string) string

File the gateway update watcher polls for the finished update's exit status

func GetCodeIdentity

func GetCodeIdentity(refresh bool) (*jsonutil.Object, error)

Flat sha, short sha, version, source and commit date identity, re-resolved when refresh is set

func GitArgv

func GitArgv(gitCmd, args []string) []string

Joins the git command and args with the custody config inserted before the subcommand

func GitCommonDir

func GitCommonDir(root string) (string, error)

Common git dir of the checkout at root read from disk, empty when root is no checkout

func GitErrorStopClass

func GitErrorStopClass(err error) *string

Closed stop token for a failed git command about to end the run, nil for anything else

func GitExecutable

func GitExecutable(ctx context.Context) string

Git the updater runs, PATH's first and then the one pm recorded or staged

func GitOutputStopClass

func GitOutputStopClass(output string, argv []string, returncode *int) *string

Stop token for a git call that returned instead of raising

func GitSubcommand

func GitSubcommand(args []string) string

First non option argument after the git executable, skipping global options and their values

func HeadSHA

func HeadSHA(ctx context.Context, root string) string

Commit HEAD names, empty when git cannot read it

func HoldsCheckoutLock

func HoldsCheckoutLock(installRoot string) (bool, error)

Reports whether this process holds or joined the checkout lock of installRoot

func HostObligationPath

func HostObligationPath() string

This install's host obligation record, keyed by the normcased install root

func HostObligationPresent

func HostObligationPresent() bool

True when the record file exists, parseable or not

func HostRestartAlreadyCompleted

func HostRestartAlreadyCompleted(sha string) bool

True when this host obligation already restarted onto sha

func HostStateDir

func HostStateDir() string

Host state dir the gateway rendezvous resolves, computed here without importing the gateway

func IdentityLine

func IdentityLine(pid int) string

Marker line three for pid, empty when its creation time is unreadable

func IncarnationLive

func IncarnationLive(pid int, recordedCT any) *bool

Whether the process identity pid and recordedCT runs now, nil when alive but unprovable

func IsLocalMutator

func IsLocalMutator(args []string) bool

Reports whether args run a git subcommand that writes this machine's worktree, index or refs

func IsPauseRecordError

func IsPauseRecordError(err error, kind string) bool

Whether err is the pause record failure of the given kind (RecordConflict, RecordBusy, RetiredUnknown, RecordUnknown)

func JudgeMarker

func JudgeMarker(raw []byte, w *World) (string, *int, *string)

Verdict malformed, dead, ours or live of marker bytes with the live owner and the first run id

func LatestReceiptObject

func LatestReceiptObject(ctx context.Context) *jsonutil.Object

Exported readLatestReceipt keeping the ordered object

func LoadReceiptFile

func LoadReceiptFile(path string) (any, error)

Exported loadJSONFile

func MarkCustodyRan

func MarkCustodyRan()

Records that an update child already ran in custody, so a later refusal says steps had run

func MarkHostRestartCompleted

func MarkHostRestartCompleted(ctx context.Context, sha string)

Records that the host process restarted onto sha, never failing

func MarkMove

func MarkMove(ctx context.Context, token map[string]any, target string) error

Persists this pause's move target before git writes the tree, an error meaning the move must not run

func MarkStopAccepted

func MarkStopAccepted(path string, marker *jsonutil.Object) error

Receipt that this incarnation accepted the stop, beside the marker or stamped into it in place

func MarkStopConsumed

func MarkStopConsumed(path string, marker *jsonutil.Object, sameHome func(left, right string) (bool, error)) error

Checkpoints a validated gateway stop consume into every matching record before its marker disappears

func MarkStopRequested

func MarkStopRequested(ctx context.Context, token map[string]any, pids []int, markers map[int]string) error

Persists the intended stops and each mapped gateway's marker path before the first stop request

func MarkStopSent

func MarkStopSent(ctx context.Context, token map[string]any, pid int) error

Persists that pid's stop request was issued, an unwritable record warning instead of failing

func MarkerMutex

func MarkerMutex(ctx context.Context, path string, wait time.Duration) (context.Context, func(), error)

Holds the marker sidecar lock, reentrant along ctx, MarkerBusy after wait

func MarkerMutexPath

func MarkerMutexPath(path string) string

Sidecar every marker mutation holds a kernel lock on, never deleted

func MergePauseInto

func MergePauseInto(token, adopted map[string]any) (map[string]any, error)

Folds an orphaned pause into this update's token so one resume brings both sets back

func ObligationFields

func ObligationFields() map[string]string

Obligation in the legacy key value field shape, nil when unarmed

func OweFollowup

func OweFollowup(ctx context.Context, updateID *string, step, reason, retry string) error

Records a failed post commit step on the open run, else amends the run's closed receipt

func OwnerAlive

func OwnerAlive(record *jsonutil.Object) bool

Exported ownerAlive

func OwnerWatch

func OwnerWatch(pid int) func()

Starts the owner death watcher for a child leading its own session, nil when it cannot start

func PauseAcceptedPath

func PauseAcceptedPath(markerPath string) string

Accepted receipt written beside a planned stop marker

func PauseIdentity

func PauseIdentity(pid int) map[string]any

Pid and ct line identity of a process, this process when pid is zero

func PauseIdentityIsLive

func PauseIdentityIsLive(ident map[string]any) bool

Update marker incarnation rule for a recorded identity, unprovable counting as live

func PauseInstallRoot

func PauseInstallRoot() string

func PauseMutex

func PauseMutex(ctx context.Context, wait time.Duration) (context.Context, func(), error)

Exclusive kernel lock on the record sidecar, reentrant along ctx, RecordBusy after wait

func PauseRecordPath

func PauseRecordPath() string

Paused gateway record of this install in the profile tree root home

func PauseUnowned

func PauseUnowned() map[string]any

Owner identity of a record nobody holds

func PersistRunningReceipt

func PersistRunningReceipt(ctx context.Context)

Re-asserts the open running run on disk

func ProcessCreateTime

func ProcessCreateTime(pid int) *float64

Creation time of pid in unix seconds on the clock psutil reports, the stdlib probe when that fails

func PsutilParent

func PsutilParent(pid int) (int, bool, error)

PsutilParent exposes the psutil parent of pid to the gateway orphan reaper

func ReadCheckoutSHA

func ReadCheckoutSHA() (*string, error)

Commit of the running install re-read now, the stamp's first and the build revision second

func ReadHostObligation

func ReadHostObligation() *jsonutil.Object

Published obligation record, nil when absent, corrupt or another version

func ReadLatestReceipt

func ReadLatestReceipt(ctx context.Context) map[string]any

Most recent update receipt across the stores of this home, nil when none parses

func ReadPauseRecord

func ReadPauseRecord(path string) (map[string]any, error)

Saved pause body, nil only when absent, RecordUnknown when it cannot be read or parsed

func ReadRunRecord

func ReadRunRecord(ctx context.Context, updateID string) (string, *jsonutil.Object, bool)

The run's own archive path and record in the root store in key order, never latest.json

func ReceiptDir

func ReceiptDir(ctx context.Context) string

Exported receiptDir

func ReceiptDirs

func ReceiptDirs(ctx context.Context) []string

Exported receiptDirs

func ReceiptPayload

func ReceiptPayload(data any, indent bool) ([]byte, error)

Exported receiptPayload

func ReconcileInterruptedRuns

func ReconcileInterruptedRuns(ctx context.Context) []map[string]any

Marks running records whose processes are gone as interrupted and returns them

func RecordBuildStage

func RecordBuildStage(ctx context.Context, followups [][2]string)

Marks the build stage failed only when a build follow-up is owed

func RecordFact

func RecordFact(ctx context.Context, key string, value any)

Sets one top level receipt field

func RecordFollowup

func RecordFollowup(ctx context.Context, step, reason, retry string)

Prints the owed follow-up protocol line and records it on the open run

func RecordGatewayRestart

func RecordGatewayRestart(ctx context.Context, g GatewayRestart)

Records the gateway restart phase outcome

func RecordPause

func RecordPause(ctx context.Context, token, adopted map[string]any, claims []string) (map[string]any, error)

Merges the adopted set, stamps the tree and persists under this process before the first stop

func RecordSkip

func RecordSkip(ctx context.Context, name, reason string)

Records a skipped step with the reason it was skipped

func RecordStage

func RecordStage(ctx context.Context, name, outcome string, facts *jsonutil.Object)

Marks the end of a pipeline stage and refreshes the durable running record

func RecordStep

func RecordStep(ctx context.Context, name string, ok bool, detail string)

Records one update step outcome

func RecordStopReason

func RecordStopReason(ctx context.Context, reason string)

Names the closed stop token of the exit about to stop this run

func RecordUserAction

func RecordUserAction(ctx context.Context, step, reason string)

Records a committed run's owed user action so it finalizes partial

func RecoverPauses

func RecoverPauses(ctx context.Context, argv []string) error

Start of run recovery resuming every orphaned pause, the update command and a booting gateway excepted

func RefusalNotice

func RefusalNotice(command string) *string

Text the failure path prints for this run's refused update child, nil when none was refused

func ReleaseCheckout

func ReleaseCheckout()

ReleaseCheckout exports releaseCheckout

func ReleaseHostObligation

func ReleaseHostObligation(ctx context.Context, owner string) error

Hands back owner's stake, restoring what the first owner found once no other run owes through it

func ReleasePauseClaims

func ReleasePauseClaims(ctx context.Context, claims []string) error

Deletes the claims a merged record now carries, a busy mutex leaving them for the redundancy sweep

func ReplaceBytes

func ReplaceBytes(path string, data []byte) error

Writes data as one durable record through a fresh 0600 temp file renamed over path

func ResetCurrentReceipt

func ResetCurrentReceipt(ctx context.Context)

Restores the receipt that was open before the current one began, the reset of its begin token

func ResetCustodyRun

func ResetCustodyRun() func()

Clears the run's refused child and ran flag and returns the call that restores them

func ResetVersionInfoCache

func ResetVersionInfoCache()

ResetVersionInfoCache exports resetVersionInfoCache

func ResumeReceipt

func ResumeReceipt(ctx context.Context, data *jsonutil.Object)

Opens an existing run from its persisted data under its own identity, restoring the enclosing receipt when it finalizes

func ResumeRunRecord

func ResumeRunRecord(ctx context.Context) string

Carries the open run forward from its archive, returning the archive when the run is already closed

func ResumeSuspendedChild

func ResumeSuspendedChild(process *os.Process) error

Resumes a suspended update child, POSIX children never start suspended

func RetirePauseRedundant

func RetirePauseRedundant(ctx context.Context, path string) error

Deletes copies of obligations another file already carries, a busy mutex skipping the sweep

func RowIsExternal

func RowIsExternal(row any) bool

Whether a fleet row serves an install this update did not touch

func RunFile

func RunFile(directory string, data *jsonutil.Object) string

Exported runFile

func SetBuildVersion

func SetBuildVersion(version string)

Records the release tag or git describe text the build stamped into main.version

func SetObligationStderr

func SetObligationStderr(w io.Writer) func()

Points the obligation warnings at w and returns the call that restores the previous writer

func SetPauseGatewayResumer

func SetPauseGatewayResumer(resume func(ctx context.Context, token map[string]any, stdout io.Writer) error)

Installs the Windows gateway resume a recovering launch runs, called by the update command package

func SetPlannedStopProbe

func SetPlannedStopProbe(probe PlannedStopProbe)

Installs the gateway planned stop marker rules, called by the gateway package

func SetRuntimeHostMatcher

func SetRuntimeHostMatcher(match func([]string) bool)

Installs the command line test naming a long lived icebath host, called by pkg/selfupdate

func SplitDraining

func SplitDraining(token map[string]any) (map[string]any, error)

Removes and returns the profiles, unmapped and supervised entries whose process is still draining

func StampTree

func StampTree(ctx context.Context, token map[string]any, root string) (map[string]any, error)

Adds this pause's tree baseline once per pause id beside the baselines of absorbed pauses

func SyncPause

func SyncPause(ctx context.Context, token map[string]any) error

Mirrors the token after a resume attempt, deleting a finished record and rewriting an owed one

func TornByMove

func TornByMove(ctx context.Context, root string, found map[string]any, changes []string, changesKnown bool) ([]string, bool, error)

Paths a move from found's HEAD wrote that lack the current commit's bytes, false when git cannot say

func TrackedChanges

func TrackedChanges(ctx context.Context, root string) ([]string, bool)

Sorted tracked paths differing from HEAD in index or worktree, false when git cannot say

func TreeIsWhole

func TreeIsWhole(ctx context.Context, token map[string]any, root string) (bool, string, error)

Whether paused gateways may start on this checkout now, with the reason when not

func TreeState

func TreeState(ctx context.Context, root string) map[string]any

HEAD, the tracked changes and their digests now, nil when root is not a git checkout

func UpdateInProgress

func UpdateInProgress(ctx context.Context, installRoot string) (bool, error)

Reports whether an update owns the install, by a live marker or a held checkout lock

func UpdateMarkerPath

func UpdateMarkerPath() string

Shared update marker in the profile tree root home every update owner watches

func UpdateReceiptScope

func UpdateReceiptScope(ctx context.Context) context.Context

Context with no open receipt and a fresh terminal cell, keeping the command guard off an enclosing update

func UserAgent

func UserAgent(product string) (string, error)

Product slash base version for an outbound request header

func WriteGatewayUpdateExitCode

func WriteGatewayUpdateExitCode(ctx context.Context, ok bool)

Publishes 0 or 1 atomically for the gateway watcher, a run already committed as success never reads failed

func WriteHostObligation

func WriteHostObligation(ctx context.Context, expectedSHA string, runtimes []any, profile, owner string) bool

Arms the host obligation, true when written, runtimes nil standing for no inventory

func WriteLatest

func WriteLatest(ctx context.Context, payload []byte) error

Exported writeLatest

func WritePause

func WritePause(ctx context.Context, token, owner map[string]any, path string) error

Persists token keeping this pause's owner, merging a dead pause's orphaned set and refusing a live one

Types

type CustodyRefused

type CustodyRefused struct{ Reason string }

Windows refused to bind an update child to the update job so the child never ran

func RefuseCustodyChild

func RefuseCustodyChild(ctx context.Context, argv []string, cause any, receipted bool) *CustodyRefused

Refusal for argv, logged and receipted unless the caller already did, kept as this run's first refusal

func (*CustodyRefused) Error

func (e *CustodyRefused) Error() string

type GatewayRestart

type GatewayRestart struct {
	RestartedServices            []string
	RelaunchedProfiles           []string
	ExternallySupervisedProfiles []string
	KilledPIDs                   []int
	FailedUnits                  []string
	Incomplete                   bool
	PhaseError                   string
	FreshRecovery                map[string]any
}

Gateway restart phase outcome, FreshRecovery nil when the fresh recovery pass did not run

type GitResult

type GitResult struct {
	Args       []string
	ReturnCode int
	Stdout     string
	Stderr     string
}

Captured outcome of one git child with text mode output

func RunGitQuery

func RunGitQuery(ctx context.Context, gitCmd, args []string, timeout time.Duration) (*GitResult, error)

Runs a read only git query in the updater's custody, refusing an argv that writes the checkout

type GitTimeout

type GitTimeout struct {
	Args    []string
	Timeout time.Duration
}

Git child that outlived its timeout and was killed with its tree

func (*GitTimeout) Error

func (e *GitTimeout) Error() string

type KeyErrorText

type KeyErrorText struct{ Key string }

Failure naming a missing mapping key

func (*KeyErrorText) Error

func (e *KeyErrorText) Error() string

type MarkerBusy

type MarkerBusy struct{ Path string }

func (*MarkerBusy) Error

func (e *MarkerBusy) Error() string

type PauseFile

type PauseFile struct {
	Src  string
	Body map[string]any
}

PauseFile is one record or claim of this install with its parsed body

func PauseOrphans

func PauseOrphans(ctx context.Context, path string) ([]PauseFile, error)

Every obligation of this install whose holder is dead, empty while another update is live

type PauseRecordError

type PauseRecordError struct {
	Kind string
	Msg  string
}

Pause record failure that callers treat as Python's OSError family

func (*PauseRecordError) Error

func (e *PauseRecordError) Error() string

func (*PauseRecordError) OSError

func (e *PauseRecordError) OSError() bool

Marks the error as an OSError subclass for callers that catch that family

type PlannedStopProbe

type PlannedStopProbe struct {
	TTL       int
	IsStale   func(writtenAt any, ttl int) bool
	StartTime func(pid int) any
}

PlannedStopProbe carries the gateway status rules a stop request is judged by

type ProfileHome

type ProfileHome struct {
	Profile string
	Home    string
}

ProfileHome pairs a profile name with its home directory

func ProfileHomes

func ProfileHomes() ([]ProfileHome, error)

Default home plus every valid named profile dir in name order, an error when the profiles root is unreadable

type StampError

type StampError struct{ Msg string }

RuntimeError a malformed install stamp raises

func (*StampError) Error

func (e *StampError) Error() string

type UpdateHolder

type UpdateHolder struct {
	PID        int
	AgeSeconds float64
	Reason     string
	Held       bool
}

func AcquireCheckout

func AcquireCheckout(installRoot string) (*UpdateHolder, error)

AcquireCheckout exports acquireCheckout

func LegacyProfileClaims

func LegacyProfileClaims(root string) []UpdateHolder

Live claims in pre root marker files under root/profiles, read only and in directory order

func ReadLiveUpdate

func ReadLiveUpdate(ctx context.Context, path, installRoot string) (holder *UpdateHolder)

Live update holding the marker, a held holder while the checkout lock outlives a dead claim, nil when clear

type UpdateLock

type UpdateLock struct {
	Path          string
	InstallRoot   string
	CheckoutFirst bool
	Acquired      bool
	Holder        *UpdateHolder
	// contains filtered or unexported fields
}

func NewUpdateLock

func NewUpdateLock(path, installRoot string, checkoutFirst bool) *UpdateLock

Update lock over the shared marker, path empty for the root marker, installRoot empty for this install

func (*UpdateLock) Acquire

func (l *UpdateLock) Acquire(ctx context.Context) (bool, error)

Takes the checkout lock when asked, then claims or adopts the marker, false with Holder set when refused

func (*UpdateLock) AcquireCheckout

func (l *UpdateLock) AcquireCheckout(installRoot string) (bool, error)

Takes or joins the checkout lock a caller mutates the install under

func (*UpdateLock) Release

func (l *UpdateLock) Release(ctx context.Context)

Gives back this incarnation's part of the claim under the marker mutex, only the outermost claim releasing

type UpdateReceipt

type UpdateReceipt struct {
	Data          *jsonutil.Object
	CorrelationID string
	// contains filtered or unexported fields
}

Observable facts of one icebath update run

func CurrentReceipt

func CurrentReceipt(ctx context.Context) *UpdateReceipt

Open receipt of the context's scope, nil when none has begun

func NewUpdateReceipt

func NewUpdateReceipt() *UpdateReceipt

Fresh running receipt carrying argv, pid, pre update identity and a new correlation id

func (*UpdateReceipt) Fact

func (r *UpdateReceipt) Fact(key string, value any) error

Sets one top level field

func (*UpdateReceipt) Finalize

func (r *UpdateReceipt) Finalize(outcome string)

Closes the receipt, partial when a committed run still owes a user action

func (*UpdateReceipt) Followup

func (r *UpdateReceipt) Followup(step, reason string) error

Records a post commit step the run still owes

func (*UpdateReceipt) GatewayRestartResult

func (r *UpdateReceipt) GatewayRestartResult(g GatewayRestart) error

Records the gateway restart phase with the conservative fresh recovery buckets

func (*UpdateReceipt) Skip

func (r *UpdateReceipt) Skip(name, reason string) error

Records a skipped step with its reason

func (*UpdateReceipt) Stage

func (r *UpdateReceipt) Stage(name, outcome string, facts *jsonutil.Object) error

Marks a stage end whose duration is the gap since the previous mark, facts following in call order

func (*UpdateReceipt) Step

func (r *UpdateReceipt) Step(name string, ok bool, detail string) error

Records one step outcome

type VersionInfo

type VersionInfo struct {
	BaseVersion    string
	DerivedVersion string
	Distance       *int64
	Commit         *string
	Branch         *string
	Source         string
	Dirty          bool
	CommitDate     *int64
	Distribution   *string
}

func GetVersionInfo

func GetVersionInfo() (VersionInfo, error)

Cached provenance from the install stamp, then the build identity, then unknown

func GitVersionInfo

func GitVersionInfo(repoDir string, includeUntracked bool) VersionInfo

Identity of a checkout read from git itself, a status over three seconds reading as clean

type World

type World struct {
	PID   int
	CT    *float64
	Now   float64
	Alive func(int) bool
	CTOf  func(int) *float64
}

Jump to

Keyboard shortcuts

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