Skip to main content

fanout_child_name

Function fanout_child_name 

Source
pub fn fanout_child_name(
    base: &str,
    policy_ns: &str,
    pvc_ns: &str,
    pvc_name: &str,
) -> String
Expand description

The deterministic name of the fanned-out Snapshot for one PVC.

<base>-pvc-<slug>-<h8>, capped at [MAX_CHILD_NAME].

  • <slug> is human-legible (<name>, or <namespace>-<name> when the PVC is outside the policy’s namespace) and may be clipped.
  • <h8> is 8 hex of FNV-1a over the exact string "<namespace>/<name>" and is never clipped — it is the injectivity guarantee.

Collision-free against the three existing schemes (<schedule>-<slot>, <schedule>-<policy>-<slot>, <policy>-manual-<slot>): each ends in a dash-free 14-digit slot stamp, while a fanned name’s tail after -pvc- always contains a -.

This does NOT delegate to io::staging::staged_child_name, whose MAX_NAME_LEN - tag.len() - suffix.len() - 2 is unchecked usize subtraction: its callers pass 4-char suffixes (snap, src), and a PVC name up to 253 chars would underflow it.

let n = fanout_child_name("nightly-20260805020000", "db", "db", "pgdata");
assert!(n.starts_with("nightly-20260805020000-pvc-pgdata-"));
assert!(n.len() <= 63);