Merge main (Go 1.26.10 pin) into group-verb-runbook-copy
12 files changed,
+153
−16
.amadan/ci.d/10-gate+1 −0.amadan/ci.d/20-cross@5+1 −0.amadan/ci.d/30-minio-contract+1 −0.amadan/go-toolchain.sh+22 −0internal/console/opstore_test.go+3 −4internal/console/scalecost_linux_test.go+30 −0internal/console/scalecost_other_test.go+13 −0internal/console/testdata/demo_claim_browser.mjs+6 −4internal/host/hadepartures_scan_test.go+31 −2internal/host/registrychild_exec_linux_test.go+20 −1internal/rollout/fake_test.go+22 −1internal/rollout/manager_test.go+3 −4
CI passed — run details
diff --git a/.amadan/ci.d/10-gate b/.amadan/ci.d/10-gate| index 540cf876e..19a206a80 100755 |
| --- a/.amadan/ci.d/10-gate |
| +++ b/.amadan/ci.d/10-gate |
| @@ -45,6 +45,7 @@ |
| # line, with the Makefile's note on why; they are still in force here, |
| # just not written down twice. |
| set -eu |
| +. .amadan/go-toolchain.sh |
| # The build runs beside the tests rather than before them: neither needs |
| # the other, and the gate's wall clock is whichever finishes last. |
diff --git a/.amadan/ci.d/20-cross@5 b/.amadan/ci.d/20-cross@5| index ee14fe7b4..b40d06de7 100755 |
| --- a/.amadan/ci.d/20-cross@5 |
| +++ b/.amadan/ci.d/20-cross@5 |
| @@ -23,6 +23,7 @@ |
| # itself in the shard that failed, instead of being the first line of a |
| # combined log. |
| set -eu |
| +. .amadan/go-toolchain.sh |
| shard=${AMADAN_SHARD:?this step must be run by amadan CI, which sets AMADAN_SHARD} |
| shards=${AMADAN_SHARD_COUNT:?this step must be run by amadan CI, which sets AMADAN_SHARD_COUNT} |
diff --git a/.amadan/ci.d/30-minio-contract b/.amadan/ci.d/30-minio-contract| index 741acac64..1ee952d70 100755 |
| --- a/.amadan/ci.d/30-minio-contract |
| +++ b/.amadan/ci.d/30-minio-contract |
| @@ -32,6 +32,7 @@ |
| # loopback only, its data directory is the job's private /tmp tmpfs, and |
| # it dies with the job's PID namespace. Nothing persists on the box. |
| set -eu |
| +. .amadan/go-toolchain.sh |
| # Fail on a missing tool by name rather than by a confusing error forty |
| # lines down. Both are present on the runner; this is here so that a |
diff --git a/.amadan/go-toolchain.sh b/.amadan/go-toolchain.sh| new file mode 100644 |
| index 000000000..e2f45b1aa |
| --- /dev/null |
| +++ b/.amadan/go-toolchain.sh |
| @@ -0,0 +1,22 @@ |
| +# Sourced by every .amadan/ci.d step: the Go toolchain CI builds and tests |
| +# with, pinned to what the release builds use rather than whatever the |
| +# runner has installed. |
| +# |
| +# go1.26.10, because Go 1.26.11's net/http deadlocks a server that writes |
| +# its response while another goroutine still reads the request body under |
| +# Expect: 100-continue (chunkWriter.writeHeader now takes the body's lock |
| +# through bodyRemains(), and body.Read holds it while blocked on the |
| +# network). The edge's reverse proxy does exactly that when an upstream |
| +# refuses early, and TestDemoAPIAliasStreaming's "early" cases hang on it. |
| +# Both CI runners moved to 1.26.11 on 2026-11-11 (carlos/platform #897); |
| +# releases are built on 1.26.10. |
| +# |
| +# A `toolchain go1.26.10` line in go.mod would not do this: the go command |
| +# only switches to a toolchain line NEWER than the local one. GOTOOLCHAIN |
| +# does downgrade. "+auto" still lets a go.mod that needs a newer Go fetch it. |
| +# |
| +# Re-check when Go ships a fix for the deadlock: move this to that version |
| +# (it also carries GO-2026-6859), with the early subtests as the witness. |
| +GOTOOLCHAIN=go1.26.10+auto |
| +export GOTOOLCHAIN |
| +go version |
diff --git a/internal/console/opstore_test.go b/internal/console/opstore_test.go| index 1126775e4..dec2bdb71 100644 |
| --- a/internal/console/opstore_test.go |
| +++ b/internal/console/opstore_test.go |
| @@ -890,13 +890,12 @@ func TestOperatorCountsAtScale(t *testing.T) { |
| // 102.5 ms against 100), so one run measures the worker, not the query. |
| const scaleTimingRuns = 5 |
| -// bestOfScaleRuns runs run scaleTimingRuns times and returns the fastest. |
| +// bestOfScaleRuns runs run scaleTimingRuns times and returns the fastest, |
| +// each timed by scaleCost. |
| func bestOfScaleRuns(run func()) time.Duration { |
| var best time.Duration |
| for i := 0; i < scaleTimingRuns; i++ { |
| - start := time.Now() |
| - run() |
| - if took := time.Since(start); i == 0 || took < best { |
| + if took := scaleCost(run); i == 0 || took < best { |
| best = took |
| } |
| } |
diff --git a/internal/console/scalecost_linux_test.go b/internal/console/scalecost_linux_test.go| new file mode 100644 |
| index 000000000..126da6b0c |
| --- /dev/null |
| +++ b/internal/console/scalecost_linux_test.go |
| @@ -0,0 +1,30 @@ |
| +package console |
| + |
| +import ( |
| + "runtime" |
| + "time" |
| + |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// scaleCost is the CPU time run takes on its own OS thread. A scale |
| +// query's budget is what the query costs, and the gate runs many test |
| +// processes side by side, so on a saturated CI worker even the best of |
| +// several wall-clock runs measured the scheduler: OperatorCounts' reads |
| +// came to 183 ms against 150 on CI and 54 ms on an idle machine (#897). |
| +// The thread's CPU clock leaves out the time the thread waited to run. |
| +func scaleCost(run func()) time.Duration { |
| + runtime.LockOSThread() |
| + defer runtime.UnlockOSThread() |
| + var before, after unix.Timespec |
| + if unix.ClockGettime(unix.CLOCK_THREAD_CPUTIME_ID, &before) != nil { |
| + start := time.Now() |
| + run() |
| + return time.Since(start) |
| + } |
| + run() |
| + if unix.ClockGettime(unix.CLOCK_THREAD_CPUTIME_ID, &after) != nil { |
| + panic("CLOCK_THREAD_CPUTIME_ID failed after succeeding") |
| + } |
| + return time.Duration(after.Nano() - before.Nano()) |
| +} |
diff --git a/internal/console/scalecost_other_test.go b/internal/console/scalecost_other_test.go| new file mode 100644 |
| index 000000000..7ca54d1aa |
| --- /dev/null |
| +++ b/internal/console/scalecost_other_test.go |
| @@ -0,0 +1,13 @@ |
| +//go:build !linux |
| + |
| +package console |
| + |
| +import "time" |
| + |
| +// scaleCost is wall-clock time where there is no per-thread CPU clock; |
| +// the budgets are enforced on CI, which is Linux. |
| +func scaleCost(run func()) time.Duration { |
| + start := time.Now() |
| + run() |
| + return time.Since(start) |
| +} |
diff --git a/internal/console/testdata/demo_claim_browser.mjs b/internal/console/testdata/demo_claim_browser.mjs| index da87de325..aa7aeba68 100644 |
| --- a/internal/console/testdata/demo_claim_browser.mjs |
| +++ b/internal/console/testdata/demo_claim_browser.mjs |
| @@ -7,10 +7,12 @@ import {checkClaimMotion} from './demo_claim_motion.mjs'; |
| // The page holds each stage, and a working button, for 650 ms by its own |
| // timers. Chromium runs timers in whole milliseconds and coarsens |
| // performance.now() (about 0.1 ms, with jitter), so a hold the page kept |
| -// can measure a fraction under 650 here: 649.8 ms on CI, 2026-11-11. One |
| -// millisecond of slack absorbs that; a page that skipped its hold would |
| -// still come up hundreds of milliseconds short. |
| -const heldAtLeast = 649; |
| +// can measure a little under 650 here: 649.8 ms on CI, and 648.5 ms on a |
| +// loaded CI worker later the same day (2026-11-11, #897). Ten milliseconds |
| +// of slack absorbs that. A page that skipped its hold would still come up |
| +// hundreds of milliseconds short, and one that shortened it noticeably |
| +// still fails. |
| +const heldAtLeast = 640; |
| const [binary, profile, target, screenshots, expectedError] = process.argv.slice(2); |
| const chrome = spawn(binary, ['--headless', '--no-sandbox', '--disable-gpu', |
diff --git a/internal/host/hadepartures_scan_test.go b/internal/host/hadepartures_scan_test.go| index 1db86ebdc..a9a003f83 100644 |
| --- a/internal/host/hadepartures_scan_test.go |
| +++ b/internal/host/hadepartures_scan_test.go |
| @@ -15,6 +15,7 @@ import ( |
| "github.com/carlosframework/platform/internal/termfence" |
| "path/filepath" |
| "strings" |
| + "sync" |
| "sync/atomic" |
| "testing" |
| "time" |
| @@ -54,6 +55,32 @@ type scanRig struct { |
| d registry.HADeparture |
| store *release.DirStore |
| imports int |
| + log scanLog |
| +} |
| + |
| +// scanLog keeps the controller's log lines and prints them only when the |
| +// test fails, so a CI failure says why a pass did not adopt (#733). It is |
| +// written from the consumer's goroutine too, hence the lock. |
| +type scanLog struct { |
| + mu sync.Mutex |
| + lines []string |
| +} |
| + |
| +func (l *scanLog) logf(f string, args ...any) { |
| + l.mu.Lock() |
| + defer l.mu.Unlock() |
| + l.lines = append(l.lines, time.Now().Format("15:04:05.000 ")+fmt.Sprintf(f, args...)) |
| +} |
| + |
| +func (l *scanLog) dumpOnFailure(t *testing.T) { |
| + t.Cleanup(func() { |
| + if !t.Failed() { |
| + return |
| + } |
| + l.mu.Lock() |
| + defer l.mu.Unlock() |
| + t.Logf("controller log (%d lines):\n%s", len(l.lines), strings.Join(l.lines, "\n")) |
| + }) |
| } |
| func newScanRig(t *testing.T, n int) *scanRig { |
| @@ -69,6 +96,7 @@ func newScanRigRef(t *testing.T, n int, ref string) *scanRig { |
| } |
| t.Cleanup(func() { r.Close() }) |
| x := &scanRig{r: r, now: time.Now(), locks: &scanReader{views: map[string]hafresh.View{}}, store: release.NewDirStore(t.TempDir())} |
| + x.log.dumpOnFailure(t) |
| scope := hadeparture.Scope{CloudRegion: "eu-west-1", DataBucket: "data", SecretsKeyFP: "fp"} |
| x.d = registry.HADeparture{Departure: hadeparture.Departure{ID: "dead", Box: hadeparture.Box{Ref: ref, InstanceID: "i-1123456789abcdef0", Account: "111122223333", Scope: scope}, ObservedAt: x.now.Add(-time.Hour), EdgesKey: "control/edges/" + ref + ".json"}, ProofKey: "proof", ProofDigest: "digest"} |
| edgeBody, _ := json.Marshal(map[string]string{"box": ref}) |
| @@ -86,7 +114,7 @@ func newScanRigRef(t *testing.T, n int, ref string) *scanRig { |
| marker := hafresh.Marker{V: 1, Box: ref, IID: x.d.Box.InstanceID, Lifetime: "life"} |
| x.locks.views[h.Host] = hafresh.View{ETag: "old", Lock: hafresh.Lock{Generation: 1, ExpiresAt: time.Unix(0, 0), Owner: hafresh.MarkerOwner(marker), Release: &marker}} |
| } |
| - x.c = &Controller{cfg: DepartureConfig{Registry: r, Self: hadeparture.Box{Ref: "self", InstanceID: "i-0123456789abcdef0", Account: "111122223333", Scope: scope}, Inventory: func() provision.InventorySnapshot { return x.inv }, Policy: func() LocalPolicy { return LocalPolicy{Scope: scope} }, Now: func() time.Time { return x.now }, Logf: func(string, ...any) {}, OpenStore: func(context.Context) (release.Store, error) { return x.store, nil }, NewReader: func(context.Context, string) (DepartureLockReader, error) { return x.locks, nil }, Prefix: func(h string) string { return h }, ValidateSuccessor: func(context.Context, string, string) (bool, error) { return true, nil }}, evidence: map[string]bool{"dead": true}} |
| + x.c = &Controller{cfg: DepartureConfig{Registry: r, Self: hadeparture.Box{Ref: "self", InstanceID: "i-0123456789abcdef0", Account: "111122223333", Scope: scope}, Inventory: func() provision.InventorySnapshot { return x.inv }, Policy: func() LocalPolicy { return LocalPolicy{Scope: scope} }, Now: func() time.Time { return x.now }, Logf: x.log.logf, OpenStore: func(context.Context) (release.Store, error) { return x.store, nil }, NewReader: func(context.Context, string) (DepartureLockReader, error) { return x.locks, nil }, Prefix: func(h string) string { return h }, ValidateSuccessor: func(context.Context, string, string) (bool, error) { return true, nil }}, evidence: map[string]bool{"dead": true}} |
| x.c.cfg.Adopt = func(ctx context.Context, h provision.DepartureHost, d registry.HADeparture, v hafresh.View) (activator.AdoptResult, error) { |
| x.imports++ |
| v.ETag = "new" |
| @@ -105,7 +133,8 @@ func newScanRigRef(t *testing.T, n int, ref string) *scanRig { |
| } |
| func (x *scanRig) pass(t *testing.T) { |
| t.Helper() |
| - _, err := x.c.ScanPass(t.Context()) |
| + worked, err := x.c.ScanPass(t.Context()) |
| + x.log.logf("test: %s ScanPass at %s: worked=%v err=%v", x.c.cfg.Self.Ref, x.now.Format(time.RFC3339), worked, err) |
| if err != nil { |
| t.Fatal(err) |
| } |
diff --git a/internal/host/registrychild_exec_linux_test.go b/internal/host/registrychild_exec_linux_test.go| index 0cafb04be..ce59fd757 100644 |
| --- a/internal/host/registrychild_exec_linux_test.go |
| +++ b/internal/host/registrychild_exec_linux_test.go |
| @@ -137,13 +137,32 @@ func TestRegistryChildFDHelper(t *testing.T) { |
| if err != nil { |
| os.Exit(21) |
| } |
| - if target != "anon_inode:[eventpoll]" && target != "anon_inode:[eventfd]" { |
| + if target != "anon_inode:[eventpoll]" && target != "anon_inode:[eventfd]" && !goRuntimeCgroupFD(target) { |
| + // Name the descriptor, so a failure says what leaked. |
| + fmt.Fprintf(os.Stderr, "unexpected fd %d -> %s\n", fd, target) |
| os.Exit(22) |
| } |
| } |
| os.Exit(0) |
| } |
| +// goRuntimeCgroupFD reports whether target is the CPU limit file the |
| +// child's own Go runtime holds open (internal/runtime/cgroup's quotaFD, |
| +// since Go 1.25) to follow its cgroup's limit for GOMAXPROCS. The child |
| +// opens it itself, close-on-exec, at startup, so it says nothing about |
| +// what the parent let through. It exists only where the cgroup sets a |
| +// CPU limit: every CI job's does, a desktop session's usually not. |
| +func goRuntimeCgroupFD(target string) bool { |
| + if !strings.HasPrefix(target, "/sys/fs/cgroup/") { |
| + return false |
| + } |
| + switch filepath.Base(target) { |
| + case "cpu.max", "cpu.cfs_quota_us", "cpu.cfs_period_us": |
| + return true |
| + } |
| + return false |
| +} |
| + |
| func TestRegistryChildPinnedExecutableAndMinimalFDs(t *testing.T) { |
| dir := t.TempDir() |
| original, err := os.Open("/proc/self/exe") |
diff --git a/internal/rollout/fake_test.go b/internal/rollout/fake_test.go| index f6e5c20d7..b6c1738c7 100644 |
| --- a/internal/rollout/fake_test.go |
| +++ b/internal/rollout/fake_test.go |
| @@ -445,6 +445,27 @@ type harness struct { |
| // policyHook, when set, runs at the start of every policy load, with no |
| // lock held: a test's window into the planner's policy read. |
| policyHook func() |
| + // logMu guards logs, the manager's log lines, in order. |
| + logMu sync.Mutex |
| + logs []string |
| +} |
| + |
| +func (h *harness) logf(f string, args ...any) { |
| + h.logMu.Lock() |
| + defer h.logMu.Unlock() |
| + h.logs = append(h.logs, fmt.Sprintf(f, args...)) |
| +} |
| + |
| +// logged reports whether the manager has logged a line containing s. |
| +func (h *harness) logged(s string) bool { |
| + h.logMu.Lock() |
| + defer h.logMu.Unlock() |
| + for _, l := range h.logs { |
| + if strings.Contains(l, s) { |
| + return true |
| + } |
| + } |
| + return false |
| } |
| func newHarness(t *testing.T, hosts ...string) *harness { |
| @@ -467,7 +488,7 @@ func newHarness(t *testing.T, hosts ...string) *harness { |
| h.m = NewManager(ctx, Deps{ |
| Act: h.probe, Routes: h.rows, Book: h.book, OptDir: h.opt, DataDir: h.data, Box: "box-1", |
| Demand: h.demand, Policy: h.policy, Pointer: h.pointerFor, Events: h.events, |
| - Touch: func() { h.touched.Add(1) }, Now: h.clock, Logf: func(string, ...any) {}, |
| + Touch: func() { h.touched.Add(1) }, Now: h.clock, Logf: h.logf, |
| }) |
| return h |
| } |
diff --git a/internal/rollout/manager_test.go b/internal/rollout/manager_test.go| index 8506c1cdc..138017436 100644 |
| --- a/internal/rollout/manager_test.go |
| +++ b/internal/rollout/manager_test.go |
| @@ -1168,10 +1168,9 @@ func TestAPointerClearRequeuesBeforeTheNextChannelIsRead(t *testing.T) { |
| if reads.Add(1) != 2 { |
| return |
| } |
| - h.m.mu.Lock() |
| - n := len(h.m.retried) |
| - h.m.mu.Unlock() |
| - if n == 0 { |
| + // Not len(m.retried): retryBuild pokes the scheduler, which may |
| + // attempt the build and clear its entry before this second read. |
| + if !h.logged("build v2 retried") { |
| requeuedLate.Store(true) |
| } |
| } |