osverify

package
v0.4.121 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 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

Overview

Package osverify says whether a machine is as it was after an operating system upgrade, and what is not. It takes a handful of facts of the machine (Take), once before the upgrade and once after, and compares them with each other and with what the blocks of the upgrade wrote down (Judge). It reads and decides, and does nothing else: it restarts no unit, installs no package, starts no container, and writes nothing.

What it reads, it reads through the readiness report's Probe, and the commands it runs are the ones on the readiness allow-list (osreadiness.Allowed), never a runner of its own. A fact that cannot be taken (a tool that is not installed, a command that fails, a file that cannot be read, the time that ran out) is not a fact that is false: it is listed as unknown (Facts.Unknown), and nothing is concluded from it.

Index

Constants

View Source
const (
	FactKernel     = "kernel"
	FactSystem     = "system"
	FactDpkg       = "dpkg"
	FactSamba      = "samba"
	FactMounts     = "mounts"
	FactRoute      = "route"
	FactDNS        = "dns"
	FactUnits      = "units"
	FactDocker     = "docker"
	FactContainers = "containers"
	FactSources    = "sources"
	FactListening  = "listening"
	FactFailed     = "failed_units"
)

The facts that can be unknown (Facts.Unknown names them).

View Source
const (
	DockerUp      = "up"
	DockerDown    = "down"
	DockerStopped = "stopped"
	DockerAbsent  = "absent"
)

The state of Docker's daemon (Docker.State): up when it answered; down when its service runs and it did not; stopped when Docker is on the box and its service does not run (the daemon is not asked then, since asking it would start it, and with it the containers that have a restart policy); absent when there is no Docker. It is empty when it could not be said.

View Source
const (
	SeverityError = "error"
	SeverityWarn  = "warn"
	SeverityInfo  = "info"
)

How serious a finding is. An error is a machine that is not what the upgrade promised: the run ends in a failed check. A warning is something that the owner should look at, and the run ends as succeeded with findings. Information is listed and changes no state: a Docker box normally keeps Docker's source paused, and that is not a problem.

View Source
const (
	// Errors.
	CodeKernelUnexpected = "kernel_unexpected" // the machine runs another kernel than the one the upgrade installed
	CodeCasaosUnitDown   = "casaos_unit_down"  // a unit of ReCasaOS that ran before the upgrade does not run now
	CodeDockerDown       = "docker_down"       // Docker ran, and does not now
	CodeMountsMissing    = "mounts_missing"    // a mergerfs pool that was mounted is not
	CodeDpkgNotQuiet     = "dpkg_not_quiet"    // dpkg has a package that is not whole
	CodeSystemNotReady   = "system_not_ready"  // systemd is still starting, or is stopping
	// Warnings.
	CodeUnitsFailedNew          = "units_failed_new"          // units that fail now and did not fail before
	CodePortsMissing            = "ports_missing"             // ports that were listened on and are not
	CodeSambaUsersChanged       = "samba_users_changed"       // Samba does not hold the users it held
	CodeRouteMissing            = "route_missing"             // the machine had a default route and has none
	CodeDNSMissing              = "dns_missing"               // the resolver answered and does not
	CodeDockerVersionChanged    = "docker_version_changed"    // the daemon is not the one of before
	CodeDockerSourceUnreachable = "docker_source_unreachable" // Docker's repository could not be asked, and its source stays paused
	CodeContainerNotReturned    = "container_not_returned"    // a container that has a restart policy ran before, and does not now
	CodeFactsIncomplete         = "facts_incomplete"          // what the machine is now could not be taken in full: what was not taken is not judged
	// Information.
	CodeDockerSourceNotPublished = "docker_source_not_published" // Docker publishes nothing for the new release yet
	CodeDockerSourcePaused       = "docker_source_paused"        // Docker's source is still paused
	CodeDpkgDistNew              = "dpkg_dist_new"               // files that dpkg left beside the ones the owner edited, since the upgrade began
	CodeSourcesLeftPaused        = "sources_left_paused"         // sources of apt that the upgrade paused and that are still paused
	CodeChangedSinceSnapshot     = "changed_since_snapshot"      // something that was there when the hop began, and was not there when the owner asked for the restart
	CodePrerebootWarning         = "prereboot_warning"           // block 7 warned of something that the owner was to look at before the restart (the word of it is the argument)
)

The findings, which are a closed list: the page has a sentence for each of them, and a test says that every one of them can be made.

