From 8b2abd08cdf8807591b51a496472766f73845b11 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 7 Oct 2026 02:17:46 +0200 Subject: [PATCH] Remove what an earlier delivery of a check left before raising its store again An ask redelivered after the build agent stopped mid-check (the rollout it was checking updated it) found its own throwaway store under its name, and the check said it could not run (mesh-controller#105, build-1791331512096605198). --- internal/builder/check.go | 7 +++++++ internal/builder/check_test.go | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/internal/builder/check.go b/internal/builder/check.go index ac0ee21..8df5ef5 100644 --- a/internal/builder/check.go +++ b/internal/builder/check.go @@ -298,6 +298,13 @@ func Check(ctx context.Context, run Runner, spec CheckSpec, workspace, registry say("check", "the facts of %s (%s): %d machine(s), the bus at %s, the store at %s", f.Taken.Format(time.RFC3339), short(strings.TrimPrefix(digest, "sha256:")), len(f.Machines), f.Versions.Bus, f.Versions.Store) + // **What an earlier delivery of this same ask left is removed first** (novox/hq issue 285): an ask is + // redelivered when the holder that took it stopped mid-check — the build agent itself updated by the + // rollout it is checking — and its containers, named by the ask's id, are still there. Raising the + // store again under that name was refused, and the check said it could not run. + if n, err := RemoveContainersOf(ctx, run, spec.ID); err == nil && n > 0 { + say("check", "removed %d throwaway container(s) an earlier delivery of this check left", n) + } // The throwaway store and bus, of the versions the mesh runs, removed whatever happens. defer func() { removing, done := context.WithTimeout(context.Background(), time.Minute) diff --git a/internal/builder/check_test.go b/internal/builder/check_test.go index 346e099..eca7b55 100644 --- a/internal/builder/check_test.go +++ b/internal/builder/check_test.go @@ -457,3 +457,26 @@ func TestTheSeatCallsAGateThatRaisedNoMachineAnError(t *testing.T) { t.Error("a failing verdict is the change's, and stands") } } + +// **Issue 285**: an ask redelivered after its holder stopped mid-check found its own throwaway store still +// there under its name, and the check said it could not run. What an earlier delivery left goes first. +func TestARedeliveredCheckRemovesWhatItsEarlierDeliveryLeft(t *testing.T) { + registry := checkEnvironment(t) + repo, head := aCheckedRepository(t, map[string]string{CheckScript: "echo checked\n"}) + id := fmt.Sprintf("check-again-%d", time.Now().UnixNano()) + if out, err := exec.Command("docker", "run", "-d", "--rm", "--label", BuildLabel+"="+id, "--name", id+"-store", + "postgres:17-alpine", "sleep", "300").CombinedOutput(); err != nil { + t.Skipf("no container for the earlier delivery: %v %s", err, out) + } + v, err := Check(t.Context(), Command, CheckSpec{ID: id, Repository: repo, Ref: head, Owner: "novox", + Repo: "hq", Number: 7, Toolchain: goToolchain}, t.TempDir(), registry, GitCredential{}, nil) + if err != nil { + t.Fatalf("a redelivered check could not run: %v", err) + } + if v.Repo == nil || v.Repo.Verdict != "pass" { + t.Errorf("the repository's check answered %+v", v.Repo) + } + if left := labelled(id); len(left) > 0 { + t.Errorf("the check left %d container(s) behind", len(left)) + } +}