Documentation
¶
Overview ¶
Package osreadiness says whether this machine could be upgraded to the next release of its operating system, and why not. It is a report and nothing else: it reads. It writes nothing under /etc, /var/lib/dpkg, /var/lib/apt or /var/cache/apt, makes no cache, lock or file under /var, /etc or /run, starts and stops no service (the daemons whose sockets would start them, Docker's and snapd's, are asked only when their service runs), and makes no request to the network. What it does leave is said here, and nowhere else is anything: dkms 3.x makes and removes a temporary file in $TMPDIR while "dkms status" runs; dpkg's lock files are opened to read, and the kernel is asked whether another process holds a lock on them (F_GETLK), which takes none (that is the box's side of the report, in service/); and a file that is read has its access time, where the file system keeps one. Those are all: nothing else of the machine is the report's to change, which the invariance proof of CI checks on real machines.
That is a property of the seam, not a promise of the checks: a check sees the machine only through a Probe, which has no method that writes, creates, removes or starts anything, and the commands it may run are an allow-list (see Allowed) that the engine enforces whatever the Probe is. A check that errors, times out, panics or has no tool to ask is a refusal that says it does not know (Result.Data["unknown"]), never an ok.
Checks are a table. A group of checks is a file that registers its rows from init (see register and Check); Run runs the rows that apply to the box's hop, four at a time, within 20 seconds.
Index ¶
- Constants
- Variables
- func Allowed(argv []string) bool
- func AptFalse(value string) bool
- func AptSourceName(name string) bool
- func BusyUnits() []string
- func DockerPresent(ctx context.Context, p Probe) (bool, error)
- func HeldPackages(ctx context.Context, p Probe) (docker, others []string, err error)
- func IsMirrorList(uri string) bool
- func IsSuiteAlias(suite string) bool
- func SourceHost(uri string) string
- func SourceIsLocal(uri string) bool
- func SourceScheme(uri string) string
- func SplitSuite(suite string) (base, suffix string)
- func Text(r Report) string
- type Action
- type Answer
- type Check
- type Counts
- type D
- type Deb822Field
- type Deb822Stanza
- type DistroDecider
- type FileInfo
- type Finding
- type Group
- type Hop
- type HopID
- type Options
- type Output
- type Probe
- type Release
- type Report
- type Result
- type Session
- type Severity
- type SourceFile
Constants ¶
const ( // DefaultTimeout is how long a check has unless it asks for more. DefaultTimeout = 5 * time.Second // DefaultBudget is how long the whole report has. DefaultBudget = 20 * time.Second // DefaultConcurrency is how many checks run at once. DefaultConcurrency = 4 )
const ( ReasonTimeout = "timeout" ReasonNotFinished = "not_finished" ReasonToolMissing = "tool_missing" ReasonTooLarge = "too_large" ReasonMissing = "missing" ReasonUnreadable = "unreadable" ReasonNotAllowed = "not_allowed" ReasonUnexpectedOutput = "unexpected_output" ReasonPanic = "panic" ReasonInvalid = "invalid_result" ReasonFailed = "failed" // ReasonClock: the date of the machine is before the day the table of the releases was written, so // the table cannot be read against it. ReasonClock = "clock" // ReasonStale: the table of the releases is more than eighteen months old, so it cannot say what upgrade a // release has: this ReCasaOS is too old to know it. ReasonStale = "stale" )
The reasons a check could not say, as they are in Data["reason"] of a finding that is unknown.
const ( MaxSourceFiles = maxSourceFiles MaxSourceEntries = maxSourceEntries MaxSourceComponents = maxSourceComponents // MaxSourceLookups is how many Release files are looked at, in all, to tell the mirrors of the distribution from // the others. MaxSourceLookups = maxReleaseLookups )
The bounds of what a machine's sources can cost, as the report applies them (sources.go).
const ( // MaxFileBytes is the most ReadFile returns; a larger file is ErrTooLarge. MaxFileBytes = 1 << 20 // MaxOutputBytes is the most of a command's output that Run returns; the rest is cut and // Output.Truncated says so. MaxOutputBytes = 1 << 20 )
The bounds of what the seam gives back: nothing a check reads is unbounded.
const ( // StateUnsupported: the box is not one the upgrade is for (an unknown system, a variant, an // architecture that is not proven). Only the checks of that are reported. StateUnsupported = "unsupported" // StateLatest: the newest release the table knows. Nothing else was checked. StateLatest = "latest" // StateBlocked: at least one refusal. StateBlocked = "blocked" // StateAttention: no refusal, at least one warning. StateAttention = "attention" // StateReady: neither. StateReady = "ready" )
The states of a Report.
const DockerHost = dockerHost
DockerHost is the host of Docker's own package source, and only that host.
const MaxTextBytes = 8 << 10
MaxTextBytes is the most Text is long: it is pasted into a forum, a ticket, a message.
Variables ¶
var ( // ErrToolMissing is the error of Run for a command that is not installed. ErrToolMissing = errors.New("the tool is not installed") // ErrTooLarge is the error of ReadFile for a file larger than MaxFileBytes. ErrTooLarge = errors.New("the file is too large") // ErrNotAllowed is the error of Run for a command that is not on the allow-list. ErrNotAllowed = errors.New("the command is not on the allow-list") )
Functions ¶
func Allowed ¶
Allowed says whether argv is a command the report may run. argv[0] is a bare command name.
func AptFalse ¶ added in v0.4.73
AptFalse says whether apt reads a value of an option as false (no, false, without, off, disable, 0).
func AptSourceName ¶ added in v0.4.73
AptSourceName says whether apt reads a file of that name in sources.list.d.
func BusyUnits ¶ added in v0.4.75
func BusyUnits() []string
BusyUnits are those units, for whoever asks the same question (the module assistant asks them with the units that update ReCasaOS): a copy, in the order they are asked.
func DockerPresent ¶ added in v0.4.73
DockerPresent says whether there is a Docker on the box, from its client or its socket and without asking a daemon.
func HeldPackages ¶ added in v0.4.73
HeldPackages are the packages on hold, the Docker engine's apart from the others, as the report reads them.
func IsMirrorList ¶ added in v0.4.97
IsMirrorList says whether an address is a list of mirrors of the form mirrorListURI.
func IsSuiteAlias ¶ added in v0.4.73
IsSuiteAlias says whether a suite is a name that stands for whichever release is current (stable, oldstable...).
func SourceHost ¶ added in v0.4.73
SourceHost is the host an address names, lower case; "" when it names none.
func SourceIsLocal ¶ added in v0.4.73
SourceIsLocal says whether the address is a disc, a file or a copy: a source that is on the machine.
func SourceScheme ¶ added in v0.4.73
SourceScheme is the transport of a source's address, lower case.
func SplitSuite ¶ added in v0.4.73
SplitSuite is a suite without its suffix: "bullseye-security" is "bullseye" and "-security".
Types ¶
type Action ¶
type Action string
An Action is the one thing the report suggests doing about a finding, as a code the page translates.
const ( ActionRestartMachine Action = "restart_machine" ActionFinishDpkg Action = "finish_dpkg" ActionWaitForPackageManager Action = "wait_for_package_manager" ActionWaitForApps Action = "wait_for_apps" ActionFreeDiskSpace Action = "free_disk_space" ActionReleaseHolds Action = "release_holds" ActionReviewSources Action = "review_sources" ActionNone Action = "none" )
type Answer ¶
Answer is what the API gives: the Report, and the same as plain text for "copy the report", so that the page never builds it.
type Check ¶
type Check struct {
// Code is the stable name of the finding: the page, the proof in CI and the owner's copy of
// the report all use it.
Code string
Group Group
// Title is what the check is about, in English ("dpkg's state"): the title of the finding
// when Run gives none, and of a check that could not be made.
Title string
// Hops are the hops the check applies to; none means all of them.
Hops []HopID
// Timeout is how long Run has: 5 seconds when zero.
Timeout time.Duration
// Gate marks the checks of the identity of the box. If one of them refuses, the box is not
// one the upgrade is for (state "unsupported"), and only the ones that refuse are reported.
Gate bool
Run func(ctx context.Context, p Probe) Result
}
A Check is one row of the table. Run is given the context of the check (it ends at Timeout, and at the budget of the whole report) and a Probe, and returns what it found. It must not panic and must not wait without that context, but if it does the engine answers for it.
type Counts ¶
type Counts struct {
Refuse int `json:"refuse"`
Warn int `json:"warn"`
OK int `json:"ok"`
Info int `json:"info"`
}
Counts is how many findings of each severity.
type Deb822Field ¶ added in v0.4.97
A Deb822Field is a field of a stanza of a .sources file: its name as written, its lines (what follows the colon on the first one, then the lines that go on from it, each without the white space around it), and the numbers of its first and last lines in the file (from 1). A comment between its lines is not one of them.
type Deb822Stanza ¶ added in v0.4.97
type Deb822Stanza struct {
Fields []Deb822Field
First, Last int
}
A Deb822Stanza is a stanza of a .sources file: its fields in the order they are written, and the numbers of its first and last lines that are not comments.
func ReadDeb822 ¶ added in v0.4.97
func ReadDeb822(text string) (stanzas []Deb822Stanza, ok bool)
ReadDeb822 is the one reader of the .sources files, for the report and for the plan: stanzas separated by blank lines, a field per line that has a colon and does not begin with white space, the lines that begin with it going on with the field above, and the lines that begin with # left out wherever they are. ok is false for a line that goes on from nothing and for a line with no colon, or with nothing before it. What a field says is not looked at here.
type DistroDecider ¶ added in v0.4.73
type DistroDecider struct {
// contains filtered or unexported fields
}
DistroDecider says whether a repository is the distribution's own archive, as the report decides it (see markDistro), with the differences that a plan, which rewrites the sources and must not guess, needs: the address decides only for Debian's own archive hosts (archiveHost) and for a disc, and the Release file apt kept of the suite decides for any other; when there is no such file the answer is "not known", and not "not the distribution's". It answers for the Release files it looks at, which are at most MaxSourceLookups in all.
func NewDistroDecider ¶ added in v0.4.73
func NewDistroDecider(p Probe) *DistroDecider
NewDistroDecider is a DistroDecider that looks at the Release files the Probe shows.
func (*DistroDecider) Suite ¶ added in v0.4.73
func (d *DistroDecider) Suite(ctx context.Context, uri, suite string) (distro, decided bool, err error)
Suite says whether the suite of the source at uri is the distribution's own. decided is false when the answer cannot be had: the bound of looks is spent, there is no Release file of the suite in apt's lists (the box has not run apt-get update since the source was added, or its lists were wiped) or the address is one that no file name can be derived of (a mirror list, mirror+http): the plan refuses then, it does not guess. A disc or a directory is not the distribution's, nor is a flat repository (a suite that ends in a slash: the archive has dists/<suite>), and Docker's own host is a third party by its name.
type Finding ¶
type Finding struct {
Code string `json:"code"`
Severity Severity `json:"severity"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Data map[string]any `json:"data"`
Action Action `json:"action,omitempty"`
// contains filtered or unexported fields
}
A Finding is one line of the report: what a check found.
func CheckByCode ¶ added in v0.4.74
CheckByCode runs the one check of the table that has this code, as the report runs it (its own time, an answer for a check that panics or ignores its context, a Probe that runs only what the allow-list says), and says what it found. ok is false when the table has no such check.
It is for the step that stands between a finished hop and the restart of the machine: the report's gates read /etc/os-release, which already names the next release by then, and would call the machine unsupported. The checks that are asked for here read the box and nothing else, as the report's do.
type Group ¶
type Group string
A Group is a kind of check; the report lists the findings of a severity group by group, in this order.
type Hop ¶
type Hop struct {
From Release `json:"from"`
To Release `json:"to"`
// contains filtered or unexported fields
}
Hop is the step the upgrade would take.
type HopID ¶
type HopID string
A HopID names a step from one release to the next, as the table of pkg/ossupport has it: the vendor, the release left and the release reached. A check that applies to some hops names them.
const ( HopDebian11to12 HopID = "debian-11-12" HopDebian12to13 HopID = "debian-12-13" HopUbuntu2204to2404 HopID = "ubuntu-22.04-24.04" HopUbuntu2404to2604 HopID = "ubuntu-24.04-26.04" )
The hops of the decision of 2026-10-11. A hop that the table of pkg/ossupport gains is a HopID of the same shape, and the checks that name no hop apply to it.
type Options ¶
type Options struct {
// Checks is the table to run; nil is Checks().
Checks []Check
// Budget is how long the whole report has; zero is DefaultBudget.
Budget time.Duration
// Concurrency is how many checks run at once; zero is DefaultConcurrency.
Concurrency int
// IdentityTimeout is how long reading who the box is has (it is made before the checks, and is
// not one of them); zero is DefaultTimeout. It never has more than what the report has left.
IdentityTimeout time.Duration
}
Options are the knobs of Run; the zero value is what the API uses.
type Output ¶
Output is what a command printed (its standard output and its error output, in English, cut to MaxOutputBytes) and how it ended. A command that ran and failed is not an error of Run: it is an ExitCode that is not 0.
type Probe ¶
type Probe interface {
// ReadFile is the content of a file, at most MaxFileBytes (ErrTooLarge beyond), of a regular
// file only.
ReadFile(ctx context.Context, path string) ([]byte, error)
// ReadHead is the first max bytes of a regular file (all of it when it is shorter, and never more than
// MaxFileBytes), with no error for a file that is larger: what a file as large as a Release file says at its
// start (its Origin) is read without reading the file.
ReadHead(ctx context.Context, path string, max int) ([]byte, error)
// ReadDir is the names of the entries of a directory, sorted.
ReadDir(ctx context.Context, path string) ([]string, error)
// Stat describes a path, following symbolic links; Lstat does not follow them.
Stat(ctx context.Context, path string) (FileInfo, error)
Lstat(ctx context.Context, path string) (FileInfo, error)
// Readlink is the target of a symbolic link, as written.
Readlink(ctx context.Context, path string) (string, error)
// Run runs a command: argv, no shell, in English, with its output bounded. Only what Allowed
// says is ever run: the engine hands a check a Probe that refuses the rest (ErrNotAllowed).
Run(ctx context.Context, argv ...string) (Output, error)
// FreeBytes is the room a program that is not root has left on the filesystem of a path.
FreeBytes(ctx context.Context, path string) (uint64, error)
// MaintenanceBusy says whether something else is changing the box's packages or its ReCasaOS
// release now (one of the maintenance units runs, or a package manager holds dpkg's lock),
// and says what, in a few words. An error says it could not ask (dpkg's lock cannot be looked at,
// the box is not one that has a lock to look at): a lock that cannot be seen is not one that
// nobody holds, and the check that asks says it does not know. A busy box is busy whatever else
// could not be looked at, and has no error.
MaintenanceBusy(ctx context.Context) (reason string, busy bool, err error)
// AppOperations are the apps that have an operation in progress (an install, an update, a
// backup, a restore), by name. An error is no answer: AppManagement cannot be asked.
AppOperations(ctx context.Context) ([]string, error)
// Now is the clock.
Now() time.Time
// EUID is the user the core runs as; Arch is the architecture it runs on (GOARCH).
EUID() int
Arch() string
}
Probe is the seam: everything a check may know of the machine, and nothing else. It has no method that writes, and a test pins that (TestTheProbeCannotWrite). A path that does not exist is an error that satisfies errors.Is(err, fs.ErrNotExist); a command that is not installed is ErrToolMissing. Every method that can wait is given the context of the check, which ends at the check's timeout.
type Release ¶
type Release struct {
ID string `json:"id,omitempty"`
VersionID string `json:"version_id,omitempty"`
Codename string `json:"codename,omitempty"`
PrettyName string `json:"pretty_name,omitempty"`
}
Release is a release of the operating system, as the report shows it.
type Report ¶
type Report struct {
CheckedAt time.Time `json:"checked_at"`
State string `json:"state"`
// Hop is the step the upgrade would take; absent for an unsupported box and for the latest release.
Hop *Hop `json:"hop,omitempty"`
Counts Counts `json:"counts"`
Checks []Finding `json:"checks"`
}
A Report is whether this machine could be upgraded to the next release, and why not.
type Result ¶
type Result struct {
Severity Severity
Title string
Detail string
Data map[string]any
Action Action
}
A Result is what a check found. Data is for the page: values are strings (of a restricted alphabet), numbers, booleans and lists of strings, and what is not is dropped; never what a tool printed. Title and Detail are an English fallback, which the page replaces by its own sentence for the code.
type Session ¶
type Session struct {
Identity ossupport.Identity
// Hop is the step the box would take; nil when the table has none for it.
Hop *Hop
// Latest is a box on the newest release the table knows, which has nothing to upgrade to.
Latest bool
// ReleaseErr is why os-release could not be read, when it could not; MarkerErr is why a file
// that tells a variant could not be looked at (it answered something else than "not there").
ReleaseErr, MarkerErr error
// contains filtered or unexported fields
}
Session is what the engine found out about the box before it ran the checks, and gives to every check in its context (SessionOf): who the box is and the hop it would take.
type Severity ¶
type Severity string
Severity is what a finding means for the upgrade.
const ( // Refuse: the upgrade must not be started from this machine as it is. Refuse Severity = "refuse" // Warn: it can be done, and the owner is told what to look at. Warn Severity = "warn" // OK: nothing to say. OK Severity = "ok" // Info: something the hop will do by itself, or a check that belongs to the plan step and is // not done here (it needs the network or a sandbox): said, never ok. Info Severity = "info" )
type SourceFile ¶ added in v0.4.73
SourceFile is a file apt reads its sources from, as the report finds it: Name is "sources.list" or the name of a file of sources.list.d. A file that is there and cannot be read (too large, no right to it) has Err, and no content.
func ReadSourceFiles ¶ added in v0.4.73
func ReadSourceFiles(ctx context.Context, p Probe) ([]SourceFile, error)
ReadSourceFiles reads the files apt reads sources from, the way the report finds them: /etc/apt/sources.list, and the files of /etc/apt/sources.list.d whose names are ones apt reads (AptSourceName), the regular ones only. A file that is not there, or is not a regular one, is nothing. The order is sources.list, then the names of the directory, sorted. Only a question that was not answered (the end of the time) is an error.
func (SourceFile) Path ¶ added in v0.4.73
func (f SourceFile) Path() string
Path is where the file is, on the box.
Source Files
¶
- allowlist.go
- check_by_code.go
- checks_docker.go
- checks_filesystem.go
- checks_fstab.go
- checks_hop.go
- checks_identity.go
- checks_modules.go
- checks_network.go
- checks_packages.go
- checks_process.go
- checks_sources.go
- checks_trixie.go
- engine.go
- helpers.go
- identity.go
- plan_export.go
- probe.go
- report.go
- sources.go
- text.go
- version.go