Snapshot views: resolve the bind path, publish the verified manifest, keep the boot unit

The mount table records resolved paths, so the unmount pass matched nothing while
the view stayed mounted; mounting by snapshot name then failed on a non-empty
directory and the prune step tried to delete a live read-only view. Compare
resolved paths and drop a failed target instead of publishing it.

Publish data/private/release-cycle/snapshots.json for the portal (its own mount
namespace and ZFS .zfs/snapshot traversal are both unusable there), and keep the
boot-time mount unit in the repository.

Also record that the 1.0.1 cycle 20261114T133314Z finished and published.
This commit is contained in:
Pavel Isaev 2026-11-15 22:35:48 +03:00
parent ab3163f14a
commit 4afb8b0d21
6 changed files with 125 additions and 52 deletions

View file

@ -12,12 +12,26 @@ writes `data/private/release-cycle/cycle-request.json`. `release-cycle.py` gaine
on `--resume`), records `snapshot`/`request` in the run state and refuses a date
without `core/os/x86_64/core.db`. A scheduled run therefore cannot inherit manual
inputs. `new` captures through a transient `systemd-run` unit so the read-only bind
view is created in the host mount namespace that serves HTTP; the portal lists and
validates snapshots from the ZFS dataset (`tank/archipelago/archlinux`), because its
own namespace never sees a view created afterwards. `deploy/mirror-snapshot.sh` and
`deploy/mirror-snapshot-mount.sh` now live in the repository: creation is immutable
per UTC date, retention keeps three, and views whose snapshot was destroyed are
pruned instead of left as stale empty directories.
view is created in the host mount namespace that serves HTTP. The mount script then
writes the verified list (each date checked against `core/os/x86_64/core.db` in the
published view) to `data/private/release-cycle/snapshots.json`, which the portal
lists and validates against: the portal's own namespace never sees a view created
afterwards, and ZFS `.zfs/snapshot` entries are not traversable from that unit
(`ELOOP` inside a sandboxed namespace). `deploy/mirror-snapshot.sh`,
`deploy/mirror-snapshot-mount.sh` and `deploy/archipelago-mirror-snapshot-mount.service`
(the boot-time owner of those views) now live in the repository: creation is
immutable per UTC date, retention keeps three, and views whose snapshot was
destroyed are pruned instead of left as stale empty directories.
Two fixes came out of running it on terra. The mount table always records the
resolved path (`/opt/archipelago/data` is a symlink onto the tank dataset), so the
"unmount existing views" pass must compare resolved paths; it previously matched
nothing, and mounting over a live view failed while the view survived the prune
step. Mounting snapshots by name also requires an *empty* target directory, so a
failed mount now removes its directory instead of publishing a date that no longer
resolves. The mirror view `2026-11-12` is mounted again, `snapshots.json` lists it,
`/api/status` returns it, and HTTPS still serves `core/os/x86_64/core.db` (200) and
`extra/os/x86_64/extra.db` (200).
Desktop Purposes run `linux-zen`. `purposes/proposals/{gnome,kde}.yaml` install it and
declare `spec.packages.replacements` (`target: linux`, `expected_owner: core/arch`);
@ -32,16 +46,23 @@ deleted path and inconsistent compose metadata) and the builder test
`pacman -R linux` leave exactly the expected paths; does the finalizer see one
kernel) is only proven by the next published cycle.
## ISO cycle 20261114T133314Z with OS version 1.0.1.<tag> (in progress, 2026-11-14)
## ISO cycle 20261114T133314Z with OS version 1.0.1.<tag> (published 2026-11-14)
Full ISO cycle against the November snapshot, built from `cli f3a57f9` (the OS
package version is now `1.0.1.<BUILD_ID>`) plus `system abd4bc6`,
`builder 666cb76` and `rfc 51a3f9c`. Started 13:33:14 UTC; Core completed in
494 s with `archipelago-1.0.1.b45b0c2412e2dfef561ac510-1` present in the
captured package metadata, then GNOME, KDE and Container Runner. Both Flatpak
caches reported `unchanged`. This run froze its source before D-113, so its
image commits have no size metadata. Publication is not yet confirmed; do not
treat the version change as delivered until the HTTPS/ref check below passes.
caches reported `unchanged`. The run finished and published at 15:24:53 UTC into
generation `hardware-b6rine44`: `current` points there, `releases.json` lists Core,
GNOME and KDE, `ostree/images` refs are `stable/core 3071739…`, `stable/gnome
477a580…`, `stable/kde 62f6910…`, and HTTPS serves `ostree/images/summary` and
`summary.sig` (200), `iso/archipelago-core.iso` with `Content-Length` 2389542912
(matching `releases.json`), `archipelago-gnome.iso` and `archipelago-kde.iso`.
This run froze its source before D-113, so its image commits carry no size
metadata and clients will not see an update size for this build; the next cycle
publishes it. The OS version change and the size metadata are therefore still
only proven in the next published cycle.
## Build control portal shows real progress (2026-11-14)

