Skip to content

Commit 03b0656

Browse files
feat(storage): prepare a verified backup for the V2 restore trial (#6452)
* test(storage): bind benchmark cleanup to native runtime identities * test(storage): verify the selected V1 runtime stayed stable * test(storage): prove native benchmark admission safeguards * fix(storage): verify the benchmark PV fence on every API server * fix(storage): verify the detached benchmark backend fence * fix(storage): checkpoint V1 benchmark retirement fences * fix(storage): retire benchmark scratch by recorded identity * fix(storage): preserve benchmark runtime identity * fix(storage): verify the benchmark runtime’s immutable image digest * chore: Apply megalinter fixes * fix(storage): align benchmark assets with production admission * fix(storage): parse native benchmark denial attribution * fix(storage): pin the approved benchmark retirement runtime * fix(storage): include benchmark admission in production inputs * fix(storage): bind retired instances to their approved runtime > 🤖 Generated by the Agentic Engineer Reject named stopped instances outside the original runtime set. Exercise fence installation against persistent intent and UID receipts, and keep post-seal verification separate from deletion. Refs: #5665 * test(storage): clarify retirement fixtures and transport > 🤖 Generated by the Agentic Engineer Keep fake journal transport state explicit, extract the validated runtime fixture, and bind the peer-refusal request to its test context. Refs: #5665 * feat(storage): prepare a verified disposable backup for V2 Create and verify isolated test data and its filesystem backup before conditional source retirement. Preserve ambiguous operations for explicit recovery. Refs: #5809 * fix(storage): record the disposable backup schedule approval Approve the single Velero surface change that excludes the disposable trial namespace from recurring backups. Keep the authorization validator and every other ledger entry unchanged. Refs: #6451 * fix(storage): require sealed nodes for benchmark retirement * fix(storage): allow the explicit migration seed backup * test(storage): cover lost receipts and reserved attachment names * refactor(storage): isolate read-only seed backup polling * feat(storage): prepare a verified backup for the V2 restore trial * fix(storage): recognize isolated Velero schedules * fix(storage): authorize direct API proofs during benchmark recovery * test(storage): preserve benchmark image identity across activation * fix(storage): pin the signed Longhorn benchmark image --------- Co-authored-by: botantler-1[bot] <185060876+botantler-1[bot]@users.noreply.github.com>
1 parent e9da2c4 commit 03b0656

42 files changed

Lines changed: 2784 additions & 21 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/prepare-longhorn-v2-node.yaml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ name: Prepare Longhorn V2 Migration
3131
benchmark-v2,
3232
recover-unstarted-v1-benchmark,
3333
recover-bound-v1-benchmark,
34+
prepare-native-v1-seed,
3435
inventory-replicas,
3536
inventory-storage-root,
3637
inventory-storage-layout,
@@ -132,6 +133,9 @@ jobs:
132133
set -euo pipefail
133134
[[ "${DISPATCH_REF}" == refs/heads/main && "${GITHUB_RUN_ATTEMPT}" == 1 ]] || exit 1
134135
case "${LONGHORN_V2_OPERATION}" in
136+
prepare-native-v1-seed)
137+
[[ -z "${LONGHORN_V2_NODE}" && -z "${LONGHORN_V2_DATABASE}" && "${LONGHORN_V2_CONFIRM}" == prepare-longhorn-native-v1-seed ]]
138+
;;
135139
inventory-v1-runtime)
136140
[[ -z "${LONGHORN_V2_NODE}" && -z "${LONGHORN_V2_DATABASE}" && "${LONGHORN_V2_CONFIRM}" == inventory-v1-runtime ]]
137141
;;
@@ -250,13 +254,13 @@ jobs:
250254
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
251255
run: ./scripts/use-prod-stable-api-endpoint.sh
252256
- name: Run the confirmed migration preparation
253-
if: ${{ inputs.operation != 'benchmark-v1' && inputs.operation != 'recover-bound-v1-benchmark' }}
257+
if: ${{ inputs.operation != 'benchmark-v1' && inputs.operation != 'recover-bound-v1-benchmark' && inputs.operation != 'prepare-native-v1-seed' }}
254258
env:
255259
GH_TOKEN: ${{ github.token }}
256260
LONGHORN_RUNTIME_INVENTORY_SOURCE: ${{ steps.recovery-source.outputs.sha }}
257261
run: go run ./scripts/migrate-longhorn-v2
258-
- name: Run the confirmed V1 benchmark
259-
if: ${{ inputs.operation == 'benchmark-v1' }}
262+
- name: Run the confirmed V1 scratch operation
263+
if: ${{ inputs.operation == 'benchmark-v1' || inputs.operation == 'prepare-native-v1-seed' }}
260264
env:
261265
GH_TOKEN: ${{ github.token }}
262266
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}

