datahome

package
v0.209.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 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 datahome answers the question the operator rule "C: holds Windows and program installs, never data" leaves open on a Windows node: where does this harness keep its data, is any of it on the OS drive, and how does it move?

The harness resolves one install root (config `home`, else $LOCAL_OFFLOAD_HOME, else ~/.local-offload) and hangs the cache, ledger, media, delegation log, pipeline jobs and footprints off it. With no `home` that root is on the OS drive. The decision to move it is deliberately NOT made here at load time: a runtime default that picked a drive would re-point every existing node at an empty tree the moment the binary was upgraded, which is moving live data silently. The installer records the choice as an explicit `home`; this package audits that nobody left data behind and plans the copy that gets an existing node there.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataTarget

func DataTarget(vols []volumes.Volume, osDrive string) (volumes.Choice, error)

DataTarget is the volume the harness's data should live on: the install-volume rule over the volumes that may hold it. It is the one place doctor, `data status` and `data migrate` ask, so the answer cannot differ between them. The OS drive is never the answer, whatever the list says about it (the point of the rule is that it is not allowed to be), and neither is a cloud-synced virtual drive or a FAT-family volume: Pick alone would name Google Drive for desktop (FAT32, not removable, a cloud quota's free space) whenever it shows the most room, and the operator would be told to copy a bbolt store onto it.

func HomeValue

func HomeValue(home string) string

HomeValue is home spelled as the JSON value for the `home` key: forward slashes, which every Windows API accepts and which need no escaping inside the string.

func ProposedHome

func ProposedHome(root string) string

ProposedHome is the directory an install on volume root would use as `home`: a fixed name directly under the volume root, in the root's own separator style.

Types

type Item

type Item struct {
	Rel    string `json:"rel"`
	Size   int64  `json:"size"`
	Status Status `json:"status"`
	Why    string `json:"why,omitempty"`
}

Item is one file's outcome.

type Location

type Location struct {
	Key  string `json:"key"`
	Path string `json:"path"`
}

Location is one place the harness writes data: the config key that decides it and the resolved path.

func Locations

func Locations(cfg config.Config) []Location

Locations lists the data locations cfg resolves, one row per distinct path, `home` first. `home` is the install root: the delegation log, the pipeline job trees, the footprint store and the agent audit trail all hang off it without a config key of their own, so it is listed as a location in its own right, which is also what makes a node that hand-wrote media_dir onto a data drive but never set `home` still show up. The machine-wide lease root (state_dir, gpu_lock_path) is deliberately absent: it is shared by every user of the card and holds a few bytes, not data.

type Options

type Options struct {
	// From is the tree the node runs from today; To is the new home.
	From, To string
	// OSDrive refuses a To on that drive ("" = no check). The rule the verb exists
	// for is that data does not live there.
	OSDrive string
	// Apply performs the copy; without it Run only plans.
	Apply bool
	// Stopped is the operator's statement that fleet-serve and every MCP door are
	// stopped. Only then are bbolt stores (*.db) copied.
	Stopped bool
}

Options is one migration.

type Report

type Report struct {
	// OSDrive is the drive Windows boots from (`C:\`); "" when the rule does not
	// apply (a non-Windows host), which makes every other field empty.
	OSDrive string `json:"os_drive,omitempty"`
	// OnOS lists every data location that sits on the OS drive.
	OnOS []Location `json:"on_os_drive,omitempty"`
	// Target is the volume the install-volume rule would put the data on; nil when no
	// non-OS volume qualifies.
	Target *volumes.Choice `json:"target,omitempty"`
	// Why says why Target is nil.
	Why string `json:"why,omitempty"`
}

Report is the audit of one config against one volume list.

func Audit

func Audit(cfg config.Config, osDrive string, vols []volumes.Volume) Report

Audit checks every data location of cfg against osDrive (`C:\`; "" on a host with no OS drive letter, where the rule does not apply and the Report is empty) and asks the install-volume rule where the data should live instead.

func (Report) Failing

func (r Report) Failing() bool

Failing reports whether the node should FAIL doctor: data on the OS drive AND a data volume that qualifies to take it. A box with nowhere to move to (one disk) is reported, not failed, because a FAIL nobody can clear teaches everyone to ignore the verb; the explicit decision to keep data on the OS drive is the install-volume rule's allow-os-volume, and it belongs to the operator.

func (Report) Grouped

func (r Report) Grouped() (root *Location, under, others []Location)

Grouped splits OnOS for display: the install root (nil when it is not on the OS drive), the locations sitting inside that root, which follow it when it moves, and the rest, each of which needs its own fix. A node on the defaults has one root and seventeen paths under it; naming the root once says as much as eighteen rows.

type Result

type Result struct {
	From    string `json:"from"`
	To      string `json:"to"`
	Applied bool   `json:"applied"`
	Items   []Item `json:"items"`
}

Result is the whole run.

func Run

func Run(opt Options) (Result, error)

Run plans (Apply false) or performs (Apply true) the copy of From into To.

It never moves, deletes or rewrites anything under From, never follows a link, and never overwrites a destination file that is newer than its source. Every copy goes to a temp name, is verified by re-reading it, takes the source's mtime, and only then replaces the destination, so an interrupted run leaves whole files or none. config.json is not carried: the harness finds its config by a fixed path, and that file is how it learns the new home in the first place.

From and To are resolved to absolute paths first, and everything below (the OS-drive guard, the same-tree checks, Result.To the caller prints as the `home` line) works on the resolved form. DriveOf answers "" for a relative path or a rooted one with no drive letter, so the guard reading the typed string let `--to relhome` through while it resolved against the working directory, onto the OS drive.

func (Result) Bytes

func (r Result) Bytes(s Status) int64

Bytes sums the sizes of the items with status s.

func (Result) Count

func (r Result) Count(s Status) int

Count is how many items have status s.

func (Result) Incomplete

func (r Result) Incomplete() bool

Incomplete reports whether something still needs the operator before `home` can be switched: a held store, an unreadable or changed source, a failed write. A kept destination and a skipped file do not count; both are decisions, not gaps.

type Status

type Status string

Status is what happened to one file of the migration.

const (
	// StatusCopy: the file is (Apply) or would be (dry run) copied, new or refreshed.
	StatusCopy Status = "copy"
	// StatusSame: the destination already holds identical bytes.
	StatusSame Status = "same"
	// StatusKept: the destination differs but is NEWER than the source, so the node
	// has already written there; it is left alone. Informational, not incomplete.
	StatusKept Status = "kept"
	// StatusHeld: a bbolt store, held back until the operator says the doors are
	// stopped. Copying a live one tears it.
	StatusHeld Status = "held"
	// StatusSkipped: deliberately not carried (see skipReason).
	StatusSkipped Status = "skipped"
	// StatusUnreadable: the source could not be read, typically because a running
	// process holds it open.
	StatusUnreadable Status = "unreadable"
	// StatusChanged: the source changed while it was being copied, so the copy was
	// refused as a torn snapshot.
	StatusChanged Status = "changed"
	// StatusFailed: the destination side failed (disk full, permission, verify).
	StatusFailed Status = "failed"
)

Jump to

Keyboard shortcuts

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