agentbinary

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package agentbinary installs and switches agent binaries from release archives.

Index

Constants

This section is empty.

Variables

View Source
var ErrActivationInProgress = errors.New("host agent activation is already in progress")

ErrActivationInProgress indicates that another host agent activation owns the shared activation lock.

Functions

func EnsureDaemonBinaryLinks(ctx context.Context, log *slog.Logger, paths goalstates.AgentUpgradePaths) error

EnsureDaemonBinaryLinks initializes daemon current, last-good, and compatibility binary links.

func Verify

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

Verify runs the installed agent binary's version command.

Types

type ActivationOptions added in v0.2.3

type ActivationOptions struct {
	Layout        Layout
	CandidatePath string
	BinaryMode    os.FileMode
	LockPath      string
}

ActivationOptions configures a host-driven daemon binary activation.

type ActivationPlan added in v0.2.3

type ActivationPlan struct {
	CandidatePath    string
	ActivePath       string
	TargetPath       string
	CurrentLinkPath  string
	LastGoodLinkPath string
	RollbackPath     string
	InitializeLayout bool
	CandidateChanged bool
	RepairLastGood   bool
	UpdateLastGood   bool
	Service          ServicePlan
	Actions          []string
	// contains filtered or unexported fields
}

ActivationPlan describes a host activation without changing host state.

func PreflightHostDaemonActivation added in v0.2.3

func PreflightHostDaemonActivation(
	ctx context.Context,
	opts ActivationOptions,
	service DaemonServiceInspector,
) (ActivationPlan, error)

PreflightHostDaemonActivation validates and plans a host-driven activation without changing files, links, services, or locks.

type ActivationResult added in v0.2.3

type ActivationResult struct {
	PreviousPath string
	CurrentPath  string
	Initialized  bool
	Changed      bool
	RolledBack   bool
}

ActivationResult describes a completed host activation.

func ActivateHostDaemon added in v0.2.3

func ActivateHostDaemon(
	ctx context.Context,
	log *slog.Logger,
	opts ActivationOptions,
	service DaemonService,
) (ActivationResult, error)

ActivateHostDaemon installs the candidate, switches the daemon entrypoint, restarts the service, verifies health, and rolls back on restart or health failure.

type DaemonService added in v0.2.3

type DaemonService interface {
	DaemonServiceInspector
	Prepare(context.Context, string) error
	Reload(context.Context) error
	Restart(context.Context) error
	WaitHealthy(context.Context, string) error
}

DaemonService adapts host-specific service management to binary activation.

type DaemonServiceInspector added in v0.2.3

type DaemonServiceInspector interface {
	Preflight(context.Context, string) (ServicePlan, error)
}

DaemonServiceInspector inspects host-specific service configuration without changing it.

type HostActivationLock added in v0.2.3

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

HostActivationLock is an exclusive lock shared by host-driven and MachineOperation-driven agent activation paths.

func AcquireHostActivationLock added in v0.2.3

func AcquireHostActivationLock(path string) (*HostActivationLock, error)

AcquireHostActivationLock acquires the shared, nonblocking host activation lock. The caller must close the returned lock.

func (*HostActivationLock) Close added in v0.2.3

func (l *HostActivationLock) Close() error

Close releases the host activation lock.

type InstallOptions added in v0.2.3

type InstallOptions struct {
	DownloadURL string
	// ExpectedSHA256 may be empty only when the caller trusts both the archive
	// source and the transport path.
	ExpectedSHA256    string
	ExpectedMember    string
	Mode              os.FileMode
	MaxArchiveBytes   int64
	MaxExtractedBytes int64
	HTTPClient        *http.Client
	ExactMember       bool
}

InstallOptions configures a bounded agent release archive install.

type Layout added in v0.2.3

type Layout struct {
	// BinaryPath is an optional compatibility path included in collision validation.
	BinaryPath   string
	BluePath     string
	GreenPath    string
	CurrentPath  string
	LastGoodPath string
}

Layout describes caller-owned blue-green agent binary paths.

type ServicePlan added in v0.2.3

type ServicePlan struct {
	UpdateRequired bool
	Description    string
}

ServicePlan describes service configuration work needed by an activation.

type SwitchResult added in v0.2.3

type SwitchResult struct {
	PreviousPath string
	CurrentPath  string
}

SwitchResult describes a completed blue-green binary switch.

func InstallAndSwitchFromTarGz

func InstallAndSwitchFromTarGz(
	ctx context.Context,
	log *slog.Logger,
	paths Layout,
	opts InstallOptions,
) (SwitchResult, error)

InstallAndSwitchFromTarGz downloads a bounded HTTP or HTTPS release archive, installs the configured member into the inactive slot, and atomically updates the last-good and current links. When ExactMember is set, the archive must contain only the exact configured base name.

Jump to

Keyboard shortcuts

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