‎internal/namespaceinventory/credentials.go‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,22 @@ func LoadProtectedClient(getenv func(string) string) (*http.Client, *url.URL, er
6666
return newProductionClient(config)
6767
}
6868

69-
// LoadBenchmarkAdmissionClient admits the protected V1 benchmark or the
70-
// explicitly confirmed recovery of originalRun. The caller must first join
71-
// the selected address to its serving process and verified Hetzner server.
69+
// LoadBenchmarkAdmissionClient admits the protected V1 benchmark, native seed,
70+
// or the explicitly confirmed recovery of originalRun. The caller must first
71+
// join the selected address to its serving process and verified Hetzner server.
7272
func LoadBenchmarkAdmissionClient(getenv func(string) string, directIP netip.Addr, originalRun string) (*http.Client, *url.URL, error) {
7373
operation, confirmation := "benchmark-v1", "benchmark-longhorn-storage"
74-
if originalRun != "" {
75-
if !runPattern.MatchString(originalRun) || originalRun == getenv("GITHUB_RUN_ID") ||
76-
getenv("LONGHORN_V2_NODE") != "" || getenv("LONGHORN_V2_DATABASE") != "" {
74+
switch {
75+
case originalRun != "":
76+
if !runPattern.MatchString(originalRun) || originalRun == getenv("GITHUB_RUN_ID") {
7777
return nil, nil, errors.New("protected benchmark admission dispatch is unverified")
7878
}
7979
operation, confirmation = "recover-bound-v1-benchmark", "recover-bound-longhorn-v1-benchmark:"+originalRun
80+
case getenv("LONGHORN_V2_OPERATION") == "prepare-native-v1-seed":
81+
operation, confirmation = "prepare-native-v1-seed", "prepare-longhorn-native-v1-seed"
82+
}
83+
if operation != "benchmark-v1" && (getenv("LONGHORN_V2_NODE") != "" || getenv("LONGHORN_V2_DATABASE") != "") {
84+
return nil, nil, errors.New("protected benchmark admission dispatch is unverified")
8085
}
8186
for key, want := range map[string]string{
8287
"GITHUB_ACTIONS": "true", "GITHUB_EVENT_NAME": "workflow_dispatch", "GITHUB_REF": "refs/heads/main",

‎internal/namespaceinventory/credentials_test.go‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import (
99
"net/http"
1010
"net/http/httptest"
1111
"net/netip"
12+
"os"
13+
"path/filepath"
14+
"runtime"
1215
"strings"
1316
"testing"
17+
"time"
1418

19+
"k8s.io/client-go/tools/clientcmd"
1520
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
1621
)
1722

@@ -176,3 +181,114 @@ func TestBenchmarkCredentialLoaderRefusesOutsideProtectedDispatch(t *testing.T)
176181
t.Fatal("direct credential loader admitted an unverified dispatch")
177182
}
178183
}
184+
185+
func nativeSeedAdmissionDispatch() map[string]string {
186+
return map[string]string{
187+
"GITHUB_ACTIONS": "true", "GITHUB_EVENT_NAME": "workflow_dispatch", "GITHUB_REF": "refs/heads/main",
188+
"GITHUB_REPOSITORY": "devantler-tech/platform", "GITHUB_RUN_ATTEMPT": "1", "RUNNER_ENVIRONMENT": "github-hosted",
189+
"GITHUB_WORKFLOW_REF": "devantler-tech/platform/.github/workflows/prepare-longhorn-v2-node.yaml@refs/heads/main",
190+
"GITHUB_SHA": strings.Repeat("a", 40), "GITHUB_RUN_ID": "1234",
191+
"LONGHORN_V2_OPERATION": "prepare-native-v1-seed", "LONGHORN_V2_CONFIRM": "prepare-longhorn-native-v1-seed",
192+
// Deliberately invalid: no credential file may be opened by this test.
193+
"KUBECONFIG": "private-credential-path-canary",
194+
}
195+
}
196+
197+
func TestNativeSeedReachesTheExistingAdmissionCredentialBoundary(t *testing.T) {
198+
valid := nativeSeedAdmissionDispatch()
199+
getenv := func(key string) string { return valid[key] }
200+
client, endpoint, err := LoadBenchmarkAdmissionClient(getenv, netip.MustParseAddr("203.0.113.10"), "")
201+
if client != nil || endpoint != nil || err == nil || err.Error() != "fixed benchmark admission credentials and direct IPv4 peer are required" {
202+
t.Fatal("the confirmed seed did not reach the unchanged credential boundary:", err)
203+
}
204+
benchmark := func(key string) string {
205+
if key == "LONGHORN_V2_OPERATION" {
206+
return "benchmark-v1"
207+
}
208+
if key == "LONGHORN_V2_CONFIRM" {
209+
return "benchmark-longhorn-storage"
210+
}
211+
return valid[key]
212+
}
213+
if client, endpoint, err := LoadBenchmarkAdmissionClient(benchmark, netip.MustParseAddr("203.0.113.10"), ""); client != nil || endpoint != nil || err == nil || err.Error() != "fixed benchmark admission credentials and direct IPv4 peer are required" {
214+
t.Fatal("the original confirmed benchmark lost its credential boundary:", err)
215+
}
216+
for _, key := range []string{"GITHUB_ACTIONS", "GITHUB_EVENT_NAME", "GITHUB_REF", "GITHUB_REPOSITORY", "GITHUB_RUN_ATTEMPT", "RUNNER_ENVIRONMENT", "GITHUB_WORKFLOW_REF", "LONGHORN_V2_OPERATION", "LONGHORN_V2_CONFIRM", "LONGHORN_V2_NODE", "LONGHORN_V2_DATABASE"} {
217+
t.Run(key, func(t *testing.T) {
218+
changed := func(name string) string {
219+
if name == key {
220+
return "foreign"
221+
}
222+
return valid[name]
223+
}
224+
client, endpoint, err := LoadBenchmarkAdmissionClient(changed, netip.MustParseAddr("203.0.113.10"), "")
225+
if client != nil || endpoint != nil || err == nil || err.Error() != "protected benchmark admission dispatch is unverified" {
226+
t.Fatal("a foreign or targeted seed reached credential loading:", err)
227+
}
228+
})
229+
}
230+
for _, pair := range [][2]string{{"benchmark-v1", "prepare-longhorn-native-v1-seed"}, {"prepare-native-v1-seed", "benchmark-longhorn-storage"}, {"restore-native-v2-seed", "prepare-longhorn-native-v1-seed"}} {
231+
changed := func(key string) string {
232+
if key == "LONGHORN_V2_OPERATION" {
233+
return pair[0]
234+
}
235+
if key == "LONGHORN_V2_CONFIRM" {
236+
return pair[1]
237+
}
238+
return valid[key]
239+
}
240+
if _, _, err := LoadBenchmarkAdmissionClient(changed, netip.MustParseAddr("203.0.113.10"), ""); err == nil || err.Error() != "protected benchmark admission dispatch is unverified" {
241+
t.Fatal("mismatched operation/confirmation pair reached credentials:", err)
242+
}
243+
}
244+
}
245+
246+
func TestAdmissionLoaderBuildsConfirmedClientsFromPrivateMemoryCredentials(t *testing.T) {
247+
if runtime.GOOS != "linux" {
248+
t.Skip("the protected credential directory is Linux memory-backed storage")
249+
}
250+
server := httptest.NewTLSServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { t.Error("loader contacted an API") }))
251+
t.Cleanup(server.Close)
252+
directory, err := os.MkdirTemp("/dev/shm", "longhorn-v2.")
253+
if err != nil {
254+
t.Fatal(err)
255+
}
256+
t.Cleanup(func() {
257+
if err := os.RemoveAll(directory); err != nil {
258+
t.Error(err)
259+
}
260+
})
261+
raw, err := clientcmd.Write(*fixtureConfig(server))
262+
if err != nil {
263+
t.Fatal(err)
264+
}
265+
path := filepath.Join(directory, "kubeconfig")
266+
if err := os.WriteFile(path, raw, 0600); err != nil {
267+
t.Fatal(err)
268+
}
269+
for _, dispatch := range []struct {
270+
operation string
271+
confirmation string
272+
originalRun string
273+
}{
274+
{operation: "benchmark-v1", confirmation: "benchmark-longhorn-storage"},
275+
{operation: "prepare-native-v1-seed", confirmation: "prepare-longhorn-native-v1-seed"},
276+
{operation: "recover-bound-v1-benchmark", confirmation: "recover-bound-longhorn-v1-benchmark:99", originalRun: "99"},
277+
} {
278+
valid := nativeSeedAdmissionDispatch()
279+
valid["LONGHORN_V2_OPERATION"], valid["LONGHORN_V2_CONFIRM"] = dispatch.operation, dispatch.confirmation
280+
valid["KUBECONFIG"], valid["LONGHORN_V2_CREDENTIAL_DIR"] = path, directory
281+
client, endpoint, err := LoadBenchmarkAdmissionClient(func(key string) string { return valid[key] }, netip.MustParseAddr("203.0.113.10"), dispatch.originalRun)
282+
if err != nil || client == nil || endpoint == nil || endpoint.String() != "https://203.0.113.10:6443" || client.Timeout != 20*time.Second {
283+
t.Fatal("confirmed operation could not construct its fixed client:", dispatch.operation, err)
284+
}
285+
response, err := client.Get(server.URL + "/version")
286+
if response != nil {
287+
_ = response.Body.Close()
288+
}
289+
if err == nil {
290+
t.Fatal("loaded client addressed a different peer")
291+
}
292+
client.CloseIdleConnections()
293+
}
294+
}

