Adopt extended verified registry storage
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-11-03 18:04:54 -06:00
parent 227fa04562
commit 9b79b93fa6
2 changed files with 25 additions and 2 deletions

View File

@ -118,6 +118,10 @@ The registry copy must be secured before switching to host K3s: migration cannot
boot a source VM while host K3s is active. The transition below prepares the remote
registry offline. Apps accepts it only when the receipt's host, node and path match
the live cluster; before the PV exists it also verifies the complete file manifest.
When the remote registry has grown, the offline check accepts it only if the
Debian copy matches the original receipt, every original file is unchanged,
and registry blob contents match their SHA-256 paths. The remote manifest is
checked again before adoption.
The native profile declares `storage.required_mount: /data`. Runtime/start guards,
offline publication and remote registry reconciliation require that exact

View File

@ -110,17 +110,36 @@ def main():
"do not restart a running registry or create an empty replacement before recovering its data")
host_directory = remote("sudo -n stat -c %d:%i " + shlex.quote(path))
pods = json.loads(run(kubectl + ["-n", "container-registry", "get", "pods", "-l", "app=local-registry", "-o", "json"]))
running_registry = False
for pod in pods.get("items") or []:
if not any(status.get("name") == "registry" and status.get("state", {}).get("running")
for status in pod.get("status", {}).get("containerStatuses") or []):
continue
running_registry = True
pod_directory = run(kubectl + ["-n", "container-registry", "exec", pod["metadata"]["name"],
"-c", "registry", "--", "stat", "-c", "%d:%i", "/var/lib/registry"])
if pod_directory != host_directory:
raise RuntimeError("Running registry volume does not match the host directory's filesystem/inode; "
"preserve its mounted data before any pod restart or storage change")
if not raw_pv and hashlib.sha256(remote_manifest(remote, path).encode()).hexdigest() != receipt["manifest_sha256"]:
raise RuntimeError("Preseeded remote registry changed before its PV was created")
if not raw_pv:
current = remote_manifest(remote, path)
if hashlib.sha256(current.encode()).hexdigest() != receipt["manifest_sha256"]:
if running_registry:
raise RuntimeError("Registry is running while its preseeded data differs from the receipt; refusing offline verification")
baseline = local_manifest(path)
if hashlib.sha256(baseline.encode()).hexdigest() != receipt["manifest_sha256"]:
raise RuntimeError("Retained registry baseline does not match the migration receipt")
original_files, current_files = manifest_files(baseline), manifest_files(current)
if any(current_files.get(name) != digest for name, digest in original_files.items()):
raise RuntimeError("Remote registry is missing or changed a file from its verified baseline")
blob_pattern = re.compile(r"^\./docker/registry/v2/blobs/sha256/([0-9a-f]{2})/([0-9a-f]{64})/data$")
for name, digest in current_files.items():
match = blob_pattern.fullmatch(name)
if match and (match.group(1) != match.group(2)[:2] or match.group(2) != digest):
raise RuntimeError("Remote registry contains a blob whose contents do not match its digest")
if remote_manifest(remote, path) != current:
raise RuntimeError("Remote registry changed during offline verification")
print(f"Verified retained registry baseline and {len(current_files) - len(original_files)} additional files on {target}", flush=True)
if os.environ.get("LAB_CLUSTER_RUNTIME") == "k3s":
ensure_k3s_data_mount_dependency(remote, args.required_data_mount)
print(f"Preserving verified remote registry storage on {target}:{path}", flush=True)