Documentation
¶
Overview ¶
Package update is the panel side of the node-agent updates: it reads the release bundle the owner signed and dropped into <data-dir>/dist, shows whether it is trusted, serves its files to the node agents (only through the agent mTLS endpoint, see fleet.Updates), runs owner-triggered node updates (with a health gate and automatic rollback) whose state lives in the database, and serves the admin UpdateService.
The panel is a courier, not an authority: the agents verify the signature with the release key compiled into their own binary. Everything here that looks like a trust decision (TRUSTED) is for display and for refusing to start a pointless rollout.
It imports neither the fleet nor the health module except for one data type: the fleet is reached through the Fleet interface below (implemented by *fleet.Fleet), health through Health, and cmd/mistgate wires all directions.
Index ¶
- Constants
- Variables
- func PanelHelperRequestPending(dataDir string, now time.Time) bool
- func PanelOperationRunning(dataDir string, now time.Time) bool
- func PanelUpdateHostSupported() bool
- func PanelUpdateUsesRootHelperService() bool
- func RemovePanelRestoreRequest(dataDir string) error
- func RunPanelUpdateHelper(args []string) error
- func SortRolloutCandidates(nodes []*adminv1.NodeUpdate) int
- func WithWriteDeadline(ctx context.Context, set func(time.Time) error) context.Context
- func WriteDeadlineFromContext(ctx context.Context) func(time.Time) error
- func WritePanelRestoreResult(dataDir string, result PanelRestoreResult) error
- type Config
- type Fleet
- type GitHubNodeBundleConfig
- type GitHubNodeBundleSource
- type GitHubPanelUpdater
- func (u *GitHubPanelUpdater) Check(ctx context.Context) PanelUpdateStatus
- func (u *GitHubPanelUpdater) DeleteKeptData(ctx context.Context, name string) error
- func (u *GitHubPanelUpdater) Install(ctx context.Context, version, digest string) error
- func (u *GitHubPanelUpdater) Invalidate()
- func (u *GitHubPanelUpdater) ReleaseNotes() []ReleaseNote
- func (u *GitHubPanelUpdater) Restore(ctx context.Context, request PanelRestoreRequest) error
- func (u *GitHubPanelUpdater) Run(ctx context.Context)
- func (u *GitHubPanelUpdater) Status() PanelUpdateStatus
- type Health
- type NodeBundleSource
- type OsJobRequest
- type PanelKeptDeleteRequest
- type PanelKeptDeleteResult
- type PanelOperationState
- type PanelRestoreRequest
- type PanelRestoreResult
- type PanelUpdateConfig
- type PanelUpdateStatus
- type PanelUpdater
- type ReleaseNodeBinaries
- type ReleaseNote
- type RepoStars
- type Service
- func (s *Service) Conditions(ctx context.Context) []health.ExtCond
- func (s *Service) DeleteKeptData(ctx context.Context, name string) error
- func (s *Service) EdgeTick(ctx context.Context, now time.Time)
- func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)
- func (s *Service) LinkDownload(ctx context.Context, nodeID, name, token string) (string, error)
- func (s *Service) NetworkTableFile() (name, sha256 string)
- func (s *Service) NetworksTable() *asndb.DB
- func (s *Service) NodeBinary(goos, goarch string) string
- func (s *Service) OSUpdatesEnabled() bool
- func (s *Service) OpenNodeBinary(_ context.Context, goos, goarch string) (io.ReadCloser, int64, string, error)
- func (s *Service) OsStatusChanged(string)
- func (s *Service) OutdatedAgents(ctx context.Context) (version string, names []string)
- func (s *Service) PanelHostOsStatus() *agentv1.OsStatus
- func (s *Service) PanelUpdateRunning() bool
- func (s *Service) RecordAnswer(ctx context.Context, nodeID, requestID string, result *agentv1.CommandResult) error
- func (s *Service) RecordProgress(ctx context.Context, nodeID string, p *agentv1.UpdateProgress) error
- func (s *Service) Run(ctx context.Context)
- func (s *Service) Serve(ctx context.Context, nodeID, name string, offset uint64, ...) error
- func (s *Service) ServeWithWriteDeadline(ctx context.Context, nodeID, name string, offset uint64, ...) error
- func (s *Service) SetNetworkBundleChanged(callback func())
- func (s *Service) StartPanelRestore(ctx context.Context, request PanelRestoreRequest, beforeStart func() error) error
- func (s *Service) Updating(nodeID string) bool
- type Timing
- type UpdateAgentOptions
Constants ¶
const ( PanelRestoreResultFileName = "panel-restore.result" PanelKeptDeleteResultFileName = "panel-kept-delete.result" PanelRestoreStagePrefix = ".mistgate-backup-restore-" )
const GitHubReleaseListURL = "https://api.github.com/repos/Mistgate/mistgate/releases?per_page=30"
GitHubReleaseListURL lists the official repository's releases, newest first. Discovery and "What's new" share this conditionally fetched page.
const GitHubReleaseNotesURL = GitHubReleaseListURL
GitHubReleaseNotesURL remains the public name used by the application wiring.
const UpdateChannelSetting = "update_channel"
UpdateChannelSetting is the setting key that controls panel and node-bundle release discovery.
Variables ¶
var ( ErrNoPanelRelease = errors.New("no panel release is published on the selected channel") ErrNoPanelUpdate = errors.New("the panel is already up to date") ErrPanelUnsupported = errors.New("panel self-update requires a supported systemd update path") ErrPanelAssetMissing = errors.New("the selected release has no binary for this architecture") ErrPanelUnsigned = errors.New("the selected release has no panel manifest signed with this panel's release key") ErrPanelExpired = errors.New("the signed panel manifest of the selected release has expired") ErrPanelNoKey = errors.New("this panel build has no release key to verify panel releases") ErrPanelChanged = errors.New("the selected signed panel release is not the one that was confirmed") ErrPanelUpdateChannelNotAllowed = errors.New("panel_update_channel_not_allowed") ErrPanelUpdateChannelConfig = errors.New("panel_update_channel_config_invalid") )
var ErrGitHubNodeBundleMissing = errors.New("the selected GitHub release has no signed node bundle")
Functions ¶
func PanelHelperRequestPending ¶ added in v0.1.80
PanelHelperRequestPending reports whether a fresh helper request is waiting for its privileged unit to start.
func PanelOperationRunning ¶ added in v0.1.80
PanelOperationRunning reports a fresh or unreadable operation lock. A stale lock is ignored until a helper run removes it; the panel never needs write access beside its data directory.
func PanelUpdateHostSupported ¶
func PanelUpdateHostSupported() bool
PanelUpdateHostSupported reports whether this installation has the required systemd update path.
func PanelUpdateUsesRootHelperService ¶ added in v0.1.1
func PanelUpdateUsesRootHelperService() bool
PanelUpdateUsesRootHelperService reports whether a non-root panel should request the fixed privileged helper unit.
func RemovePanelRestoreRequest ¶ added in v0.1.80
RemovePanelRestoreRequest removes a stale helper request after the updater confirms that no helper is running.
func RunPanelUpdateHelper ¶
RunPanelUpdateHelper is the hidden command started by a transient systemd unit or the fixed root-owned helper service. It executes outside the panel service's ProtectSystem sandbox, fetches and verifies the release the owner confirmed, replaces only its own executable, restarts the configured unit and restores the backup if the new service does not stay healthy.
func SortRolloutCandidates ¶
func SortRolloutCandidates(nodes []*adminv1.NodeUpdate) int
SortRolloutCandidates applies the canary order used by StartRollout and returns its default batch size.
func WithWriteDeadline ¶
WithWriteDeadline passes the HTTP handler's per-response write deadline setter to streamed bundle responses.
func WriteDeadlineFromContext ¶
WriteDeadlineFromContext returns the HTTP response's write deadline setter when the handler attached one.
func WritePanelRestoreResult ¶ added in v0.1.80
func WritePanelRestoreResult(dataDir string, result PanelRestoreResult) error
WritePanelRestoreResult records a helper result when a scheduled restore helper exits without starting.
Types ¶
type Config ¶
type Config struct {
// DataDir holds dist/ (the bundle). Empty = no bundle directory at all (tests).
DataDir string
// Key is the release public key of this build (buildinfo.ReleasePublicKey); nil = an unsigned build: bundles are
// shown but never TRUSTED and no rollout can start.
Key ed25519.PublicKey
// PanelVersion and PanelBuilt describe this panel's own build (buildinfo.Version, buildinfo.BuiltUnix()).
PanelVersion string
PanelBuilt int64
// InitialChannel is seeded only when update_channel is unset, as by the installer's systemd environment.
InitialChannel string
// PanelUpdater checks official GitHub releases and schedules a checked panel binary replacement when available.
PanelUpdater PanelUpdater
// NodeBundleSource polls the official GitHub release for a bundle signed by this installation's release key.
// A trusted newer bundle is installed into dist and made available for owner-triggered node updates.
NodeBundleSource NodeBundleSource
// OSStatusReader enables the read-only panel-host snapshot on the VPS edition. Nil disables the reader (tests/edge).
OSStatusReader *osupdate.Reader
// Edge uses the panel's own signed release and link-only commands for node updates. RPC availability is edition policy.
Edge bool
// StepUp is auth.Service.RequireStepUp: every change calls it first. Required.
StepUp func(context.Context) error
// Actor returns the admin id for audit rows and for the rollout's created_by. Default: the signed-in admin.
Actor func(context.Context) string
Timing
Log *slog.Logger
Now func() time.Time // the clock (tests)
}
Config configures Service.
type Fleet ¶
type Fleet interface {
// Live reads the durable liveness projection for the fleet in one statement.
Live(ctx context.Context) ([]store.NodeLiveRow, error)
// NodeLive reads one node's durable liveness projection.
NodeLive(ctx context.Context, nodeID string) (store.NodeLiveRow, error)
// HasSession reports whether this panel process currently owns the node's agent stream.
HasSession(nodeID string) bool
// UpdateAgent sends a signed manifest and waits for the CommandResult (the download is part of it).
// FAILED_PRECONDITION when the node is not connected or did not list "update/1": nothing was sent.
UpdateAgentWithRequestID(ctx context.Context, nodeID, requestID string, manifest, signature []byte, wait, downloadTimeout time.Duration, options UpdateAgentOptions) (*agentv1.CommandResult, error)
// RollbackAgent asks the node to put its previous binary back; same preconditions.
RollbackAgent(ctx context.Context, nodeID string, wait time.Duration) (*agentv1.CommandResult, error)
// SendUpdateAgent hands an edge update command to the live node link without waiting for its result.
SendUpdateAgent(ctx context.Context, nodeID, requestID string, manifest, signature []byte, downloadToken string, deadline time.Time, downloadTimeout time.Duration) error
// SendRollbackAgent hands an edge rollback command to the live node link without waiting for its result.
SendRollbackAgent(ctx context.Context, nodeID, requestID string, deadline time.Time) error
// UpdateOs sends one OS job and waits up to wait for the CommandResult (params.state: started, running, finished or
// unsupported). FAILED_PRECONDITION when the node is offline or did not list "os-update/1": nothing was sent.
UpdateOs(ctx context.Context, nodeID string, req OsJobRequest, wait time.Duration) (*agentv1.CommandResult, error)
// CheckPortsForGate is the gate's second vantage point: the system port check of a node from another node (never the panel or
// the target itself). code is "" for a finished run, else the check's own error code ("no_sender", "same_host", ...).
CheckPortsForGate(ctx context.Context, nodeID string) (sender string, udp []store.PortCheck, tcp []store.TCPCheck, code string)
}
Fleet is what the module needs from the fleet module (*fleet.Fleet implements it).
type GitHubNodeBundleConfig ¶ added in v0.1.6
type GitHubNodeBundleConfig struct {
DataDir string
Key ed25519.PublicKey
Channel func() release.Channel
APIURL string
HTTPClient *http.Client
Now func() time.Time
Log *slog.Logger
}
GitHubNodeBundleConfig configures the signed agent-bundle source. Production uses the fixed official release API; the API URL and HTTP client are injectable for tests.
type GitHubNodeBundleSource ¶ added in v0.1.6
type GitHubNodeBundleSource struct {
// contains filtered or unexported fields
}
GitHubNodeBundleSource downloads node binaries from the newest release allowed by the panel's channel. It accepts a package only when the installation's pinned release key verifies its manifest and every file matches that manifest.
func NewGitHubNodeBundleSource ¶ added in v0.1.6
func NewGitHubNodeBundleSource(cfg GitHubNodeBundleConfig) *GitHubNodeBundleSource
func (*GitHubNodeBundleSource) BundleStatus ¶ added in v0.1.6
func (u *GitHubNodeBundleSource) BundleStatus() (bool, string)
BundleStatus reports whether the newest channel-visible signed GitHub bundle exactly matches the current manifest in dist/.
func (*GitHubNodeBundleSource) Prepare ¶
func (u *GitHubNodeBundleSource) Prepare() error
Prepare restores an interrupted bundle swap and removes old staging directories before the panel reads dist/.
type GitHubPanelUpdater ¶
type GitHubPanelUpdater struct {
// contains filtered or unexported fields
}
func NewGitHubPanelUpdater ¶
func NewGitHubPanelUpdater(cfg PanelUpdateConfig) *GitHubPanelUpdater
NewGitHubPanelUpdater creates a fail-closed checker. An unsupported installation can still read release metadata, but the RPC never schedules a binary replacement for it.
func (*GitHubPanelUpdater) Check ¶
func (u *GitHubPanelUpdater) Check(ctx context.Context) PanelUpdateStatus
Check fetches the newest channel-visible release and its signed panel manifest. A lookup made in the last few minutes is answered from memory: the button costs nothing, and the unauthenticated GitHub quota it shares with the node bundle sync is not spent on clicks.
func (*GitHubPanelUpdater) DeleteKeptData ¶ added in v0.1.80
func (u *GitHubPanelUpdater) DeleteKeptData(ctx context.Context, name string) error
DeleteKeptData asks the same privileged helper to remove one validated kept directory and waits for its durable result.
func (*GitHubPanelUpdater) Install ¶
func (u *GitHubPanelUpdater) Install(ctx context.Context, version, digest string) error
Install re-checks GitHub, requires the latest signed release to be exactly the version and digest the owner confirmed, records them for the helper and asks systemd to run the built-in helper outside the panel service's filesystem sandbox. The helper fetches and verifies the release again on its own before it replaces anything.
func (*GitHubPanelUpdater) Invalidate ¶ added in v0.1.80
func (u *GitHubPanelUpdater) Invalidate()
Invalidate makes the next explicit or scheduled check fetch the current channel immediately.
func (*GitHubPanelUpdater) ReleaseNotes ¶ added in v0.1.39
func (u *GitHubPanelUpdater) ReleaseNotes() []ReleaseNote
ReleaseNotes is the last list read from GitHub, newest first (empty until the first good read, and kept when a later read fails). It lives in memory only: the update check itself is not persisted either, and the next check (within minutes of a start) refills it.
func (*GitHubPanelUpdater) Restore ¶ added in v0.1.80
func (u *GitHubPanelUpdater) Restore(ctx context.Context, request PanelRestoreRequest) error
Restore asks the same privileged helper path as a panel update to swap in a verified restore stage.
func (*GitHubPanelUpdater) Run ¶
func (u *GitHubPanelUpdater) Run(ctx context.Context)
func (*GitHubPanelUpdater) Status ¶
func (u *GitHubPanelUpdater) Status() PanelUpdateStatus
type Health ¶
type Health interface {
// RunChecksNow schedules an immediate synthetic round for the inbounds of a node (rate limited to one per 30 s).
RunChecksNow(ctx context.Context, nodeID string) (scheduled, skipped int, retry time.Duration, err error)
// NodeChecksSince counts probeable inbounds and rounds ended at or after since; read errors are returned to the gate.
// timeoutsOnly: something failed and every failed round since was a timeout; failedFor: how long the failures have lasted.
NodeChecksSince(ctx context.Context, nodeID string, since time.Time) (probeable, ok, failed int, timeoutsOnly bool, failedFor time.Duration, err error)
}
Health is what the rollout gate needs from the health module (*health.Service implements it); nil = no probe gate.
type NodeBundleSource ¶ added in v0.1.6
type NodeBundleSource interface {
Sync(context.Context, int64) (changed bool, err error)
BundleStatus() (available bool, manifestSHA256 string)
}
NodeBundleSource fetches and verifies the latest signed node bundle from its release source. The current built value is zero when there is no trusted local bundle.
type OsJobRequest ¶
type OsJobRequest struct{ Action, Mode, Reboot, JobID string }
OsJobRequest is the enumerated content of UpdateOs (agent.proto): nothing else is ever sent to a node.
type PanelKeptDeleteRequest ¶ added in v0.1.80
type PanelKeptDeleteRequest struct {
Name string `json:"name"`
}
PanelKeptDeleteRequest names exactly one prior data directory for the root helper to remove.
type PanelKeptDeleteResult ¶ added in v0.1.80
type PanelKeptDeleteResult struct {
Outcome string `json:"outcome"`
Name string `json:"name"`
CompletedUnix int64 `json:"completed_unix"`
}
func ReadPanelKeptDeleteResult ¶ added in v0.1.80
func ReadPanelKeptDeleteResult(dataDir string) (PanelKeptDeleteResult, error)
type PanelOperationState ¶ added in v0.1.80
type PanelOperationState struct {
ID string `json:"id"`
Kind string `json:"kind"`
StartedUnix int64 `json:"started_unix"`
HeartbeatUnix int64 `json:"heartbeat_unix"`
RestoreRequest *PanelRestoreRequest `json:"restore_request,omitempty"`
}
func ReadPanelOperationState ¶ added in v0.1.80
func ReadPanelOperationState(dataDir string, now time.Time) (state PanelOperationState, active, exists bool, err error)
ReadPanelOperationState reads the helper's root-owned state file. A malformed or unreadable file is an error and callers must treat it as busy. exists distinguishes a stale file, which the next helper run removes, from no file.
type PanelRestoreRequest ¶ added in v0.1.80
type PanelRestoreRequest struct {
StageDir string `json:"stage_dir"`
Source string `json:"source"`
FileName string `json:"file_name"`
MadeByVersion string `json:"made_by_version"`
RequestedUnix int64 `json:"requested_unix,omitempty"`
}
PanelRestoreRequest is the metadata handed to the privileged helper. It contains no decryption key.
func ReadPanelRestoreRequest ¶ added in v0.1.80
func ReadPanelRestoreRequest(dataDir string) (PanelRestoreRequest, error)
ReadPanelRestoreRequest reconstructs an accepted restore after the panel process restarts.
type PanelRestoreResult ¶ added in v0.1.80
type PanelRestoreResult struct {
Outcome string `json:"outcome"`
Source string `json:"source"`
FileName string `json:"file_name"`
MadeByVersion string `json:"made_by_version"`
CompletedUnix int64 `json:"completed_unix"`
}
PanelRestoreResult is the helper's durable, non-secret result marker in the active data directory.
func ReadPanelRestoreResult ¶ added in v0.1.80
func ReadPanelRestoreResult(dataDir string) (PanelRestoreResult, error)
ReadPanelRestoreResult reads the durable helper result after the panel has restarted.
type PanelUpdateConfig ¶
type PanelUpdateConfig struct {
CurrentBuilt int64
DataDir string
ServiceUnit string
Executable string
// Key is the release public key compiled into this binary: the only key a panel release is accepted under (a
// release.pub in the data directory is writable by the panel's service user, so it never qualifies). Nil = no
// self-update.
Key ed25519.PublicKey
// Enabled is set only for a supported Linux systemd installation. Tests may set it explicitly.
Enabled bool
// UseRootHelperService makes Install request the fixed, root-owned helper unit. It is used by non-root panel
// services; the helper independently fetches and verifies the release before replacing the panel.
UseRootHelperService bool
// AllowedChannelFile is the root-owned channel policy shared with the helper. Production uses
// /etc/mistgate/panel-update-channel; it is configurable here so package tests can use a temporary file.
AllowedChannelFile string
// APIURL, HTTPClient, Runner, OS, Arch and Now are injectable test seams. Production uses the fixed Mistgate
// endpoint, the default GitHub client and the host values. Runner returns the command's standard output.
APIURL string
// Channel is read for each lookup, so changing update_channel applies without rebuilding the updater.
Channel func() release.Channel
HTTPClient *http.Client
Runner func(context.Context, string, ...string) ([]byte, error)
OS string
Arch string
Now func() time.Time
Log *slog.Logger
}
type PanelUpdateStatus ¶
type PanelUpdateStatus struct {
Version string
Channel release.Channel
URL string
PublishedUnix int64
CheckedUnix int64
Built int64
SHA256 string
Available bool
Supported bool
Installable bool
Installing bool
RunningNewer bool
ErrorKey string
}
PanelUpdateStatus is the release information exposed on the Updates screen. ErrorKey is a stable UI key, not an upstream error message. Built and SHA256 come from the release's signed panel manifest: the build time orders releases, and the digest of this architecture's binary is what an install must name back.
type PanelUpdater ¶
type PanelUpdater interface {
Status() PanelUpdateStatus
Check(context.Context) PanelUpdateStatus
// Install installs the latest signed release, only when it is the version and digest the owner confirmed.
Install(ctx context.Context, version, sha256 string) error
Run(context.Context)
}
PanelUpdater is the GitHub release checker and the privileged installer for the panel binary.
type ReleaseNodeBinaries ¶ added in v0.1.35
type ReleaseNodeBinaries struct {
// Version is the release tag this panel was built from (v1.2.3). A development build has no tag and gets an error.
Version string
// Key verifies the release manifest (buildinfo.ReleasePublicKey()).
Key ed25519.PublicKey
// Client fetches the files; nil uses a client that follows only GitHub's own redirects. Its Timeout, if any, also
// cuts the binary stream, so leave it unset and let the context bound the transfer.
Client *http.Client
// Base overrides releaseDownloadBase.
Base string
}
ReleaseNodeBinaries is a provision.BinarySource that has no bundle directory (the edge edition has no disk): it streams the node binary of this panel's own release from the release download URLs, so the node needs no route to GitHub. Trust is the compiled-in release key: the manifest must verify under Key, name this exact Version, be unexpired, and list the platform; the caller then checks the streamed bytes against the size and digest it gets back.
func (*ReleaseNodeBinaries) OpenNodeBinary ¶ added in v0.1.35
func (r *ReleaseNodeBinaries) OpenNodeBinary(ctx context.Context, goos, goarch string) (io.ReadCloser, int64, string, error)
OpenNodeBinary implements provision.BinarySource. The returned reader streams the binary; nothing is buffered.
type ReleaseNote ¶ added in v0.1.39
type ReleaseNote struct {
Version string
Channel release.Channel
URL string
PublishedUnix int64
En, Ru, Zh string
Security bool
}
ReleaseNote is one channel-visible release's description, split by language. The text is INFORMATIONAL and not signed: unlike the manifests it is whatever the GitHub release page says, fetched over HTTPS from the official repository. Nothing is decided from it except a badge ("security"); the SPA renders it as text, never as HTML.
type RepoStars ¶ added in v0.1.65
type RepoStars struct {
// contains filtered or unexported fields
}
RepoStars polls the GitHub API for one public repository's star count.
func NewRepoStars ¶ added in v0.1.65
NewRepoStars returns nil unless sourceURL is exactly a GitHub repository page.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the updates module.
func New ¶
New builds the module and reads the bundle directory once. Call Run to start the worker, fleet.SetUpdates and health.AddConditionSource (Conditions) to connect it.
func (*Service) Conditions ¶
Conditions is the health condition source (health.Service.AddConditionSource): while the active rollout is paused because a step failed, the gate failed or the panel lost track of a step, UPDATE_FAILED is raised; resuming, cancelling or a new rollout makes it go away. A pause by the owner or by a changed bundle raises nothing.
func (*Service) DeleteKeptData ¶ added in v0.1.80
DeleteKeptData reserves the shared panel-update and rollout gate while the privileged helper deletes a kept directory.
func (*Service) EdgeTick ¶ added in v0.1.50
EdgeTick runs one bounded edge pass. Every send is synchronous, so its context is also the upper bound on the service mutex held around that send. The cron's scheduled time is used only for the prune schedule.
func (*Service) Handler ¶
Handler is the admin UpdateService (see fleet.NodeHandler for how it is mounted behind the session).
func (*Service) LinkDownload ¶ added in v0.1.50
LinkDownload authorizes one file of the manifest pinned to a SENT step. The manifest was verified before the rollout was created; the token digest is the only per-request secret stored in D1.
func (*Service) NetworkTableFile ¶
NetworkTableFile returns the trusted bundle file for node streams, when present.
func (*Service) NetworksTable ¶
NetworksTable returns the immutable panel-side table loaded off the request path. Nil means absent or invalid.
func (*Service) NodeBinary ¶
NodeBinary is fleet.Updates.NodeBinary: the absolute path of the platform's file of the current trusted bundle, "" without one. The path is the one the last scan verified; Serve re-checks the file itself, scp of the owner does not need to.
func (*Service) OSUpdatesEnabled ¶
OSUpdatesEnabled tells Fleet whether it may ask capable streams for the read-only status snapshot.
func (*Service) OpenNodeBinary ¶
func (s *Service) OpenNodeBinary(_ context.Context, goos, goarch string) (io.ReadCloser, int64, string, error)
OpenNodeBinary opens a verified node binary from the current trusted bundle (provision.BinarySource; the file is local, so the context is unused). The caller receives the signed manifest's digest as well and must verify the bytes it transfers: the descriptor is stable across path replacement, while an in-place write can still change bytes after this method returns.
func (*Service) OsStatusChanged ¶
OsStatusChanged is called when a node's snapshot or an OS event arrived: a step that follows its job looks now.
func (*Service) OutdatedAgents ¶ added in v0.1.23
OutdatedAgents is the version of the release the nodes are compared with (the trusted bundle's, else this panel's own) and the names of the connected nodes that run an older build and could be updated. The Telegram alerts tell it once per version.
func (*Service) PanelHostOsStatus ¶
PanelHostOsStatus is the last in-process read from the panel's own host. It does not start a read.
func (*Service) PanelUpdateRunning ¶ added in v0.1.80
PanelUpdateRunning reports whether the shared helper is scheduled or running. The restore coordinator uses it to recover if systemd accepted a restore request but the helper never started.
func (*Service) RecordAnswer ¶ added in v0.1.48
func (s *Service) RecordAnswer(ctx context.Context, nodeID, requestID string, result *agentv1.CommandResult) error
RecordAnswer stores the first agent result for a recorded update or rollback request. The step store rejects stale, duplicate, or no-longer-active requests; detail is bounded before the proto is persisted.
func (*Service) RecordProgress ¶
func (s *Service) RecordProgress(ctx context.Context, nodeID string, p *agentv1.UpdateProgress) error
RecordProgress persists the latest valid frame on the rollout step. This is deliberately a database operation: the edge edition receives frames in one isolate and serves GetUpdates from another.
func (*Service) Run ¶
Run drives the worker, the bundle poll and the retention sweep until ctx ends, then waits for the command goroutines it started.
func (*Service) Serve ¶
func (s *Service) Serve(ctx context.Context, nodeID, name string, offset uint64, send func(chunk []byte, total uint64) error) error
Serve is fleet.Updates.Serve: it streams one file of the current trusted bundle to an agent that already authenticated with its node certificate. Only names in the trusted manifest are served. Live downloads are limited to maxServes; a same-file resume can replace its node's live slot while the old handler finishes its write. The descriptor is opened once, so a file replaced during a download cannot corrupt it.
func (*Service) ServeWithWriteDeadline ¶
func (s *Service) ServeWithWriteDeadline(ctx context.Context, nodeID, name string, offset uint64, setWriteDeadline func(time.Time) error, send func(chunk []byte, total uint64) error) error
ServeWithWriteDeadline streams one file and bounds each response write with the handler's HTTP write deadline.
func (*Service) SetNetworkBundleChanged ¶
func (s *Service) SetNetworkBundleChanged(callback func())
SetNetworkBundleChanged registers the callback that asks live streams to reconcile after the trusted table digest changes.
func (*Service) StartPanelRestore ¶ added in v0.1.80
func (s *Service) StartPanelRestore(ctx context.Context, request PanelRestoreRequest, beforeStart func() error) error
RestorePanelData reserves the panel-update/rollout gate before asking the updater's systemd helper to swap verified restore data into place. The helper's Installing state holds the reservation after this call returns.
type Timing ¶
type Timing struct {
Tick time.Duration // worker period; default 5 s
Rescan time.Duration // bundle directory poll; default 60 s
BundlePoll time.Duration // GitHub agent bundle poll; default 10 min
GitHubSourceCheck time.Duration // bound for the optional GitHub manifest check; default 10 s
AnswerWait time.Duration // UpdateAgent: the agent's CommandResult, download included; default 10 min
ReconnectWait time.Duration // after the answer: the node is back with the new build; default 3 min
GateWait time.Duration // after the reconnect: the gate passes or fails; default 5 min
RollbackWait time.Duration // RollbackAgent answer; default 60 s
InboundGrace time.Duration // an inbound FAILED that long (two evaluations) fails the gate at once; default 30 s
Prune time.Duration // retention sweep period; default 6 h
OsAnswerWait time.Duration // UpdateOs: the node's CommandResult; default 45 s
OsResendAfter time.Duration // an unanswered, unseen job id is sent again after this, then after twice this; default 90 s
OsJobWait time.Duration // a job that shows nothing for this long after it was sent fails the step; default 90 min (the unit lives 75 min, then 10 of waiting and 2 of settling)
OsBackWait time.Duration // after the reboot began: the node is back on a new boot; default 15 min
OsGateWait time.Duration // after it is back (or the job ended): the checks pass; default 8 min, the node's own settling takes up to 5
OsRefreshGap time.Duration // one refresh of the package lists per node in this time; default 30 min
}
Timing of the module. The zero value is production; tests shorten what they need.
type UpdateAgentOptions ¶
type UpdateAgentOptions struct {
Sources []string
}
UpdateAgentOptions carries optional fields for an agent that advertised the matching capability.
Source Files
¶
- bundle.go
- bundle_auto.go
- changelog.go
- download_sources.go
- edge.go
- fs_nofollow_unix.go
- github_bundle.go
- nodes.go
- os_rollout.go
- os_rollout_rpc.go
- os_status.go
- os_wait.go
- panel_operation.go
- panel_restore.go
- panel_restore_request.go
- panel_restore_rollout.go
- panel_update.go
- panel_update_channel_linux.go
- panel_update_elf.go
- panel_update_helper.go
- panel_update_host_linux.go
- progress.go
- reason.go
- record_answer.go
- release_binaries.go
- rename_exchange_linux.go
- restore_journal.go
- rollout.go
- rpc.go
- schedule.go
- stars.go
- timeout.go
- update.go
- vantage.go