Documentation
¶
Overview ¶
Package restore reads the platform backup generations of ADR-0203 back (ADR-0206): it lists them as a lineage, resolves a restore point, restores one offline into empty directories and leaves the platform held, and inspects one into memory engines.
Index ¶
- Constants
- func CheckVersion(writer, binary string) error
- func Counts(ctx context.Context, st store.Store) (map[v1.Kind]int, error)
- func Diff(from, to *View) (added, removed, changed map[v1.Kind][]v1.ObjectRef, err error)
- func Export(obj v1.Object, reveal bool) (v1.Object, error)
- func Parent(dataDir, timeline string) (*backup.GenRef, error)
- func Timeline(ctx context.Context, st store.Store) (string, error)
- type Generation
- type Options
- type Point
- type Report
- type View
Constants ¶
const ( StateComplete = "complete" StateIncomplete = "incomplete" StateAbandoned = "abandoned" StateNewer = "newer" )
The states of a listed generation (Decision 3).
Variables ¶
This section is empty.
Functions ¶
func CheckVersion ¶
CheckVersion is Decision 4's rule: a generation written by funcd writer restores on funcd binary when writer's major.minor is the same or older; a newer one is fault.Invalid naming both. A stamp that is not semver ("dev", or git describe's bare hash in a clone without tags) orders nothing, so it restores and Run warns.
func Diff ¶
Diff lists per kind the objects to adds, from drops and both hold with differing Export forms. Secrets that do not decode in either view compare by key only.
func Export ¶
Export is obj as `funcdctl apply -f` recreates it (Q14): no uid, resourceVersion, creation time or status. A Secret's values are REDACTED unless reveal.
Types ¶
type Generation ¶
Generation is one listed generation: its manifest (only Generation and Timeline while incomplete), its class and its state: incomplete without a manifest, abandoned on a dead branch (backup.Abandoned), newer when this funcd cannot read it (format or version), else complete.
func List ¶
List lists src once and reads each complete generation's manifest, in backup.List's order.
func Resolve ¶
func Resolve(gens []Generation, p Point) (Generation, error)
Resolve picks the generation p names among gens (Decision 3): none ⇒ fault.NotFound; latest, a time or a pin whose candidates come from two timelines neither of which descends from the other ⇒ fault.Conflict naming both. A resourceVersion <t>-<n> is the newest complete generation of t below revision n, else t's parent.
func (Generation) Ref ¶
func (g Generation) Ref() backup.GenRef
Ref is the generation's (timeline, n).
type Options ¶
type Options struct {
Config config.Config
Source blob.Bucket
Identities []age.Identity
EscrowDir string
NewMasterSecret bool
SecretsKey []byte
Out io.Writer
}
Options configure Run and Inspect. Source is the target opened with the operator's restore credential (gocloud.OpenWith); Identities are envelope.ReadIdentities'; SecretsKey is --secrets-key, which only Inspect reads (Run uses secrets.encryptionKeyFile); Out takes the warnings and the credentials a new master changes.
type Point ¶
type Point struct {
Latest bool
At time.Time
Version store.Version
Gen *backup.GenRef
Pin backup.Class
Timeline string
}
Point is a parsed restore point (Decision 3): exactly one of Latest, At, Version, Gen and Pin is set. Timeline is --timeline: latest, a time and a pin keep only that timeline and those it descends from.
type Report ¶
type Report struct {
From backup.GenRef `json:"from"`
Timeline string `json:"timeline"`
Funcd string `json:"funcd"`
At v1.Timestamp `json:"at"`
Counts map[v1.Kind]int `json:"counts"`
PausedByRestore []string `json:"pausedByRestore,omitempty"`
AlreadyPaused []string `json:"alreadyPaused,omitempty"`
RecordsWithoutRun []string `json:"recordsWithoutRun,omitempty"`
}
Report is restore.json (Decision 2 step 5): the generation loaded, the timeline the restored metastore minted, the funcd that restored it and when, the objects per kind, and the runs Decision 7 holds as <ns>/<name>.
func Run ¶
Run restores the generation p names into o.Config's empty directories and leaves the platform held (Decision 2): every check, then hold.Begin and the marker, before any part is read; each store's sha256 before its Load; the canary on the new timeline; the runs paused, the master written; restore.json, the owner, then hold.End. An error removes what it created; a kill leaves restore.inprogress, which refuses the next start.
type View ¶
type View struct {
Meta store.Store
Runs runstate.Store
Events *eventstore.Store
Secrets []v1.ObjectRef
}
View is one generation loaded into memory engines (Decision 5): Meta decodes Secrets only with a secrets key, and Secrets lists them by key either way.