Skip to content

eBPF-based security platform

bpm: remove a pending record behind the cursor before looking for it

Daniel Borkmann84632f3ad1b4
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 9d70cfa4..a97c534b 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -307,13 +307,16 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
nothing past the cut
* - ``bpm-tree-recovery-model``
- ``tree_recover_pending()``
- - Publications with 0 to 2 operations, a matching or unrelated
- pending record, each TPM replay class, the measured flag,
+ - Publications with 0 to 2 operations, a pending record at, below
+ or above the cursor that matches an operation or none, each TPM
+ replay class, the measured flag,
whether the upatch is loaded and every first failing I/O call.
The previous root and the history root have all 32 symbolic
bytes.
- - The return decision, ordered writes, the outcome lines of the
- operations passed over and of the pending one, cursor, tree ID,
+ - The return decision, a record at or below the cursor removed
+ whatever the publication holds included, ordered writes, the
+ outcome lines of the operations passed over and of the pending
+ one, cursor, tree ID,
manifest, recorded head and base, both projection roots and the
history root match the independent recovery model
* - ``bpm-tree-overlap-model``
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index 72c98305..b1987fc0 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -719,6 +719,13 @@ signed config image.
names it in ``JAVA_TOOL_OPTIONS`` under a ``java_load``, a
``delete`` takes the agent and the options out under a
``java_unload``
+ * - ``t7113-bpm-tree-pending-passed``
+ - In ``functional/bpm-pending/``, a VM of its own, on the tree
+ ``t7108`` walks: a sync stopped after ``pending.json`` and before
+ the measure, under labels that select the operation, and a sync
+ under labels that select none, which passes it and leaves its
+ record behind the cursor; the next segment, which no longer
+ holds the operation, then syncs, removes the record and goes on
* - Test
- Covers
* - ``t8001-otel-map``
@@ -1026,8 +1033,8 @@ Coverage by area
* - upatch tree
- ``t3011``, ``t5004``, ``t7005``, ``t7007``, ``t7008``, ``t7009``,
``t7101``, ``t7102``, ``t7103``, ``t7104``, ``t7105``, ``t7106``,
- ``t7107``, ``t7108``, ``t7109``, ``t7110``, ``t9105``, ``t9109``,
- ``t9110``, ``t9111``.
+ ``t7107``, ``t7108``, ``t7109``, ``t7110``, ``t7113``,
+ ``t9105``, ``t9109``, ``t9110``, ``t9111``.
Fuzz: ``tree``,
``tree-state``, ``kconfig``. Unit: ``bpm_tree``,
``bpm_tree_overlap``, ``bpm_tree_state``, ``chain_history``,
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 0f2d0d10..af824aa9 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -171,11 +171,13 @@ A shell test is named ``t<F><K><NN>-<what>.sh``:
seal, task authority, task and socket policy inheritance, the
keyrings and the TPM path
* - 7
- - ``functional/bpm/``, ``functional/bpm-segments/``
+ - ``functional/bpm/``, ``functional/bpm-segments/``,
+ ``functional/bpm-pending/``
- Package commands, Beefile policy labels, publishing and the
upatch tree; ``bpm-segments`` boots a VM of its own, whose node
starts without a tree, for the walk through a tree's segments
- and the keepalive window over them
+ and the keepalive window over them, and ``bpm-pending`` one for
+ a pending operation a later segment no longer holds
* - 8
- ``functional/otel/``
- Map export, the status keepalive, OTLP transport and TLS policy
diff --git a/Documentation/reference/cli/status.rst b/Documentation/reference/cli/status.rst
index 5ad1092d..280ad4cf 100644
--- a/Documentation/reference/cli/status.rst
+++ b/Documentation/reference/cli/status.rst
@@ -86,7 +86,8 @@ reads a tree a sync is changing: while one runs, ``status`` waits up to
sent. A sync writes ``pending.json`` before it loads or unloads anything
and removes it only after ``state.json`` has the new ``last_seq``, so
``tree_op_pending`` says a sync stopped in the middle of an operation
-and the next sync completes it. ``status`` still reads ``state.json``,
+and the next sync completes it, or removes it once a sync has passed
+it. ``status`` still reads ``state.json``,
looks for ``pending.json``, reads the outcomes up to that ``last_seq``
and the loaded upatches, then looks for ``pending.json`` and reads
``state.json`` again, and starts over when the second ``state.json``
diff --git a/Documentation/reference/failure-categories.rst b/Documentation/reference/failure-categories.rst
index a5b9b6b0..bf5beb17 100644
--- a/Documentation/reference/failure-categories.rst
+++ b/Documentation/reference/failure-categories.rst
@@ -663,8 +663,11 @@ rc=<rc> (<strerror>)`` and exits 1:
``history_root`` differs from the node's (``EKEYREJECTED``).
Nothing of the publication is applied.
* - ``pending_recovery``
- - An interrupted operation cannot be reconciled with the tree
- eventlog, or its ``outcomes`` lines or state cannot be written.
+ - An interrupted operation above the cursor is not one the
+ publication holds (``ERANGE``) or cannot be reconciled with the
+ tree eventlog, or its ``outcomes`` lines or state cannot be
+ written. One at or below the cursor is removed, whatever the
+ publication holds.
* - ``selector_evaluate``
- The selector cannot be evaluated: the node labels or the kernel
config cannot be read. The cursor stays on the operation.
diff --git a/Documentation/reference/files.rst b/Documentation/reference/files.rst
index 7c5c229c..25cb1879 100644
--- a/Documentation/reference/files.rst
+++ b/Documentation/reference/files.rst
@@ -177,7 +177,8 @@ the label as foreign. In the initrd, ``init`` binds
* - ``bpm/upatch-tree/pending.json``
- ``bpm tree sync``
- ``0600``
- - The operation in progress, removed when it completes.
+ - The operation in progress, removed when it completes or when
+ the next sync finds it at or below the cursor.
* - ``bpm/upatch-tree/artifacts/<layer-digest>.upatch``
- ``bpm tree sync``
- ``0600``
diff --git a/Documentation/reference/formats/upatch-tree.rst b/Documentation/reference/formats/upatch-tree.rst
index a2f2e568..6aef6e10 100644
--- a/Documentation/reference/formats/upatch-tree.rst
+++ b/Documentation/reference/formats/upatch-tree.rst
@@ -566,8 +566,12 @@ state with ``last_seq`` above 0 whose ``outcomes`` is missing
``pending.json``
~~~~~~~~~~~~~~~~
-``seq``, ``id`` and ``operation_digest`` of the operation in progress,
-present only while one is.
+``seq``, ``id`` and ``operation_digest`` of the operation in progress.
+A sync removes it once ``state.json`` records the operation applied. When
+a later sync passes the operation without applying it, as one the
+selector no longer matches, the record stays until the next sync, whose
+recovery removes a record at or below the cursor whatever the
+publication holds.
Other files
~~~~~~~~~~~
diff --git a/builtin-bpm.c b/builtin-bpm.c
index bfe44c1e..98345aed 100644
--- a/builtin-bpm.c
+++ b/builtin-bpm.c
@@ -2108,6 +2108,15 @@ static int tree_recover_pending(const struct tree_publication *pub,
return 0;
if (ret)
return ret;
+ /*
+ * The cursor was committed past it, whatever came of it: the
+ * publication may since have moved on to a segment that no longer
+ * holds it.
+ */
+ if (pending.seq <= state->last_seq) {
+ unlink(BPM_TREE_PENDING_PATH);
+ return 0;
+ }
for (int i = 0; i < pub->n_operations; i++) {
if (pub->operations[i].seq == pending.seq &&
!strcmp(pub->operations[i].id, pending.id) &&
@@ -2119,10 +2128,6 @@ static int tree_recover_pending(const struct tree_publication *pub,
}
if (!op)
return -ERANGE;
- if (pending.seq <= state->last_seq) {
- unlink(BPM_TREE_PENDING_PATH);
- return 0;
- }
if (sha256_digest_decode(pending.operation_digest, digest) ||
hex_decode(state->projection_root, previous, 32))
return -EINVAL;
diff --git a/testing/functional/bpm-pending/t7113-bpm-tree-pending-passed.sh b/testing/functional/bpm-pending/t7113-bpm-tree-pending-passed.sh
new file mode 100755
index 00000000..ac0e548a
--- /dev/null
+++ b/testing/functional/bpm-pending/t7113-bpm-tree-pending-passed.sh
@@ -0,0 +1,134 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# t7113 -- a pending operation the node stopped matching and passed does not
+# stop the node: a sync stopped after writing pending.json for an operation
+# and before measuring it, then a sync under labels no operation selects,
+# which passes the operation and leaves its record behind the cursor, and
+# then a sync of the next segment, which no longer holds the operation,
+# removes the record and goes on. On the tree t7108 walks, in a VM of its
+# own, as the node starts without a tree.
+
+cd "$(dirname "$0")/../.."
+. ./integration-lib.sh
+target_guard
+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
+
+FIXTURES=${SHIRUDO_TEST_FIXTURES_DIR:?target fixture directory is not set}
+SOURCE="$FIXTURES/segments-oci"
+PENDING=/var/lib/shirudo/bpm/upatch-tree/pending.json
+WORK=$(mktemp -d)
+SERVED="$WORK/registry"
+REPO="$SERVED/shirudo/segments"
+SERVER_PID=
+
+for fixture in "$SOURCE/port" "$SOURCE/shirudo/segments/manifests/g4" \
+ "$SHIRUDO_TEST_KEY_FIXTURES/config-tree-segments-other.img" \
+ "$SHIRUDO_TEST_KEY_FIXTURES/config-tree-segments-none.img" \
+ ./helper/test-oci-registry.py
+do
+ [ -s "$fixture" ] || test_skip_all "missing segment fixture: $fixture"
+done
+[ ! -e "$TREE_STATE_FILE" ] || test_skip_all "the node already follows a tree"
+PORT=$(cat "$SOURCE/port")
+
+cleanup()
+{
+ if [ -n "$SERVER_PID" ]; then
+ kill "$SERVER_PID" 2>/dev/null || true
+ wait "$SERVER_PID" 2>/dev/null || true
+ fi
+ rm -rf "$WORK"
+}
+trap cleanup EXIT
+
+# The manifest digest of the artifact of operation $2 of the publication
+# the reference $1 names.
+artifact_of()
+{
+ python3 - "$REPO" "$1" "$2" <<'PY'
+import json
+import pathlib
+import sys
+
+DOC = "application/vnd.shirudo.upatch.tree.v1+json"
+repo, ref, seq = pathlib.Path(sys.argv[1]), sys.argv[2], int(sys.argv[3])
+layers = json.loads((repo / "manifests" / ref).read_bytes())["layers"]
+blob = [layer for layer in layers if layer["mediaType"] == DOC][0]
+document = json.loads((repo / "blobs" / blob["digest"]).read_bytes())
+print([op for op in document["operations"]
+ if op["seq"] == seq][0]["artifact"]["manifest_digest"])
+PY
+}
+
+# The target follows the reference segments, which names generation $1.
+serve()
+{
+ cp "$REPO/manifests/$1" "$REPO/manifests/segments"
+}
+
+sync_tree()
+{
+ BPM_OCI_SCHEME=http "$SHIRUDO_BIN" bpm tree sync \
+ --report "$WORK/$1.json" >/dev/null 2>"$WORK/$1.err"
+}
+
+state_is()
+{
+ [ "$(tree_state_field last_seq)" = "$1" ] &&
+ [ "$(tree_state_field generation)" = "$2" ] &&
+ [ "$(tree_state_field segment_base_seq)" = "$3" ] &&
+ [ "$(tree_state_field head_seq)" = "$4" ]
+}
+
+cp -R "$SOURCE" "$SERVED"
+python3 ./helper/test-oci-registry.py --root "$SERVED" --port "$PORT" \
+ --ready-file "$WORK/ready" &
+SERVER_PID=$!
+for _ in 1 2 3 4 5; do
+ [ -e "$WORK/ready" ] && break
+ sleep 1
+done
+[ -e "$WORK/ready" ] || test_skip_all "the segment registry did not start"
+# Operation 2 adds the upatch the labels env=not-this-node select, which no
+# sync fetched before: with its manifest gone the sync stops after writing
+# pending.json and before measuring the operation.
+OTHER=$(artifact_of g2 2) || test_skip_all "cannot read the segment fixtures"
+
+test_expect_success 'a sync stopped before measuring an operation leaves it pending' '
+ "$SHIRUDO_BIN" image update \
+ "$SHIRUDO_TEST_KEY_FIXTURES/config-tree-segments-other" >/dev/null &&
+ serve g2 &&
+ mv "$REPO/manifests/$OTHER" "$WORK/other-manifest" &&
+ ! sync_tree stopped &&
+ mv "$WORK/other-manifest" "$REPO/manifests/$OTHER" &&
+ grep -q "phase=artifact_fetch_or_verify " "$WORK/stopped.err" &&
+ [ -e "$PENDING" ] &&
+ state_is 0 2 0 2
+'
+
+test_expect_success 'a sync under labels no operation selects passes it and leaves its record' '
+ "$SHIRUDO_BIN" image update \
+ "$SHIRUDO_TEST_KEY_FIXTURES/config-tree-segments-none" >/dev/null &&
+ sync_tree passed &&
+ [ "$(report_field applied <"$WORK/passed.json")" = 0 ] &&
+ [ -e "$PENDING" ] &&
+ state_is 2 2 0 2
+'
+
+test_expect_success 'the next segment, which no longer holds the operation, syncs and removes its record' '
+ serve g4 &&
+ sync_tree next &&
+ [ ! -e "$PENDING" ] &&
+ [ "$(report_field last_seq <"$WORK/next.json")" = 4 ] &&
+ state_is 4 4 2 4
+'
+
+test_expect_success 'a sync after it goes on from there' '
+ serve g6 &&
+ sync_tree after &&
+ state_is 6 6 4 6
+'
+
+test_done
diff --git a/testing/proofs/cbmc/bpm-tree-sync-model.c b/testing/proofs/cbmc/bpm-tree-sync-model.c
index 87ed700b..457a6d21 100644
--- a/testing/proofs/cbmc/bpm-tree-sync-model.c
+++ b/testing/proofs/cbmc/bpm-tree-sync-model.c
@@ -1099,6 +1099,10 @@ static bool recover_in(struct mstate *st, const struct tree_publication *p)
if (!have_pending)
return true;
+ if (disk_pending.seq <= st->last_seq) {
+ want_write(W_UNLINK, 0, 0, NULL, NULL);
+ return true;
+ }
for (int i = 0; i < p->n_operations; i++) {
const struct tree_operation *q = &p->operations[i];
@@ -1112,10 +1116,6 @@ static bool recover_in(struct mstate *st, const struct tree_publication *p)
}
if (!o)
return false;
- if (disk_pending.seq <= st->last_seq) {
- want_write(W_UNLINK, 0, 0, NULL, NULL);
- return true;
- }
digest_of(disk_pending.operation_digest, d);
model_hash(st->root, d, next);
if (replay_kind == 1)
diff --git a/testing/proofs/lean4/Shirudo/TreeSync.lean b/testing/proofs/lean4/Shirudo/TreeSync.lean
index b40ecf13..8dc74e9a 100644
--- a/testing/proofs/lean4/Shirudo/TreeSync.lean
+++ b/testing/proofs/lean4/Shirudo/TreeSync.lean
@@ -526,19 +526,22 @@ def fresh (t : T) : State T M D := ⟨t, 0, 0, init, none, 0⟩
/-- `tree_recover_pending()`: the writes it makes and the state the loop
goes on from, or `none` for a refusal before it writes anything. Every
-refusal after a write stops the run as a crash there does. An operation it
-finds applied gets its outcome lines before the state that covers them. -/
+refusal after a write stops the run as a crash there does. A pending
+operation at or below the cursor is removed before the publication is
+looked at, as the cursor was committed past it and the publication may no
+longer hold it. An operation it finds applied gets its outcome lines
+before the state that covers them. -/
def recover (n : Node T M I D) (pub : Pub T M I D) (st : State T M D) :
Option (List (Write T M I D) × State T M D) :=
match n.pending with
| none => some ([], st)
| some p =>
- match pub.ops.find?
- (fun o => o.seq = p.seq ∧ o.id = p.id ∧ o.digest = p.digest) with
- | none => none
- | some o =>
- if p.seq ≤ st.lastSeq then some ([.unlink], st)
- else
+ if p.seq ≤ st.lastSeq then some ([.unlink], st)
+ else
+ match pub.ops.find?
+ (fun o => o.seq = p.seq ∧ o.id = p.id ∧ o.digest = p.digest) with
+ | none => none
+ | some o =>
let next := H st.root p.digest
let st' := { st with root := next, lastSeq := o.seq }
let unapplied :=
@@ -1246,15 +1249,19 @@ theorem recover_same [DecidableEq I] [DecidableEq D] {H : D → D → D} {init :
unfold recover
rw [hs.pending, hs.measured, hs.log]
-/-- Recovery only goes on with a pending operation the publication has. -/
+/-- Recovery only goes on with a pending operation above the cursor that
+the publication has. -/
theorem recover_found [DecidableEq I] [DecidableEq D] {H : D → D → D} {init : D}
{n : Node T M I D} {pub : Pub T M I D} {st0 st : State T M D}
{ws : List (Write T M I D)} {p : Op I D}
(hrec : recover H init n pub st0 = some (ws, st))
- (hp : n.pending = some p) : ∃ o ∈ pub.ops, o.seq = p.seq := by
+ (hp : n.pending = some p) (hlt : st0.lastSeq < p.seq) :
+ ∃ o ∈ pub.ops, o.seq = p.seq := by
unfold recover at hrec
simp only [hp] at hrec
split at hrec
+ · omega
+ split at hrec
· simp at hrec
rename_i o hf
have hos := List.find?_some hf
@@ -1413,20 +1420,6 @@ theorem recover_inv {Signed : Pub T M I D → M → Prop}
| some p =>
simp only [hp] at hrec
split at hrec
- · simp at hrec
- rename_i o hf
- have ho : o ∈ pub.ops := List.mem_of_find?_eq_some hf
- have hos := List.find?_some hf
- simp only [decide_eq_true_eq] at hos
- have hop : o = p := by
- obtain ⟨h1, h2, h3⟩ := hos
- cases o
- cases p
- simp only at h1 h2 h3
- subst h1 h2 h3
- rfl
- subst hop
- split at hrec
· rename_i hle
simp only [Option.some.injEq, Prod.mk.injEq] at hrec
obtain ⟨rfl, rfl⟩ := hrec
@@ -1451,6 +1444,20 @@ theorem recover_inv {Signed : Pub T M I D → M → Prop}
hinv' hw.1 hw.2
hchk hfol hsig, hspec⟩
rename_i hgt
+ split at hrec
+ · simp at hrec
+ rename_i o hf
+ have ho : o ∈ pub.ops := List.mem_of_find?_eq_some hf
+ have hos := List.find?_some hf
+ simp only [decide_eq_true_eq] at hos
+ have hop : o = p := by
+ obtain ⟨h1, h2, h3⟩ := hos
+ cases o
+ cases p
+ simp only at h1 h2 h3
+ subst h1 h2 h3
+ rfl
+ subst hop
have hlt : cursor n < o.seq := by omega
-- The pending operation has no line at or below the cursor.
have hnotin : ∀ L : List (Line D), (∀ l ∈ L, l.seq ≤ cursor n) →
@@ -2564,7 +2571,8 @@ theorem orecover_inv {H : D → D → D} {pub : Pub T M I D} {n : Node T M I D}
(hlen : pub.baseSeq + (pub.ops.length : Int) = pub.headSeq)
(hbc : pub.baseSeq ≤ cursor n)
(hst0 : st0.lastSeq = cursor n) (hcur : cursor n ≤ pub.headSeq)
- (hfound : ∀ p, n.pending = some p → ∃ o ∈ pub.ops, o.seq = p.seq)
+ (hfound : ∀ p, n.pending = some p → cursor n < p.seq →
+ ∃ o ∈ pub.ops, o.seq = p.seq)
(hspec : RecoverSpec n (recLines H pub st0) ws st) :
Along OInv OMono ws n ∧ Exact (applyAll ws n) st.lastSeq ∧
cursor (applyAll ws n) ≤ st.lastSeq ∧ st.lastSeq ≤ pub.headSeq ∧
@@ -2578,10 +2586,11 @@ theorem orecover_inv {H : D → D → D} {pub : Pub T M I D} {n : Node T M I D}
by omega, ho, fun q hq => absurd (hp.symm.trans hq) (by simp)⟩
| some p =>
simp only [RecoverSpec, hp] at hspec
- obtain ⟨o, hom, hop⟩ := hfound p hp
- have hoh := (consec_mem pub.ops pub.baseSeq hcs hom).2
- have hph : p.seq ≤ pub.headSeq := by omega
- rcases hspec with ⟨-, rfl, hl⟩ | ⟨-, -, -, rfl, hl⟩ |
+ have hph : cursor n < p.seq → p.seq ≤ pub.headSeq := fun hlt => by
+ obtain ⟨o, hom, hop⟩ := hfound p hp hlt
+ have hoh := (consec_mem pub.ops pub.baseSeq hcs hom).2
+ omega
+ rcases hspec with ⟨-, rfl, hl⟩ | ⟨hlt, -, -, rfl, hl⟩ |
⟨hlt, -, -, ⟨r, rfl⟩, hl, hh⟩ | ⟨hlt, -, rfl, hl, hh⟩
· have h1 : OInv ((Write.unlink : Write T M I D).apply n) :=
⟨Covers.of_eq rfl rfl ho.covers, ho.head,
@@ -2595,17 +2604,17 @@ theorem orecover_inv {H : D → D → D} {pub : Pub T M I D} {n : Node T M I D}
by omega, ho, fun q hq => by
have e : p = q := Option.some.inj (hp.symm.trans hq)
rw [← e]
- exact hph⟩
+ exact hph hlt⟩
· have h1 : OInv ((Write.append ⟨p.seq, p.digest, r⟩ :
Write T M I D).apply n) :=
ho.inert rfl rfl ho.pend
obtain ⟨ha, hxe, hcu, hoi, hpe⟩ := ocomplete_inv (H := H) (pub := pub)
(n := (Write.append ⟨p.seq, p.digest, r⟩ : Write T M I D).apply n)
- (st0 := st0) (st := st) hx h1 hcs hlen hbc hst0 hlt hph hl hh hp
+ (st0 := st0) (st := st) hx h1 hcs hlen hbc hst0 hlt (hph hlt) hl hh hp
exact ⟨along_cons ho (OMono.inert rfl rfl) ha, hxe, hcu, by omega, hoi,
hpe⟩
· obtain ⟨ha, hxe, hcu, hoi, hpe⟩ := ocomplete_inv (H := H) (pub := pub)
- (st0 := st0) (st := st) hx ho hcs hlen hbc hst0 hlt hph hl hh hp
+ (st0 := st0) (st := st) hx ho hcs hlen hbc hst0 hlt (hph hlt) hl hh hp
exact ⟨ha, hxe, hcu, by omega, hoi, hpe⟩
/-- A whole sync, as far as the outcomes record and the head go, stopped
@@ -2669,7 +2678,8 @@ theorem orun_inv [DecidableEq T] [DecidableEq M] [DecidableEq I]
ha.hash_init hinv0 hchk hfol hsig hrec0
have hst0 := (start_facts H init ha.binds hinv0 hchk hfol hsig).2.1
obtain ⟨haw, hxw, hcw, hbw, how, hpw⟩ := orecover_inv hx0 ho0 hcs hlen
- hbc hst0 hcur (fun p hp => recover_found hrec0 hp) hspec
+ hbc hst0 hcur (fun p hp hlt => recover_found hrec0 hp
+ (Int.lt_of_le_of_lt (Int.le_of_eq hst0) hlt)) hspec
have hnn : pub.baseSeq ≤ st.lastSeq := by
have hm := along_between OMono.refl (fun _ _ _ => OMono.trans) haw 0
ws.length (Nat.zero_le _)
diff --git a/testing/vm/image-fixtures.sh b/testing/vm/image-fixtures.sh
index 23ec7dfd..e1d11bc4 100755
--- a/testing/vm/image-fixtures.sh
+++ b/testing/vm/image-fixtures.sh
@@ -77,11 +77,14 @@ for name in config-boot-keys config-live-new-key config-live-revoke-a config-a c
config-tree-kconfig config-tree-reloaded config-tree-outcomes \
config-tree-stopped config-tree-fetched config-tree-fixes \
config-tree-keepalive config-tree-unmatched config-tree-java-added \
- config-tree-java-deleted config-tree-segments \
+ config-tree-java-deleted config-tree-segments config-tree-segments-other \
+ config-tree-segments-none \
config-otel config-jsonl config-jsonl-bad config-interrupted config-end2end \
config-edge config-core config-local-stack config-builtin config-untrusted; do
[ "$name" != config-builtin ] || [ -n "$builtin_key" ] || continue
- [ "$name" != config-tree-segments ] || [ -n "$segments_port" ] || continue
+ case $name in
+ config-tree-segments*) [ -n "$segments_port" ] || continue ;;
+ esac
root="$output/source/$name"
mkdir -p "$root/etc/shirudo" "$root/keys/trusted" "$root/keys/revoked"
sed "s/@tenant@/$name/g" "$templates/config.conf.in" \
@@ -90,11 +93,25 @@ for name in config-boot-keys config-live-new-key config-live-revoke-a config-a c
config-tree-*)
mkdir -p "$root/etc/shirudo/bpm"
cp "$templates/node.labels" "$root/etc/shirudo/node.labels"
- sed "s/@reference@/${name#config-tree-}/g" \
+ reference=${name#config-tree-}
+ # The segment tree's artifacts name the port it was published
+ # on. Its other images follow the same tree with labels the
+ # node has not: one the tree's other upatch selects, and one
+ # no operation selects.
+ case $name in
+ config-tree-segments*)
+ reference=segments
+ case $name in
+ *-other) printf 'env=not-this-node\n' ;;
+ *-none) printf 'env=none\n' ;;
+ *) cat "$templates/node.labels" ;;
+ esac >"$root/etc/shirudo/node.labels"
+ ;;
+ esac
+ sed "s/@reference@/$reference/g" \
"$templates/upatch-tree.conf.in" \
>"$root/etc/shirudo/bpm/upatch-tree.conf"
- # The segment tree's artifacts name the port it was published on.
- [ "$name" != config-tree-segments ] ||
+ [ "$reference" != segments ] ||
sed -i "s|127.0.0.1:5443/shirudo/upatch-tree|127.0.0.1:$segments_port/shirudo/segments|" \
"$root/etc/shirudo/bpm/upatch-tree.conf"
;;