‎k8s/bases/infrastructure/controllers/velero/helm-release.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ spec:
306306
excludedNamespaces:
307307
- kube-system
308308
- velero
309+
# Disposable storage trials use their own explicitly owned backup.
310+
- longhorn-benchmark
309311
# snapshotMoveData makes Velero's data mover upload CSI snapshots to
310312
# the R2 BSL. No-op on base/local (no CSI — everything uses FSB);
311313
# active in prod, where the hetzner overlay sets features: EnableCSI

‎k8s/providers/hetzner/infrastructure/controllers/longhorn/namespace-benchmark.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ metadata:
66
labels:
77
pod-security.kubernetes.io/enforce: restricted
88
pod-security.kubernetes.io/enforce-version: latest
9-
velero.io/exclude-from-backup: "true"
109
annotations:
1110
kustomize.toolkit.fluxcd.io/prune: disabled

‎scripts/migrate-longhorn-v2/README.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,46 @@ memory before creating scratch resources. The V2 comparison uses the worker
366366
recorded in its completed V1 baseline. Existing baselines retain their original
367367
third-worker placement.
368368

369+
## Disposable recovery source
370+
371+
`prepare-native-v1-seed`, confirmed with `prepare-longhorn-native-v1-seed`,
372+
prepares only the source half of a filesystem recovery canary. Leave `node` and
373+
`database` empty. It requires the cleaned V1 baseline, three healthy copies of
374+
every Longhorn volume, the original approved retirement-manager epochs, and an
375+
already available four-GiB scratch budget. The source Pod's memory request must
376+
fit on the first permanent worker before scratch creation. The procedure changes
377+
no reservation.
378+
379+
The fixed `longhorn-benchmark` workspace must be empty. The daily Velero schedule
380+
explicitly excludes it. Other schedules may instead select only named, unrelated
381+
namespaces with cluster-scoped resources disabled and no resource policy. The source Pod and
382+
claim opt in only their `data` filesystem volume for this run's separately
383+
selected Backup. The procedure writes and verifies a 128-MiB payload, sentinel
384+
and checksum. It refuses restored, cloned, encrypted or differently bound
385+
source storage.
386+
387+
The existing default Velero destination must be Available, ReadWrite and recently
388+
validated. No Longhorn backup target or credentials are added. A seven-day Backup
389+
selects only this run's Pod and claim, with CSI snapshots, data movement and
390+
cluster resources disabled. Native completion, exactly one complete Kopia
391+
transfer, its source Pod UID, snapshot ID and the original Ready repository UID
392+
and spec are required. A completed Backup by itself does not establish data
393+
transfer. The same evidence is checked again before source retirement and after
394+
local cleanup.
395+
396+
`longhorn-v2-native-seed` retains the original resource identities and each
397+
conditional phase transition. Uncertain creates or journal writes stop without
398+
retrying or adopting objects by name. Cleanup uses the V1 benchmark's original
399+
runtime, serving-API fences and physical retirement proof, then removes the run's
400+
replica tags. It leaves the remote backup and workspace intact. An interrupted
401+
run preserves its journal and assets for a separately reviewed recovery path.
402+
403+
`SOURCE_CLEANED` accepts no V2 restore, reattachment, benchmark measurement or
404+
application migration. A separate V2 phase must restore the original snapshot to
405+
new storage, verify the original bytes, persist a new write, reattach on another
406+
qualified worker and verify both again. Encrypted storage and application-specific
407+
recovery still require their own proofs.
408+
369409
## Prepare a permanent worker
370410