View file

@ -57,9 +57,12 @@ build's inputs.
`new` creates a snapshot through a transient `systemd-run` unit, because the
read-only view it bind-mounts must land in the host mount namespace to be published
over HTTP; a mount made inside this unit's own namespace would be invisible to the
web server. Snapshot listing and validation read the ZFS dataset directly, so a view
created moments ago is visible here as well. Retention keeps at most three monthly
snapshots and prunes the orphaned views (`deploy/mirror-snapshot*.sh`).
web server. The mount script then publishes the verified list to
`data/private/release-cycle/snapshots.json` (each date checked against its Core
database in the published view), and the portal lists and validates from that
manifest — neither this unit's private namespace nor ZFS `.zfs/snapshot` traversal is
a reliable source here. Retention keeps at most three monthly snapshots and prunes
the orphaned views (`deploy/mirror-snapshot*.sh`).
Schedule buttons enable or disable the monthly dispatcher timer; the cadence itself
(1st of the month, ISO + OSTree) is fixed by the code and is not editable from the

View file

@ -24,11 +24,6 @@ RUN = re.compile(r'[0-9]{8}T[0-9]{6}Z')
SNAPSHOT = re.compile(r'[0-9]{4}-[0-9]{2}-[0-9]{2}')
SERVICE = 'archipelago-release-cycle.service'
TIMER = 'archipelago-release-cycle.timer'
# Immutable mirror snapshots live on ZFS; the read-only bind views below are
# published by HTTP from the host mount namespace.
SNAPSHOT_DATASET = Path('/tank/archipelago/archlinux')
SNAPSHOT_PREFIX = 'monthly-'
SNAPSHOT_VIEW = 'data/public/arch-repo-snapshot'
def read_json(path, default=None):
@ -45,7 +40,8 @@ class App:
self.archive = self.base / 'data/private/release-cycle'
self.history = self.base / 'data/private/pipeline-monitor'
self.worker = Path(config['worker_root']) / 'build/release-cycle'
self.snapshot_dataset = Path(config.get('snapshot_dataset', str(SNAPSHOT_DATASET)))
self.snapshot_manifest = Path(config.get('snapshot_manifest',
str(self.archive / 'snapshots.json')))
self.lock = threading.Lock()
self.networks = [ipaddress.ip_network(n) for n in config['allowed_networks']]
@ -69,21 +65,17 @@ class App:
return sorted(states, key=lambda s: (s.get("updated") or s.get("started") or "", s.get("run") or ""), reverse=True)
def snapshots(self):
"""Immutable repository views, read from the dataset itself.
"""Immutable repository views published by the snapshot owner.
A bind view created moments ago exists only in the host mount namespace,
so listing the published directory would hide it from this unit. The ZFS
snapshot list is the source of truth; every listed entry is validated by
its Core database, which is what the cycle resolves packages from.
The list comes from the manifest written by the mount script: a bind view
created moments ago exists only in the host mount namespace, and ZFS
`.zfs/snapshot` entries are not traversable from this unit, so neither is
a reliable source here. Every listed date was verified against its Core
database in the published view.
"""
root = self.snapshot_dataset / '.zfs/snapshot'
result = []
if root.is_dir():
for entry in root.glob(SNAPSHOT_PREFIX + '*'):
date = entry.name.removeprefix(SNAPSHOT_PREFIX)
if SNAPSHOT.fullmatch(date) and (entry / 'core/os/x86_64/core.db').is_file():
result.append({'date': date,
'url': '/archipelago/arch-repo-snapshot/' + date + '/$repo/os/$arch'})
data = read_json(self.snapshot_manifest, {}) or {}
result = [item for item in data.get('snapshots', [])
if isinstance(item, dict) and SNAPSHOT.fullmatch(item.get('date', ''))]
return sorted(result, key=lambda item: item['date'], reverse=True)
def snapshot_date(self, choice):

View file

@ -0,0 +1,13 @@
[Unit]
Description=Mount read-only monthly Arch mirror snapshot views
After=tank-archipelago-archlinux.mount local-fs.target
RequiresMountsFor=/tank/archipelago/archlinux
ConditionPathIsDirectory=/tank/archipelago/archlinux
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/sbin/archipelago-mirror-snapshot-mount
[Install]
WantedBy=multi-user.target

View file

@ -1,24 +1,39 @@
#!/bin/bash
# Bind-mount each monthly mirror snapshot read-only under the public artifact
# root, and prune views whose snapshot was destroyed by retention.
# Mount each monthly mirror snapshot read-only under the public artifact root,
# prune views whose snapshot was destroyed by retention, and publish the
# resulting list for the control portal.
set -euo pipefail
mountroot=/tank/archipelago/archlinux
view=/opt/archipelago/data/public/arch-repo-snapshot
mkdir -p "$view"
dataset=tank/archipelago/archlinux
# /opt/archipelago/data is a symlink onto the tank dataset, but the kernel mount
# table always records the resolved path, so compare resolved paths.
view=$(realpath -m /opt/archipelago/data/public/arch-repo-snapshot)
manifest=/opt/archipelago/data/private/release-cycle/snapshots.json
mkdir -p "$view" "$(dirname "$manifest")"
# Unmount every existing view first: recreating them is idempotent, and a view
# must never be pruned while its snapshot is still bind-mounted.
# must never be pruned while its snapshot is still mounted.
while read -r m; do
umount "$m" 2>/dev/null || true
done < <(awk -v v="$view/" '$3 ~ "^" v {print $3}' /proc/mounts)
umount "$m" 2>/dev/null || echo "warning: cannot unmount $m" >&2
done < <(awk -v v="$view/" '$2 ~ "^" v {print $2}' /proc/mounts)
# Mount snapshots by name: `.zfs/snapshot` automount entries can stay dangling
# after a dataset remount, which makes that path unusable from a service.
mapfile -t snaps < <(zfs list -H -o name -t snapshot -d 1 "$dataset" | grep -E '@monthly-' | sort)
declare -A keep=()
for d in "$mountroot"/.zfs/snapshot/monthly-*; do
[ -d "$d" ] || continue
name=${d##*/}
date=${name#monthly-}
dates=()
for snap in "${snaps[@]}"; do
date=${snap##*@monthly-}
keep[$date]=1
target="$view/$date"
mkdir -p "$target"
mount --bind -o ro "$d" "$target"
if ! mount -t zfs -o ro "$snap" "$target"; then
# Never leave an unmounted directory behind: it would publish a stale
# snapshot date that no longer resolves, and the prune step would then
# break the retention contract in the other direction.
echo "warning: cannot mount $snap" >&2
unset 'keep[$date]'
rmdir "$target" 2>/dev/null || true
continue
fi
dates+=("$date")
echo "mounted $date"
done
for target in "$view"/*; do
@ -26,6 +41,30 @@ for target in "$view"/*; do
date=${target##*/}
[[ $date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || continue
[ -n "${keep[$date]:-}" ] && continue
if mountpoint -q "$target"; then
echo "warning: view $date is still mounted; not pruning" >&2
continue
fi
echo "pruning view $date"
rm -rf "$target"
done
# The portal must not depend on this mount namespace or on ZFS automounts, so the
# owner of the views publishes the verified list after mounting.
temporary=$(mktemp "$manifest.XXXXXX")
{
printf '{\n "updated": "%s",\n "snapshots": [' "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
separator=''
for date in "${dates[@]}"; do
if [ -f "$view/$date/core/os/x86_64/core.db" ]; then
printf '%s\n {"date": "%s", "url": "/archipelago/arch-repo-snapshot/%s/$repo/os/$arch"}' \
"$separator" "$date" "$date"
separator=','
else
echo "warning: view $date has no Core database" >&2
fi
done
printf '\n ]\n}\n'
} > "$temporary"
mv "$temporary" "$manifest"
chmod 0644 "$manifest"
echo "published $(grep -c '"date"' "$manifest") verified snapshot(s)"

View file

@ -98,15 +98,16 @@ class Portal(unittest.TestCase):
app.control('start', {'mode': 'reboot'})
self.assertFalse((app.archive / 'cycle-request.json').exists())
def test_snapshot_listing_requires_a_complete_core_database(self):
def test_snapshot_listing_uses_the_published_manifest(self):
with tempfile.TemporaryDirectory() as directory:
dataset = Path(directory) / 'archlinux'
complete = dataset / '.zfs/snapshot/monthly-2026-11-12/core/os/x86_64'
complete.mkdir(parents=True)
(complete / 'core.db').write_bytes(b'database')
(dataset / '.zfs/snapshot/monthly-2026-11-01').mkdir(parents=True)
base = Path(directory)
manifest = base / 'snapshots.json'
manifest.write_text(json.dumps({'updated': '2026-11-15T00:00:00Z', 'snapshots': [
{'date': '2026-11-12', 'url': '/archipelago/arch-repo-snapshot/2026-11-12/$repo/os/$arch'},
{'date': '../../etc'},
]}))
app = control.App(dict(coordinator_root=directory, worker_root=directory,
worker_source_root=directory, snapshot_dataset=str(dataset),
worker_source_root=directory, snapshot_manifest=str(manifest),
allowed_networks=['127.0.0.0/8'], hosts=[]))
self.assertEqual([item['date'] for item in app.snapshots()], ['2026-11-12'])
self.assertEqual(app.snapshot_date('latest'), '2026-11-12')
@ -114,6 +115,10 @@ class Portal(unittest.TestCase):
for choice in ('2026-11-01', '../../etc', ''):
with self.assertRaises(ValueError):
app.snapshot_date(choice)
# No published manifest is a clear refusal, not an empty build input.
manifest.unlink()
with self.assertRaises(ValueError):
app.snapshot_date('latest')
def test_progress_markup_and_percentage_rules(self):
root = Path(__file__).parents[1] / 'control'