Expand description
Selector expansion: turning one SnapshotPolicy source into N concrete
per-PVC backups (#346).
§The model
A SnapshotPolicy source is exactly one of pvc, nfs, or pvcSelector.
The first two name a single thing; the third matches many. Kopiur’s whole
data model is built on one Snapshot CR = one mover Job = one kopia
source path = one kopia manifest, owned via a finalizer — retention,
restore, the catalog and the deletion policy all rest on that 1:1. So a
selector is expanded into N ordinary Snapshot CRs, one per matched PVC,
each of which is then indistinguishable from a hand-written single-PVC
backup.
Expansion happens once, at mint time, in whichever component creates the
CR — a SnapshotSchedule fire or kubectl kopiur snapshot now. A Snapshot
never expands itself: a CR minting sibling CRs would re-enter the same
reconciler for each child and break the one-shot run_decision discipline,
and a SnapshotPolicy that minted invocations would collapse the
recipe/invocation/schedule split the project is built around.
§What was here before
Nothing. pvcSelector was schema-valid, admission-accepted, documented on
six pages and shipped as deploy/examples/04-multi-pvc-selector.yaml — and
no expansion code existed anywhere, so build_backup_run hit its
_ => arm and returned invariant violated … This is likely a bug in kopiur. That is #346.
§The restore side (#443)
Expansion is only half the story. A selector policy writes N kopia sources,
one per member path; a RESTORE against that policy must read exactly ONE of
them, chosen by the PVC it is filling. restore_source_path is that
inverse: it re-derives a member’s path from the policy’s own
sourcePathStrategy, so the restore’s kopia filter names the same path the
backup wrote. Without it the filter is user@host: with no path, which
matches EVERY member — and the newest of them wins, so one PVC could be
filled with another PVC’s data.
It lives here, next to EffectiveSource::kopia_source_path and
strategy_for, on purpose: the backup path and the restore path are then
literally the same code, and the two strings cannot drift.
Structs§
- Effective
Source - The single source one
Snapshotactually backs up, after resolvingspec.source(a fanned-out child) against the policy’ssources[]. - Expanded
Member - One member of an expanded selector: the child’s name and the
spec.sourceto stamp on it. - Mint
Cell - One
Snapshotto mint for a slot/invocation: its deterministic name, the source pin (for apvcSelectormember) and the repository pin (for a multi-repo fan-out child, NORMALIZED vianormalized_repository_ref).
Enums§
- Restore
Source Path - Where a restore’s kopia source path came from — the result of
restore_source_path.
Functions§
- cache_
pvc_ name - The kopia-cache PVC name for one (policy, repository) cell.
- effective_
source - Resolve which source this
Snapshotcovers. - expand_
sources - Pure. Expand one policy’s sources against an already-matched PVC set.
- fanout_
child_ name - The deterministic name of the fanned-out
Snapshotfor one PVC. - fanout_
child_ name_ for - The deterministic child
Snapshotname for one (source-member, repository) cell of a fan-out — the general form behindfanout_child_name. - group_
name - The shared
VolumeGroupSnapshotname for one expansion in one namespace. - label_
selector_ string - Render a
LabelSelectoras the API server’s selector string. - mint_
cells - Pure. Cross one policy’s expanded source members with its repository
dimension (#368) into the exact set of
Snapshots to mint for one slot or onesnapshot nowinvocation. Lives here so theSnapshotSchedulereconciler andkubectl kopiur snapshot nowmint byte-identical sets — a divergence would give the same recipe different children depending on who fired it. - populate_
job_ name - The deterministic name of the populate mover
Jobfor one claiming PVC. - restore_
source_ path - The kopia source path a restore of
targetshould read frompolicy(#443). - strategy_
for - The
sourcePathStrategygoverning a source.