371411
`prepare-worker` rebuilds one permanent worker's local disk so it can hold V2 replicas. It wipes

‎scripts/migrate-longhorn-v2/api.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ type client struct {
128128
context string
129129
inventoryPools map[string]migrationPool
130130
inventoryPreparation *journal
131+
nativeSeed bool
131132
}
132133

133134
var kubeName = regexp.MustCompile(`^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$`)

‎scripts/migrate-longhorn-v2/benchmark.go‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ func benchmarkMachines(s inventory, phase string) (map[string]benchmarkMachine,
9393
}
9494

9595
func readBenchmark(ctx context.Context, c client, phase string) (object, benchmarkRecord, error) {
96-
cm, err := c.get(ctx, "configmap", "longhorn-system", "longhorn-v2-benchmark-"+phase, true)
96+
name, workload := "longhorn-v2-benchmark-"+phase, benchmarkWorkload()
97+
if c.nativeSeed {
98+
if phase != "v1" {
99+
return nil, benchmarkRecord{}, errors.New("the native seed cannot select another engine's journal")
100+
}
101+
name, workload = nativeSeedJournal, nativeSeedWorkload()
102+
}
103+
cm, err := c.get(ctx, "configmap", "longhorn-system", name, true)
97104
if err != nil || cm == nil {
98105
return cm, benchmarkRecord{}, err
99106
}
@@ -121,12 +128,16 @@ func readBenchmark(ctx context.Context, c client, phase string) (object, benchma
121128
return nil, record, errors.New("benchmark journal is malformed")
122129
}
123130
var extra any
131+
allowedImage := record.Image == fioImage || (!c.nativeSeed && record.Image == legacyFioImage)
124132
if d.Decode(&extra) != io.EOF || !benchmarkNamespaceMatches(record) || record.Phase != phase ||
125-
(record.Image != fioImage && record.Image != legacyFioImage) || record.Workload != benchmarkWorkload() ||
133+
!allowedImage || record.Workload != workload ||
126134
!validBenchmarkOwner(record.Run, record.Source) || len(record.Machines) != 3 ||
127135
(record.clientNode() != benchmarkClientNode && record.clientNode() != legacyBenchmarkClientNode) {
128136
return nil, record, errors.New("benchmark journal does not match this reviewed procedure")
129137
}
138+
if c.nativeSeed && (record.Version != 3 || record.Namespace != benchmarkNamespace || record.Recovery != nil || record.Cleaned || len(record.Measurements) != 0 || len(record.TagNodes) != 3) {
139+
return nil, record, errors.New("native seed retirement cannot adopt benchmark results or a different workspace")
140+
}
130141
for _, name := range []string{"prod-worker-1", "prod-worker-2", "prod-worker-3"} {
131142
m := record.Machines[name]
132143
if m.ProviderID == "" || m.SystemUUID == "" || m.OSImage == "" || m.Architecture != "amd64" {

‎scripts/migrate-longhorn-v2/benchmark_admission_install.go‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,15 @@ func activeBenchmarkV1FenceOwner(c client, record benchmarkRecord) bool {
115115
return false
116116
}
117117
if record.Recovery != nil {
118-
return authorizeBoundV1Recovery(os.Getenv) == nil &&
118+
return !c.nativeSeed && authorizeBoundV1Recovery(os.Getenv) == nil &&
119119
os.Getenv("LONGHORN_V2_CONFIRM") == recoverBoundV1Confirmation+record.Run &&
120120
verifyBoundRecoveryRecord(record, record.Run) == nil &&
121121
record.Recovery.Source == os.Getenv("GITHUB_SHA") && record.Recovery.Run == os.Getenv("GITHUB_RUN_ID")
122122
}
123-
return authorizeBenchmark(os.Getenv, "v1") == nil &&
123+
if c.nativeSeed && (record.Version != 3 || record.Namespace != benchmarkNamespace || record.Workload != nativeSeedWorkload()) {
124+
return false
125+
}
126+
return authorizeScratchV1(c, os.Getenv) == nil &&
124127
record.Source == os.Getenv("GITHUB_SHA") && record.Run == os.Getenv("GITHUB_RUN_ID")
125128
}
126129

‎scripts/migrate-longhorn-v2/benchmark_admission_install_flow_test.go‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type benchmarkFenceInstallFake struct {
2020
}
2121

2222
func TestBenchmarkFenceInstallationPersistsOwnershipBeforeDependentWrites(t *testing.T) {
23-
for _, fault := range []string{"", "ambiguous policy create", "policy receipt write", "ambiguous binding create", "binding receipt write", "concurrent journal"} {
23+
for _, fault := range []string{"", "ambiguous policy create", "policy receipt write", "lost policy receipt response", "ambiguous binding create", "binding receipt write", "lost binding receipt response", "concurrent journal"} {
2424
t.Run(fault, func(t *testing.T) {
2525
record := retirementFenceFixture(t)
2626
for key, val := range dispatchFixture() {
@@ -123,6 +123,9 @@ func (f *benchmarkFenceInstallFake) patchJournal(input []byte) ([]byte, error) {
123123
}
124124
f.stored, f.version = next, f.version+1
125125
f.events = append(f.events, "journal:"+stage)
126+
if f.fault == "lost policy receipt response" && stage == "policy-receipt" || f.fault == "lost binding receipt response" && stage == "binding-receipt" {
127+
return nil, errors.New("journal response lost after commit")
128+
}
126129
return nil, nil
127130
}
128131

@@ -163,6 +166,8 @@ func (f *benchmarkFenceInstallFake) assertResult(c client, record benchmarkRecor
163166
switch f.fault {
164167
case "ambiguous policy create", "policy receipt write":
165168
want = want[:2]
169+
case "lost policy receipt response":
170+
want = want[:3]
166171
case "ambiguous binding create", "binding receipt write":
167172
want = want[:5]
168173
case "concurrent journal":
@@ -177,7 +182,17 @@ func (f *benchmarkFenceInstallFake) assertResult(c client, record benchmarkRecor
177182
}
178183
return
179184
}
180-
if !reflect.DeepEqual(record, f.stored) {
185+
if f.fault == "lost policy receipt response" || f.fault == "lost binding receipt response" {
186+
wantReceipt := benchmarkFenceReceipt{PolicyUID: "policy-uid"}
187+
wantIntent := f.name + "/policy"
188+
if f.fault == "lost binding receipt response" {
189+
wantReceipt.BindingUID = "binding-uid"
190+
wantIntent = f.name + "/binding"
191+
}
192+
if record.FencePending != wantIntent || f.stored.FencePending != "" || f.stored.Fences[f.name] != wantReceipt {
193+
f.t.Fatal("an unconfirmed journal response lost the persisted receipt or advanced the caller")
194+
}
195+
} else if !reflect.DeepEqual(record, f.stored) {
181196
f.t.Fatal("in-memory ownership advanced beyond the persisted journal")
182197
}
183198
if f.fault == "" {
@@ -187,7 +202,8 @@ func (f *benchmarkFenceInstallFake) assertResult(c client, record benchmarkRecor
187202
return
188203
}
189204
before := slices.Clone(f.events)
190-
if installBenchmarkFence(f.t.Context(), c, &record, desired) == nil || !slices.Equal(f.events, before) {
205+
persisted := f.stored
206+
if installBenchmarkFence(f.t.Context(), c, &record, desired) == nil || !slices.Equal(f.events, before) || !reflect.DeepEqual(f.stored, persisted) {
191207
f.t.Fatal("unreceipted create was retried or adopted")
192208
}
193209
}

0 commit comments

Comments
 (0)