View Source
const (
	BKKernel           = "kernel"
	BKListening        = "listening.txt"
	BKListeningAfter   = "listening-after.txt"
	BKFailedUnits      = "failed-units.txt"
	BKFailedUnitsAfter = "failed-units-after.txt"
	BKCasaosUnits      = "casaos-units.txt"
	BKContainers       = "containers.txt"
	BKDpkgFiles        = "dpkg-files.txt"
	BKDpkgFilesAfter   = "dpkg-files-after.txt"
	BKDockerSourceNote = "docker-source-note"
	// BKWarnings holds the words of the warnings that block 7 printed before the restart, one on a line.
	BKWarnings = "warnings"
)

The files that the blocks of the hop leave in the backup folder and that the judge reads. Block 2 writes down the state of the machine before the hop (kernel is written by block 7, the note about Docker's source by block 8), and block 8 writes the same lists again after the restart.

View Source
const UnreadablePrefix = "bk:"

UnreadablePrefix begins the name, in Facts.Unknown of the facts of after, of a file of the backup folder that is there and could not be read: it is not a file that is not there, and the judge says that what it was to be compared with was not.

Variables

BKNames are the files of the backup folder that the judge reads.

Codes are the findings, errors first, in the order that Judge lists them.

Functions

func DefaultRoute

func DefaultRoute(procNetRoute string) string

DefaultRoute is the interface that the IPv4 default route of the text of /proc/net/route goes out by, and "" when there is none: what the facts say of the route, for the core that waits for a machine that has restarted to have its network back before it checks it.

func NotReturned

func NotReturned(bk BKFiles, after Facts) []dockerpkg.NotReturned

NotReturned are the containers that block 2 saw running before the hop, that Docker does not list as running now, with their restart policy, sorted by name. It is empty when Docker does not answer now (docker_down says that) or when the containers cannot be listed. A container that is in the list and has no restart policy was stopped by the restart and does not start by itself: the page says so, and it is not a finding.

func SeverityOf

func SeverityOf(code string) string

SeverityOf is how serious a finding is, "" for a code that is not one.

func Summarize

func Summarize(findings []Finding) osrun.VerifyResult

Summarize counts what changes the state of a run: the errors and the warnings. Information does not count, and is not in what the reducer is given.

Types

type BKFiles

type BKFiles map[string]string

BKFiles are those files, by name, as they were read. A file that is not there is not in it: a list that was not written is not an empty list, and nothing is concluded from it.

func ReadBK

func ReadBK(ctx context.Context, p osreadiness.Probe, dir string) BKFiles

ReadBK reads the files of a backup folder that the judge needs, through the Probe. A file that is not there, or cannot be read, is not in what it gives back; a folder that is not one of the hop's is none.

func ReadBKUnreadable

func ReadBKUnreadable(ctx context.Context, p osreadiness.Probe, dir string) (BKFiles, []string)

ReadBKUnreadable is ReadBK and the names of the files that are there and could not be read (not the ones that are not there: a block that did not run wrote nothing, and that is no fault of the machine's).

type Container

type Container struct {
	Name string `json:"name"`
	// Policy is its restart policy: "no" or "" (it does not come back by itself), "always", "unless-stopped", "on-failure".
	Policy string `json:"policy,omitempty"`
	// Binds are the directories of the machine that it has mounted into itself, so that what it writes there is the
	// machine's, and not the container's.
	Binds []string `json:"binds,omitempty"`
}

Container is a container that runs, and what of it matters after a restart.

type Docker

type Docker struct {
	State string `json:"state,omitempty"`
	// Version and EngineID are the daemon's own: the id is the one it keeps in its data directory, and it changes when
	// that directory is made again. Both are empty unless the daemon answered (and the id, when its file cannot be read).
	Version  string `json:"version,omitempty"`
	EngineID string `json:"engine_id,omitempty"`
	// Containers are the containers that run, sorted by name.
	Containers []Container `json:"containers,omitempty"`
}

Docker is what is known of Docker's daemon.

type Facts

type Facts struct {
	Taken   bool      `json:"taken"`
	At      time.Time `json:"at"`
	Unknown []string  `json:"unknown,omitempty"`

	// Kernel is the release the machine runs now (uname -r), System what systemd says of the state of the system
	// (running, degraded, starting...), and DpkgQuiet whether dpkg --audit has nothing to say.
	Kernel    string `json:"kernel,omitempty"`
	System    string `json:"system,omitempty"`
	DpkgQuiet bool   `json:"dpkg_quiet"`
	// SambaUsers is how many users Samba's database holds (pdbedit -L).
	SambaUsers int `json:"samba_users"`
	// Mergerfs are the mount points of the mergerfs pools that are mounted, sorted. Pools are the same pools by mount point, with the
	// branches that each is made of, as the mount table gives them; Mounts are the mount points of the file systems that hold
	// data (disks, pools, network shares), where a mount that is not there after the restart is a directory that is empty.
	Mergerfs []string            `json:"mergerfs,omitempty"`
	Pools    map[string][]string `json:"pools,omitempty"`
	Mounts   []string            `json:"mounts,omitempty"`
	// Route is the interface the default route of IPv4 goes out by, "" when there is none.
	Route string `json:"route,omitempty"`
	// DNS says whether the resolver answered for a name that a Debian box reaches every day.
	DNS bool `json:"dns"`
	// Units are the units of ReCasaOS that have a file on the box, with the state systemd gives them.
	Units map[string]string `json:"units,omitempty"`
	// Paused are the sources of apt that the upgrade paused and that are still paused: files that have been renamed
	// (docker.list.casaos-paused) and the lines of a file that have been commented out (sources.list:12).
	Paused []string `json:"paused,omitempty"`
	Docker Docker   `json:"docker"`
	// Listening are the local addresses that something listens on (the fourth column of ss -Hltn, as block 2 writes it down),
	// and Failed the units that systemd says have failed: the two lists that the blocks of the hop write before and after, here
	// taken as the judge needs them, now.
	Listening []string `json:"listening,omitempty"`
	Failed    []string `json:"failed_units,omitempty"`
}

Facts is what is known of a machine at one moment. The zero value says that nothing was taken (Taken is false): a run whose facts from before are lost is judged by what it still knows. A fact that could not be taken is named in Unknown, and its field is then meaningless.

func Take

func Take(ctx context.Context, p osreadiness.Probe) Facts

Take takes the facts of the machine now. It is the one function that is used before the upgrade and after it, so that what is compared was taken in the same way. Everything it asks the machine goes through the readiness allow-list, and it asks within the time of ctx: what the time did not leave is unknown.

func TakeWith

func TakeWith(ctx context.Context, p osreadiness.Probe, resolve Resolver) Facts

TakeWith is Take with another resolver, which the tests of what is built on it need so as not to ask the network.

func (Facts) Knows

func (f Facts) Knows(fact string) bool

Knows says whether a fact was taken: the facts were taken at all, and this one was not left unknown.

type Finding

type Finding struct {
	Code     string   `json:"code"`
	Severity string   `json:"severity"`
	Arg      string   `json:"arg,omitempty"`
	Apps     []string `json:"apps,omitempty"`
	Policy   string   `json:"policy,omitempty"`
}

Finding is one thing that the judge found. Arg says what it is about, in one token or a short text that can be shown as it is: a unit, a port, a path, a name, a kernel. Where it says that something is not what it was, it is "expected>found" (the kernel that was to run and the one that runs, the users that Samba held and holds, the version of Docker before and now). Apps are the containers that a missing mount point puts at risk, and Policy is the restart policy of a container that did not return: each is there for one code only.

func Judge

func Judge(before, after Facts, bk BKFiles) []Finding

Judge compares the machine after the upgrade with the machine before it, and with what the blocks of the hop wrote down of it, and says what is not as it was. The facts of before are those that Take took when the hop was started, or the zero Facts when they are lost; what the facts of after do not know is not judged, and what is not judged is said (facts_incomplete) where it was known before. The findings are listed with the errors first, then the warnings, then the information, each in the order of Codes and, within a code, by name. It is never nil.

func JudgeWith

func JudgeWith(before, after Facts, bk BKFiles, opts Options) []Finding

JudgeWith is Judge with the options.

type Options

type Options struct {
	// Restart are the facts that were taken when the owner asked for the restart. The machine waits for it, sometimes for days,
	// and the owner may stop an app or a unit of ReCasaOS meanwhile: what was running when the hop began and was not when the
	// restart was asked for is what the owner changed, and is told as that (changed_since_snapshot), not as what the restart did.
	// The zero Facts say that none were taken.
	Restart Facts
}

Options are what the judge is told besides the facts of before and after and the files of the backup folder.

type Resolver

type Resolver func(ctx context.Context, name string) bool

Resolver says whether a name resolves.

Jump to

Keyboard shortcuts

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