ha: expose departure evidence and exercise production wiring
Publish departure counters and pending age through the existing metrics sampler. Keep permission notices bound to durable fault transitions. Exercise the real queue adapter, inventory, importer and completion path, and add executable startup mutation coverage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 files changed,
+814
−17
internal/host/hadepartures.go+17 −1internal/host/hadepartures_metrics.go+73 −0internal/host/hadepartures_metrics_test.go+63 −0internal/host/hadepartures_production_test.go+282 −0internal/host/hadepartures_scan.go+27 −3internal/host/hadepartures_wiring.go+1 −0internal/host/metrics_loop.go+15 −8internal/metrics/sample.go+19 −3internal/registry/ha_journal.go+33 −0internal/sim/regionha/duty_boundaries_test.go+221 −0internal/sim/regionha/mutate-startup.sh+28 −0internal/sim/regionha/mutate.sh+11 −1internal/sim/regionha/rules_test.go+9 −0internal/sim/regionha/witness_test.go+15 −1
Intent
Attributed to this commit: 6.94 g CO₂e (916,239 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p1b3b-duties, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/host/hadepartures.go b/internal/host/hadepartures.go| index 4281bf937..d59e48b74 100644 |
| --- a/internal/host/hadepartures.go |
| +++ b/internal/host/hadepartures.go |
| @@ -78,6 +78,7 @@ type DepartureConfig struct { |
| PageIdentity func(context.Context, registry.HAPendingTermination, string) error |
| } |
| type Controller struct { |
| + telemetry departureTelemetry |
| cfg DepartureConfig |
| consumer *hadeparture.Consumer |
| mu sync.Mutex |
| @@ -107,6 +108,9 @@ func NewController(cfg DepartureConfig) (*Controller, error) { |
| return c, nil |
| } |
| func (c *Controller) notice(code, format string, args ...any) { |
| + c.telemetry.mu.Lock() |
| + c.telemetry.sample.Error = code |
| + c.telemetry.mu.Unlock() |
| c.mu.Lock() |
| if c.notices == nil { |
| c.notices = map[string]time.Time{} |
| @@ -184,7 +188,16 @@ func departureID(bucket string, b hadeparture.Box) string { |
| func (c *Controller) Enqueue(ctx context.Context, box hadeparture.BoxObservation) error { |
| return c.enqueue(ctx, box, "") |
| } |
| -func (c *Controller) enqueue(ctx context.Context, box hadeparture.BoxObservation, inbox string) error { |
| +func (c *Controller) enqueue(ctx context.Context, box hadeparture.BoxObservation, inbox string) (result error) { |
| + began := time.Now() |
| + defer func() { |
| + code := "enrolled" |
| + if result != nil { |
| + code = "deferred" |
| + } |
| + c.telemetry.confirmation(c, box.Box.Ref, box.Box.InstanceID, departureID(c.cfg.DeploymentBucket, box.Box), code, time.Since(began)) |
| + }() |
| + |
| bound, ok, err := c.cfg.Identities.Resolve(ctx, box.Box.Ref, box.Box.InstanceID) |
| if err != nil { |
| return err |
| @@ -275,6 +288,9 @@ func (c *Controller) work(ctx context.Context) error { |
| case <-ctx.Done(): |
| return ctx.Err() |
| case <-started: |
| + c.telemetry.mu.Lock() |
| + c.telemetry.sample.Error = "" |
| + c.telemetry.mu.Unlock() |
| c.logf("Termination recovery is running.") |
| started = nil |
| case <-timer.C: |
diff --git a/internal/host/hadepartures_metrics.go b/internal/host/hadepartures_metrics.go| new file mode 100644 |
| index 000000000..40e123484 |
| --- /dev/null |
| +++ b/internal/host/hadepartures_metrics.go |
| @@ -0,0 +1,73 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "sync" |
| + "sync/atomic" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/metrics" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +var metricsDepartures atomic.Pointer[Controller] |
| + |
| +type departureTelemetry struct { |
| + mu sync.Mutex |
| + sample metrics.DepartureSample |
| +} |
| + |
| +func (t *departureTelemetry) transfer(c *Controller, h provision.DepartureHost, d registry.HADeparture, result string, latency time.Duration) { |
| + t.mu.Lock() |
| + t.sample.Transfers++ |
| + t.sample.TransferLatencyMS += latency.Milliseconds() |
| + if result == "deferred" { |
| + t.sample.TransferErrors++ |
| + } |
| + t.mu.Unlock() |
| + c.logf("ha_departure_transfer host=%s lifetime=%s dead_ref=%s dead_iid=%s scan_id=%s result=%s latency_ms=%d", h.Host, h.Lifetime, d.Box.Ref, d.Box.InstanceID, d.ID, result, latency.Milliseconds()) |
| +} |
| +func (t *departureTelemetry) confirmation(c *Controller, ref, iid, id, result string, latency time.Duration) { |
| + t.mu.Lock() |
| + t.sample.Confirmations++ |
| + t.sample.ConfirmationLatencyMS += latency.Milliseconds() |
| + if result != "enrolled" { |
| + t.sample.ConfirmationErrors++ |
| + } |
| + t.mu.Unlock() |
| + c.logf("ha_departure_confirmation host= lifetime= dead_ref=%s dead_iid=%s scan_id=%s result=%s latency_ms=%d", ref, iid, id, result, latency.Milliseconds()) |
| +} |
| +func (c *Controller) Metrics(ctx context.Context) (metrics.DepartureSample, error) { |
| + c.telemetry.mu.Lock() |
| + s := c.telemetry.sample |
| + c.telemetry.mu.Unlock() |
| + if c.consumer != nil { |
| + select { |
| + case <-c.consumer.Started(): |
| + s.Started = true |
| + default: |
| + } |
| + s.Running = s.Started && c.consumer.Running() |
| + } |
| + summary, err := c.cfg.Registry.DepartureSummary(ctx) |
| + if err != nil { |
| + s.Error = "journal" |
| + return s, err |
| + } |
| + s.Pending = summary.Count |
| + if !summary.Oldest.IsZero() { |
| + s.OldestPendingSeconds = max(0, c.now().Sub(summary.Oldest).Seconds()) |
| + } |
| + return s, nil |
| +} |
| +func sampleDepartures() *metrics.DepartureSample { |
| + c := metricsDepartures.Load() |
| + if c == nil { |
| + return nil |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| + defer cancel() |
| + s, _ := c.Metrics(ctx) |
| + return &s |
| +} |
diff --git a/internal/host/hadepartures_metrics_test.go b/internal/host/hadepartures_metrics_test.go| new file mode 100644 |
| index 000000000..5ecf41f7b |
| --- /dev/null |
| +++ b/internal/host/hadepartures_metrics_test.go |
| @@ -0,0 +1,63 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/metrics" |
| +) |
| + |
| +func TestHADepartureTelemetry(t *testing.T) { |
| + x := newScanRig(t, 1) |
| + x.c.telemetry.transfer(x.c, x.inv.Records[0], x.d, "adopted", 25*time.Millisecond) |
| + got, err := x.c.Metrics(t.Context()) |
| + if err != nil || got.Transfers != 1 || got.TransferLatencyMS != 25 || got.Pending != 1 || got.OldestPendingSeconds < 3600 { |
| + t.Fatalf("metrics %+v %v", got, err) |
| + } |
| + if got.Started || got.Running { |
| + t.Fatal("unstarted consumer healthy") |
| + } |
| + x.c.cfg.Logf = func(f string, args ...any) { |
| + if strings.Contains(f, "Recovered duties") { |
| + d, _ := x.r.Departure(t.Context(), x.d.ID) |
| + if d.Phase != "complete" { |
| + t.Error("C4 before durable completion") |
| + } |
| + } |
| + } |
| + x.pass(t) |
| + x.pass(t) |
| + got, err = x.c.Metrics(t.Context()) |
| + if err != nil || got.Pending != 0 || got.Completions != 1 { |
| + t.Fatalf("completed %+v %v", got, err) |
| + } |
| + // An existing sample/flush must preserve the additive departure fields. |
| + sm := &sampler{backfilled: true, buf: []metrics.Sample{{At: x.now, HADepartures: &got}}} |
| + if err = metricsFlush(context.Background(), x.store, "self", sm, x.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, _, err := x.store.Get(t.Context(), metrics.RawKey("self", metrics.HourOf(x.now))) |
| + if err != nil || !strings.Contains(string(raw), `"ha_departures"`) { |
| + t.Fatalf("flush: %s %v", raw, err) |
| + } |
| +} |
| +func TestHADeparturePermissionFaultOnce(t *testing.T) { |
| + x := newScanRig(t, 0) |
| + notices := 0 |
| + x.c.cfg.Logf = func(f string, args ...any) { |
| + if strings.Contains(f, "ha_departure_permission_fault") { |
| + notices++ |
| + } |
| + } |
| + for _, code := range []string{"permission_new", "permission", "permission"} { |
| + x.now = x.now.Add(2 * time.Hour) |
| + if err := x.c.retryScan(t.Context(), x.d, nil, code, true); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if notices != 1 { |
| + t.Fatalf("permission fault repeated without a new durable fault generation: %d", notices) |
| + } |
| +} |
diff --git a/internal/host/hadepartures_production_test.go b/internal/host/hadepartures_production_test.go| new file mode 100644 |
| index 000000000..fb85f800f |
| --- /dev/null |
| +++ b/internal/host/hadepartures_production_test.go |
| @@ -0,0 +1,282 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "io" |
| + "net/http" |
| + "path/filepath" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "github.com/aws/aws-sdk-go-v2/aws" |
| + "github.com/aws/aws-sdk-go-v2/credentials" |
| + "github.com/carlosframework/platform/internal/activator" |
| + "github.com/carlosframework/platform/internal/awsterminations" |
| + "github.com/carlosframework/platform/internal/boxid" |
| + "github.com/carlosframework/platform/internal/boxid/boxidtest" |
| + "github.com/carlosframework/platform/internal/hadeparture" |
| + "github.com/carlosframework/platform/internal/hafresh" |
| + "github.com/carlosframework/platform/internal/hostfiles" |
| + "github.com/carlosframework/platform/internal/instancectl" |
| + "github.com/carlosframework/platform/internal/lease" |
| + "github.com/carlosframework/platform/internal/lease/locktest" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +type departureSQSTransport struct { |
| + mu sync.Mutex |
| + queue, body string |
| + attrs, receives, deletes int |
| + ready chan struct{} |
| +} |
| + |
| +func (q *departureSQSTransport) Do(r *http.Request) (*http.Response, error) { |
| + var in map[string]any |
| + if err := json.NewDecoder(r.Body).Decode(&in); err != nil { |
| + return nil, err |
| + } |
| + q.mu.Lock() |
| + defer q.mu.Unlock() |
| + body := "{}" |
| + switch r.Header.Get("X-Amz-Target") { |
| + case "AmazonSQS.GetQueueAttributes": |
| + q.attrs++ |
| + body = fmt.Sprintf(`{"Attributes":{"QueueArn":"arn:aws:sqs:eu-west-1:111122223333:%s"}}`, q.queue) |
| + case "AmazonSQS.ReceiveMessage": |
| + if in["WaitTimeSeconds"] != float64(20) || in["VisibilityTimeout"] != float64(120) || in["MaxNumberOfMessages"] != float64(1) { |
| + return nil, fmt.Errorf("queue_contract") |
| + } |
| + q.receives++ |
| + if q.receives == 1 && q.body != "" { |
| + raw, _ := json.Marshal(map[string]any{"Messages": []map[string]string{{"MessageId": "event", "ReceiptHandle": q.queue, "Body": q.body}}}) |
| + body = string(raw) |
| + } else { |
| + q.mu.Unlock() |
| + <-r.Context().Done() |
| + q.mu.Lock() |
| + return nil, r.Context().Err() |
| + } |
| + case "AmazonSQS.DeleteMessage": |
| + if in["ReceiptHandle"] != q.queue { |
| + return nil, fmt.Errorf("wrong_queue_receipt") |
| + } |
| + q.deletes++ |
| + default: |
| + return nil, fmt.Errorf("unexpected_queue_request") |
| + } |
| + return &http.Response{StatusCode: 200, Header: http.Header{"Content-Type": []string{"application/x-amz-json-1.0"}}, Body: io.NopCloser(strings.NewReader(body))}, nil |
| +} |
| +func (q *departureSQSTransport) counts() (int, int, int) { |
| + q.mu.Lock() |
| + defer q.mu.Unlock() |
| + return q.attrs, q.receives, q.deletes |
| +} |
| +func (q *departureSQSTransport) open(ctx context.Context, self boxid.Cloud) (hadeparture.Queue, error) { |
| + return awsterminations.New(ctx, aws.Config{Region: self.Region, Credentials: credentials.NewStaticCredentialsProvider("test", "test", ""), HTTPClient: q}, "https://sqs.eu-west-1.amazonaws.com/111122223333/"+q.queue, self) |
| +} |
| + |
| +func TestHADepartureProductionWiring(t *testing.T) { |
| + t.Run("startup", func(t *testing.T) { |
| + a, _, _ := departureArmFixture(t) |
| + entered := make(chan struct{}) |
| + a.MakeQueue = func(ctx context.Context) (hadeparture.Queue, error) { |
| + close(entered) |
| + <-ctx.Done() |
| + return nil, ctx.Err() |
| + } |
| + _, life, err := armHADepartures(t.Context(), a) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + <-entered |
| + select { |
| + case <-life.Started(): |
| + t.Error("Started before client initialization or successful receive") |
| + default: |
| + } |
| + if err = life.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + select { |
| + case <-life.Started(): |
| + t.Error("cancelled startup reported success") |
| + default: |
| + } |
| + }) |
| + t.Run("import_and_rescan", testDepartureWiringImport) |
| +} |
| + |
| +func testDepartureWiringImport(t *testing.T) { |
| + t.Cleanup(lease.ProcessStateForTest()) |
| + previous := metricsDepartures.Load() |
| + t.Cleanup(func() { metricsDepartures.Store(previous) }) |
| + fx := locktest.NewLockFixture(t) |
| + a, _, _ := departureArmFixture(t) |
| + a.Self.Scope.DataBucket = fx.Bucket |
| + a.Backend.Cfg.Bucket = fx.Bucket |
| + a.ProofStore = nil |
| + a.Backend.Registry = a.Registry |
| + a.Backend.DataDir = filepath.Join(t.TempDir(), "data") |
| + a.Backend.RunDirOverride = filepath.Join(t.TempDir(), "run") |
| + a.Backend.Control = instancectl.NewClient("/unused/control.sock") |
| + store, err := a.OpenStore(t.Context()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + signer := boxidtest.NewSigner(t) |
| + a.Verifier = boxid.Verifier{Account: a.Self.Account, Certs: signer.Certs()} |
| + for _, b := range []hadeparture.Box{a.Self, {Ref: "dead", InstanceID: "i-1123456789abcdef0"}} { |
| + _, raw := signer.Record(t, b.Ref, a.Self.Account, a.Self.Scope.CloudRegion, b.InstanceID) |
| + key := boxid.Key(b.Ref) |
| + _, tag, e := store.Get(t.Context(), key) |
| + if e != nil { |
| + tag = "" |
| + } |
| + if _, e = store.Put(t.Context(), key, raw, tag); e != nil { |
| + t.Fatal(e) |
| + } |
| + } |
| + rec := provision.Record{Schema: 1, Account: "bab", App: "shop", Host: "shop.example.com", Channel: "stable", HA: true, CreatedAt: time.Now().Add(-time.Hour).UTC()} |
| + raw, _ := json.Marshal(rec) |
| + if _, err = store.Put(t.Context(), provision.RecordKey(rec.Account, rec.App, rec.Host), raw, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + entry, err := provision.LifetimeEntryOf(rec) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + a.Backend.Cfg.Record = func(ctx context.Context, rt registry.Route) (activator.RecordFacts, error) { |
| + r, _, e := provision.FindRecordByHost(ctx, store, rt.Host) |
| + if e != nil { |
| + return activator.RecordFacts{}, e |
| + } |
| + return activator.RecordFactsOf(*r) |
| + } |
| + rt := registry.Route{Host: rec.Host, Kind: "instance", Account: rec.Account, App: rec.App, Channel: rec.Channel, Status: "ready", HA: true, Provisioned: true, Hibernate: true, DBPath: provision.NestedDBPath(a.Backend.DataDir, rec.Host), Socket: filepath.Join(a.Backend.RunDirOverride, "instances", provision.InstanceID(rec.Host), "app.sock")} |
| + if err = a.Registry.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + files, err := lease.NewFilesStore(t.Context(), fx.Bucket, "eu-west-1") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + a.Backend.FilesStore = files |
| + a.Service = activator.New(a.Backend.Cfg, a.Backend, a.Registry) |
| + a.Service.DutyStore = a.Registry |
| + lease.SetSelf(hafresh.Self{Ref: a.Self.Ref, IID: a.Self.InstanceID, Account: a.Self.Account, Region: a.Self.Scope.CloudRegion}) |
| + if err = lease.SetObligationDir(t.TempDir()); err != nil { |
| + t.Fatal(err) |
| + } |
| + pub, err := hostfiles.Open(t.Context(), files, "instances/"+rt.Host+"/files/0/") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + due := time.Now().Add(48 * time.Hour).Unix() |
| + if err = hostfiles.StageWake(t.Context(), pub, hostfiles.WakeState{V: 1, Host: rt.Host, NextDue: due, Timers: []hostfiles.WakeTimer{{Name: "reminder", Kind: "once", Spec: fmt.Sprintf("at %d", due), Path: "/remind", NextAt: due, DueAt: due, Registration: "original"}}}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err = pub.Commit(t.Context()); err != nil { |
| + t.Fatal(err) |
| + } |
| + marker, _ := hafresh.MarkerBody(5, hafresh.Marker{V: 1, Box: "dead", IID: "i-1123456789abcdef0", Lifetime: entry.ID}) |
| + fx.PutLock("instances/"+rt.Host, marker) |
| + q := &departureSQSTransport{queue: "receiver-self", body: string(terminationHint("i-1123456789abcdef0"))} |
| + a.MakeQueue = func(ctx context.Context) (hadeparture.Queue, error) { return q.open(ctx, departureCloud(a.Self)) } |
| + c, life, err := armHADepartures(t.Context(), a) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + select { |
| + case <-life.Started(): |
| + case <-time.After(3 * time.Second): |
| + t.Fatal("real queue adapter failed startup") |
| + } |
| + if err = life.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err = c.cfg.Identities.Observe(t.Context(), hadeparture.BoxObservation{Known: true, Box: a.Self, EdgesKey: "control/edges/self.json", EdgesETag: "self"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + obs, err := c.cfg.Identities.Observe(t.Context(), hadeparture.BoxObservation{Known: true, Box: hadeparture.Box{Ref: "dead", Scope: a.Self.Scope}, EdgesKey: "control/edges/dead.json", EdgesETag: "retired"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = c.Enqueue(t.Context(), obs); err != nil { |
| + t.Fatal(err) |
| + } |
| + now := time.Now().Add(time.Second) |
| + c.cfg.Now = func() time.Time { return now } |
| + pass := a.Inventory.Begin("fresh", now, now, true) |
| + cfg := provision.ReconcileConfig{DataDir: a.Backend.DataDir, Departures: pass, Layout: func(context.Context, release.Store) (string, error) { return release.LayoutModeNested, nil }} |
| + if err = provision.Reconcile(t.Context(), store, a.Registry, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = provision.ReconcileSidecars(t.Context(), store, a.Registry, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + if inv := a.Inventory.Snapshot(); !inv.Complete || len(inv.Records) != 1 { |
| + t.Fatalf("full inventory %+v", inv) |
| + } |
| + // Replaying cached records after confirmation must not count as a fresh source. |
| + stale := a.Inventory.Snapshot() |
| + stale.SourceReadStartedAt = obs.PublishedAt |
| + c.cfg.Inventory = func() provision.InventorySnapshot { return stale } |
| + before := len(fx.Requests()) |
| + _, err = c.ScanPass(t.Context()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(fx.Requests()) != before { |
| + t.Fatal("stale source started a lock scan") |
| + } |
| + c.cfg.Inventory = a.Inventory.Snapshot |
| + now = now.Add(31 * time.Second) |
| + cfg.Departures = a.Inventory.Begin("post-evidence", now, now, true) |
| + if err = provision.Reconcile(t.Context(), store, a.Registry, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = provision.ReconcileSidecars(t.Context(), store, a.Registry, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 0; i < 3; i++ { |
| + if _, err = c.ScanPass(t.Context()); err != nil { |
| + t.Fatal(err) |
| + } |
| + now = now.Add(31 * time.Second) |
| + } |
| + timer, err := a.Registry.GetTimer(rt.Host, "reminder") |
| + if err != nil || timer == nil || timer.Registration != "original" { |
| + t.Fatalf("imported timer %+v %v", timer, err) |
| + } |
| + lock, err := lease.ReadLock(t.Context(), fx.Bucket, "instances/"+rt.Host, "eu-west-1") |
| + if err != nil || lock.Lock.Release == nil || lock.Lock.Release.Box != a.Self.Ref || lock.Lock.Release.Clean { |
| + t.Fatalf("actual finalizer marker %+v %v", lock, err) |
| + } |
| + _, receives, deletes := q.counts() |
| + if receives < 1 || deletes != 1 { |
| + t.Fatalf("queue counts %d %d", receives, deletes) |
| + } |
| + // Execute the assembled runner at current time: +48h work must remain asleep. |
| + sd := newScheduleDeps(a.Registry, store, a.Service, nil, a.Backend.DataDir) |
| + sd.runner.Tick(t.Context()) |
| + timer, err = a.Registry.GetTimer(rt.Host, "reminder") |
| + if err != nil || timer.NextAt != due || a.Service.Owns(rt.Host) { |
| + t.Fatal("future work started early", timer, err) |
| + } |
| + if _, err = a.Registry.MarkTimerFired(rt.Host, "reminder", "original", due, "ok", 0, 0, 0, 0); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = c.record(t.Context(), hadeparture.Message{ID: "duplicate", Receipt: q.queue, Body: terminationHint(obs.Box.InstanceID)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + timer, err = a.Registry.GetTimer(rt.Host, "reminder") |
| + if err != nil || timer.NextAt != 0 { |
| + t.Fatal("redelivery overwrote completed timer", timer, err) |
| + } |
| +} |
diff --git a/internal/host/hadepartures_scan.go b/internal/host/hadepartures_scan.go| index 9cf3c0fdc..afb09c68c 100644 |
| --- a/internal/host/hadepartures_scan.go |
| +++ b/internal/host/hadepartures_scan.go |
| @@ -202,7 +202,7 @@ func (c *Controller) ScanPass(ctx context.Context) (bool, error) { |
| s.Unresolved++ |
| continue |
| } |
| - result, e := c.cfg.Adopt(ctx, h, d, old.Observed) |
| + result, e := c.adoptMeasured(ctx, h, d, old.Observed) |
| if e != nil || result == activator.Deferred { |
| s.Unresolved++ |
| continue |
| @@ -264,7 +264,7 @@ func (c *Controller) ScanPass(ctx context.Context) (bool, error) { |
| s.Unresolved++ |
| continue |
| } |
| - result, e := c.cfg.Adopt(ctx, h, d, v) |
| + result, e := c.adoptMeasured(ctx, h, d, v) |
| if e != nil || result == activator.Deferred { |
| s.Unresolved++ |
| if errors.Is(e, registry.ErrHAWake) { |
| @@ -315,10 +315,13 @@ func (c *Controller) retryScan(ctx context.Context, d registry.HADeparture, host |
| if err != nil { |
| return err |
| } |
| - if code == "permission_new" || claimed && code == "permission" { |
| + if code == "permission_new" { |
| c.logf("ha_departure_permission_fault key=%s", d.EdgesKey) |
| return nil |
| } |
| + if code == "permission" { |
| + return nil |
| + } |
| if code == "ha_departure_edges_retained" { |
| if claimed { |
| c.logf("ha_departure_edges_retained key=%s", d.EdgesKey) |
| @@ -503,6 +506,9 @@ func (c *Controller) complete(ctx context.Context, id string) (result error) { |
| if err = save("complete"); err != nil { |
| return err |
| } |
| + c.telemetry.mu.Lock() |
| + c.telemetry.sample.Completions++ |
| + c.telemetry.mu.Unlock() |
| c.logf("Recovered duties for %d instances from box %s.", len(s.Hosts), d.Box.Ref) |
| return c.ackDeparture(ctx, d) |
| } |
| @@ -523,3 +529,21 @@ func departurePermissionFault(err error) bool { |
| var ae smithy.APIError |
| return errors.As(err, &ae) && ae.ErrorCode() == "AccessDenied" |
| } |
| + |
| +func (c *Controller) adoptMeasured(ctx context.Context, h provision.DepartureHost, d registry.HADeparture, v hafresh.View) (activator.AdoptResult, error) { |
| + began := time.Now() |
| + result, err := c.cfg.Adopt(ctx, h, d, v) |
| + code := "deferred" |
| + if err == nil { |
| + switch result { |
| + case activator.Adopted: |
| + code = "adopted" |
| + case activator.AlreadyAdopted: |
| + code = "already_adopted" |
| + case activator.Superseded: |
| + code = "superseded" |
| + } |
| + } |
| + c.telemetry.transfer(c, h, d, code, time.Since(began)) |
| + return result, err |
| +} |
diff --git a/internal/host/hadepartures_wiring.go b/internal/host/hadepartures_wiring.go| index f7dcc1c15..69d5926b9 100644 |
| --- a/internal/host/hadepartures_wiring.go |
| +++ b/internal/host/hadepartures_wiring.go |
| @@ -136,6 +136,7 @@ func armHADepartures(ctx context.Context, a departureArm) (*Controller, hadepart |
| if err != nil { |
| return fail("controller", err) |
| } |
| + metricsDepartures.Store(c) |
| var queueError error |
| makeQueue := a.MakeQueue |
| if makeQueue == nil { |
diff --git a/internal/host/metrics_loop.go b/internal/host/metrics_loop.go| index 1a22737f5..747ad06de 100644 |
| --- a/internal/host/metrics_loop.go |
| +++ b/internal/host/metrics_loop.go |
| @@ -39,8 +39,9 @@ type sampleProbes struct { |
| // owners is the box's word on whose processes each exec cgroup holds |
| // (metricsOwners), read before and after units so a reading is tagged |
| // only when nothing changed during it. nil tags nothing. |
| - owners func() map[string]metrics.Vouch |
| - now func() time.Time |
| + owners func() map[string]metrics.Vouch |
| + now func() time.Time |
| + departures func() *metrics.DepartureSample |
| } |
| // samplerMaxBuf hard-caps sm.buf at ~2h of 60s ticks. metricsFlush only |
| @@ -136,8 +137,13 @@ func (sm *sampler) tick(p sampleProbes) { |
| // a reading keeps its tag only if that tick vouched the same tenant. |
| sm.prevOwner = metrics.CarryTags(unitSamples, sm.prevOwner) |
| + var departures *metrics.DepartureSample |
| + if p.departures != nil { |
| + departures = p.departures() |
| + } |
| sm.buf = append(sm.buf, metrics.Sample{ |
| - At: now, |
| + HADepartures: departures, |
| + At: now, |
| Host: metrics.HostSample{ |
| CPUFrac: hostCPU, |
| Load1: l1, |
| @@ -676,11 +682,12 @@ type unitSources struct { |
| func realSampleProbes(execRoot string, src unitSources, owners func() map[string]metrics.Vouch) sampleProbes { |
| return sampleProbes{ |
| - procStat: readProcStat, |
| - loadavg: readLoadAvg, |
| - memFrac: readMemFrac, |
| - diskFrac: readDiskFrac, |
| - diskBytes: readDiskBytes, |
| + departures: sampleDepartures, |
| + procStat: readProcStat, |
| + loadavg: readLoadAvg, |
| + memFrac: readMemFrac, |
| + diskFrac: readDiskFrac, |
| + diskBytes: readDiskBytes, |
| units: func() map[string]unitRaw { |
| var stamped, nested []string |
| if src.stamped != nil { |
diff --git a/internal/metrics/sample.go b/internal/metrics/sample.go| index 1dc4b90eb..a2ac8f816 100644 |
| --- a/internal/metrics/sample.go |
| +++ b/internal/metrics/sample.go |
| @@ -36,9 +36,10 @@ type UnitSample struct { |
| // (e.g. carlos-exec@x.example.com — no .service suffix; written by the |
| // sampler's exec-subtree scan since exec-child accounting). |
| type Sample struct { |
| - At time.Time `json:"at"` |
| - Host HostSample `json:"host"` |
| - Units map[string]UnitSample `json:"units"` |
| + HADepartures *DepartureSample `json:"ha_departures,omitempty"` |
| + At time.Time `json:"at"` |
| + Host HostSample `json:"host"` |
| + Units map[string]UnitSample `json:"units"` |
| } |
| // RawChunk is an hour's worth of raw samples for one box, the unit of |
| @@ -50,3 +51,18 @@ type RawChunk struct { |
| Hour string `json:"hour"` // UTC, 2006-01-02-15 |
| Samples []Sample `json:"samples"` |
| } |
| + |
| +type DepartureSample struct { |
| + Transfers uint64 `json:"transfers"` |
| + TransferErrors uint64 `json:"transfer_errors"` |
| + TransferLatencyMS int64 `json:"transfer_latency_ms"` |
| + Confirmations uint64 `json:"confirmations"` |
| + ConfirmationErrors uint64 `json:"confirmation_errors"` |
| + ConfirmationLatencyMS int64 `json:"confirmation_latency_ms"` |
| + Completions uint64 `json:"completions"` |
| + Pending int `json:"pending"` |
| + OldestPendingSeconds float64 `json:"oldest_pending_seconds"` |
| + Started bool `json:"started"` |
| + Running bool `json:"running"` |
| + Error string `json:"error,omitempty"` |
| +} |
diff --git a/internal/registry/ha_journal.go b/internal/registry/ha_journal.go| index 9ba52c310..be3944584 100644 |
| --- a/internal/registry/ha_journal.go |
| +++ b/internal/registry/ha_journal.go |
| @@ -58,6 +58,7 @@ type haJournalRequest struct { |
| Scan HADepartureScan |
| } |
| type haJournalResponse struct { |
| + Summary HADepartureSummary |
| Count int |
| Scan HADepartureScan |
| Inbox []HATerminationInbox |
| @@ -138,6 +139,16 @@ func (r *Registry) EnrollDeparture(ctx context.Context, d HADeparture, inbox str |
| _, err := r.haJournal(ctx, haJournalRequest{Op: "enroll", Departure: d, Key: inbox}) |
| return err |
| } |
| + |
| +type HADepartureSummary struct { |
| + Count int |
| + Oldest time.Time |
| +} |
| + |
| +func (r *Registry) DepartureSummary(ctx context.Context) (HADepartureSummary, error) { |
| + out, err := r.haJournal(ctx, haJournalRequest{Op: "summary"}) |
| + return out.Summary, err |
| +} |
| func (r *Registry) PendingDepartures(ctx context.Context, at time.Time, limit int) ([]HADeparture, error) { |
| out, err := r.haJournal(ctx, haJournalRequest{Op: "pending", At: at, Limit: limit}) |
| return out.Departures, err |
| @@ -177,6 +188,28 @@ func (r *Registry) haJournal(ctx context.Context, q haJournalRequest) (out haJou |
| return resp.HAJournal, e |
| } |
| switch q.Op { |
| + case "summary": |
| + rows, e := r.sql.QueryContext(ctx, `SELECT body FROM ha_departures WHERE phase<>'complete'`) |
| + if e != nil { |
| + return out, e |
| + } |
| + defer rows.Close() |
| + for rows.Next() { |
| + var raw []byte |
| + if e = rows.Scan(&raw); e != nil { |
| + return out, e |
| + } |
| + var d HADeparture |
| + if e = json.Unmarshal(raw, &d); e != nil { |
| + return out, e |
| + } |
| + out.Summary.Count++ |
| + if out.Summary.Oldest.IsZero() || d.ObservedAt.Before(out.Summary.Oldest) { |
| + out.Summary.Oldest = d.ObservedAt |
| + } |
| + } |
| + err = rows.Err() |
| + |
| case "identity_page": |
| if q.At.IsZero() { |
| return out, ErrHAJournal |
diff --git a/internal/sim/regionha/duty_boundaries_test.go b/internal/sim/regionha/duty_boundaries_test.go| new file mode 100644 |
| index 000000000..65504701c |
| --- /dev/null |
| +++ b/internal/sim/regionha/duty_boundaries_test.go |
| @@ -0,0 +1,221 @@ |
| +package regionha |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "io" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/aws/aws-sdk-go-v2/aws" |
| + "github.com/aws/aws-sdk-go-v2/service/s3" |
| + "github.com/aws/smithy-go" |
| + "github.com/carlosframework/platform/internal/boxid" |
| + "github.com/carlosframework/platform/internal/boxid/boxidtest" |
| + "github.com/carlosframework/platform/internal/hadeparture" |
| + "github.com/carlosframework/platform/internal/hafresh" |
| + hostpkg "github.com/carlosframework/platform/internal/host" |
| + "github.com/carlosframework/platform/internal/termfence" |
| +) |
| + |
| +type dutyProofStore struct { |
| + raw []byte |
| + reads int |
| +} |
| + |
| +func (s *dutyProofStore) GetObject(context.Context, *s3.GetObjectInput, ...func(*s3.Options)) (*s3.GetObjectOutput, error) { |
| + s.reads++ |
| + if s.raw == nil { |
| + return nil, &smithy.GenericAPIError{Code: "NoSuchKey"} |
| + } |
| + return &s3.GetObjectOutput{Body: io.NopCloser(strings.NewReader(string(s.raw))), ContentLength: aws.Int64(int64(len(s.raw)))}, nil |
| +} |
| +func (s *dutyProofStore) PutObject(context.Context, *s3.PutObjectInput, ...func(*s3.Options)) (*s3.PutObjectOutput, error) { |
| + return nil, &smithy.GenericAPIError{Code: "AccessDenied"} |
| +} |
| +func dutyProofCacheWitness(t *testing.T, w *world, rule string) { |
| + signer := boxidtest.NewSigner(t) |
| + _, raw := signer.Record(t, "departed", "111122223333", "eu-west-1", "i-1123456789abcdef0") |
| + binding, err := termfence.VerifyProofIdentity(boxid.Verifier{Account: "111122223333", Certs: signer.Certs()}, raw, boxid.Expect{Box: "departed", AWSRegion: "eu-west-1", TofuInstanceID: "i-1123456789abcdef0"}, "data") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + at := epoch |
| + cache := &termfence.ProofCache{Now: func() time.Time { return at }} |
| + store := &dutyProofStore{} |
| + if rule != "proof-absence-not-cached" { |
| + e := binding.Evidence() |
| + store.raw, _ = json.Marshal(termfence.TerminationProof{V: 1, Account: e.Cloud.Account, Region: e.Cloud.Region, IID: e.Cloud.InstanceID, BoxRef: e.Box, BoxLifetime: e.RecordSHA256, IdentitySHA256: e.RecordSHA256, State: "terminated", Source: "ec2-describe", ConfirmedAt: at, ConfirmingRef: "survivor", ConfirmingIID: "i-0123456789abcdef0"}) |
| + } |
| + for host := 0; host < 20; host++ { |
| + use := cache |
| + if !on(rule) { |
| + use = &termfence.ProofCache{Now: func() time.Time { return at }} |
| + } |
| + _, found, e := use.Load(t.Context(), store, binding) |
| + if e != nil || found != (store.raw != nil) { |
| + t.Fatal("production proof validator", found, e) |
| + } |
| + if rule == "proof-positive-not-cached" { |
| + at = at.Add(48 * time.Hour) |
| + } |
| + } |
| + if store.reads != 1 { |
| + w.fail("I6", "%s: %d proof GETs across 20 host lookups", rule, store.reads) |
| + } |
| +} |
| + |
| +type dutyEmptyQueue struct{ called chan struct{} } |
| + |
| +func (q *dutyEmptyQueue) Receive(ctx context.Context, _ time.Duration) ([]hadeparture.Message, error) { |
| + select { |
| + case q.called <- struct{}{}: |
| + default: |
| + } |
| + return nil, nil |
| +} |
| +func (q *dutyEmptyQueue) Delete(context.Context, string) error { return nil } |
| +func dutyStartupWitness(t *testing.T, w *world) { |
| + entered := make(chan struct{}) |
| + c := hadeparture.NewConsumer(func(context.Context) error { return nil }, func(context.Context, hadeparture.Message) error { return nil }, nil) |
| + life, err := c.Start(t.Context(), func(ctx context.Context) (hadeparture.Queue, error) { |
| + close(entered) |
| + <-ctx.Done() |
| + return nil, ctx.Err() |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + <-entered |
| + select { |
| + case <-life.Started(): |
| + w.fail("I6", "consumer Started before client and receive") |
| + default: |
| + } |
| + if err = life.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| +func dutyInventoryStartupWitness(t *testing.T, w *world) { |
| + queue := &dutyEmptyQueue{called: make(chan struct{}, 1)} |
| + entered := make(chan struct{}) |
| + c := hadeparture.NewConsumer(func(ctx context.Context) error { |
| + close(entered) |
| + if !on("started-waits-for-inventory") { |
| + <-ctx.Done() |
| + return ctx.Err() |
| + } |
| + return nil |
| + }, func(context.Context, hadeparture.Message) error { return nil }, nil) |
| + life, err := c.Start(t.Context(), func(context.Context) (hadeparture.Queue, error) { return queue, nil }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + <-entered |
| + if on("started-waits-for-inventory") { |
| + select { |
| + case <-life.Started(): |
| + case <-time.After(time.Second): |
| + t.Fatal("empty queue did not start") |
| + } |
| + } else { |
| + select { |
| + case <-life.Started(): |
| + default: |
| + w.fail("I6", "incomplete tenant inventory delayed consumer startup") |
| + } |
| + } |
| + if err = life.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| +func dutyRescanWitness(w *world) { |
| + d := newDutyWorld(w, 7) |
| + d.terminate(0) |
| + b := d.boxes[1] |
| + b.source = 3 |
| + b.walk = 3 |
| + s := &dutyScan{dead: 0, evidence: 1, rescan: true, seen: map[int]int64{}, phases: map[int]string{}} |
| + for i := range d.hosts { |
| + d.marker(i, 0, false) |
| + } |
| + d.now = 4 |
| + d.scan(b, s) |
| + if s.ack || s.complete { |
| + d.fail("dead releaser acknowledged") |
| + } |
| +} |
| +func dutySuccessorWitness(w *world) { |
| + d := newDutyWorld(w, 7) |
| + d.terminate(0) |
| + b := d.boxes[1] |
| + b.source = 3 |
| + b.walk = 3 |
| + s := &dutyScan{dead: 0, evidence: 1, rescan: true, seen: map[int]int64{0: 8}, phases: map[int]string{}} |
| + d.hosts[0].lock.Lock.Generation = 7 |
| + d.marker(0, 1, false) |
| + for i := 1; i < len(d.hosts); i++ { |
| + d.marker(i, 1, false) |
| + } |
| + if !on("superseded-without-bound-successor") { |
| + delete(s.seen, 0) |
| + } |
| + d.now = 4 |
| + d.scan(b, s) |
| + if s.complete { |
| + d.fail("older successor generation completed departure") |
| + } |
| +} |
| +func dutyManifestWitness(w *world) { |
| + d := newDutyWorld(w, 7) |
| + h := d.hosts[0] |
| + staged := h.wake["once"] |
| + current := dutyTimer{Registration: 2, Due: 90} |
| + h.wake["once"] = current |
| + h.sequence++ |
| + imported := h.wake["once"] |
| + if !on("reuse-staged-rows-without-manifest-digest") { |
| + imported = staged |
| + } |
| + if imported.Registration != h.wake["once"].Registration { |
| + d.fail("under-lease manifest changed but staged registration was reused") |
| + } |
| +} |
| +func dutyNullWitness(w *world) { |
| + d := newDutyWorld(w, 7) |
| + null := true |
| + known := !null |
| + if !on("null-is-home") { |
| + known = true |
| + } |
| + admitted := known && hostpkg.CanAdopt(d.hosts[0].record, hostpkg.LocalPolicy{Scope: hadeparture.Scope{Placement: ""}}) |
| + if admitted { |
| + d.fail("explicit-null identity became known home scope") |
| + } |
| +} |
| +func TestI6PersistentFailureIsPending(t *testing.T) { |
| + w := newWitness() |
| + d := newDutyWorld(w, 7) |
| + d.terminate(0) |
| + d.storeDown = true |
| + d.advance(500) |
| + if d.deliveries != 0 || d.deletes != 0 || d.indexes != 0 { |
| + t.Fatal("persistent store failure reported progress") |
| + } |
| + for _, b := range d.boxes { |
| + for _, s := range b.scans { |
| + if s.ack || s.complete { |
| + t.Fatal("failure completed departure") |
| + } |
| + } |
| + } |
| + // With no initial proof and EC2 now forgotten, recovery is an explicit |
| + // operator fault. The eventual-success oracle's fairness premise is false. |
| + d.storeDown = false |
| + d.advance(100) |
| + if d.proofs[0] { |
| + t.Fatal("guessed termination after EC2 forgot") |
| + } |
| + _ = hafresh.ActRefuse |
| +} |
diff --git a/internal/sim/regionha/mutate-startup.sh b/internal/sim/regionha/mutate-startup.sh| new file mode 100755 |
| index 000000000..674582724 |
| --- /dev/null |
| +++ b/internal/sim/regionha/mutate-startup.sh |
| @@ -0,0 +1,28 @@ |
| +#!/bin/bash |
| +set -eu |
| +scratch=${1:?owned scratch directory required} |
| +root=$(git rev-parse --show-toplevel) |
| +work=$(mktemp -d -p "$scratch" startup.XXXXXX) |
| +trap 'rm -rf -- "$work"' EXIT |
| +python3 - "$root" "$work" <<'PY' |
| +import json,pathlib,sys |
| +root,work=map(pathlib.Path,sys.argv[1:]) |
| +source=root/'internal/hadeparture/consumer.go' |
| +s=source.read_text() |
| +assert s.count('close(c.started)')==1 |
| +s=s.replace('close(c.started)','// startup mutation moved the acknowledgment') |
| +assert s.count('c.invoked = true')==1 |
| +s=s.replace('c.invoked = true','c.invoked = true\n close(c.started)') |
| +changed=work/'consumer.go';changed.write_text(s) |
| +(work/'overlay.json').write_text(json.dumps({'Replace':{str(source):str(changed)}})) |
| +PY |
| +# This compiles and executes the actual arm helper and consumer with the bad |
| +# acknowledgment ordering. A compile error or unrelated failure is not a catch. |
| +set +e |
| +TMPDIR=/home/paulca/t RHASIM_MUTATE= go test -overlay "$work/overlay.json" ./internal/host -run '^TestHADepartureProductionWiring/startup$' -count=1 -v > "$work/result" 2>&1 |
| +rc=$? |
| +set -e |
| +cat "$work/result" |
| +if [ "$rc" -ne 1 ] || ! grep -q 'Started before client initialization or successful receive' "$work/result"; then |
| + exit 2 |
| +fi |
diff --git a/internal/sim/regionha/mutate.sh b/internal/sim/regionha/mutate.sh| index e7001fd3e..8a172f858 100755 |
| --- a/internal/sim/regionha/mutate.sh |
| +++ b/internal/sim/regionha/mutate.sh |
| @@ -95,6 +95,16 @@ one() { |
| done |
| RHASIM_MUTATE=$r RHASIM_SEEDS=$SEEDS "$BIN" -test.run '^TestRegionHA$' -test.count=1 -test.v -test.timeout 180m >"$log" 2>&1 |
| rc=$? |
| + if [ "$r" = "start-before-client" ]; then |
| + "$PKG/mutate-startup.sh" "$SCRATCH" > "$SCRATCH/logs/startup-executable.log" 2>&1 |
| + startup_rc=$? |
| + if [ "$startup_rc" -eq 0 ]; then |
| + echo "CAUGHT $r: executable TestHADepartureProductionWiring/startup; witness violated" | tee "$verdict" |
| + else |
| + echo "ERROR $r: executable mutation rc=$startup_rc" | tee "$verdict" |
| + fi |
| + return |
| + fi |
| expect=$(awk -v r="$r" '$1==r {print $2}' "$EXPECT" 2>/dev/null) |
| depth=$(awk -v r="$r" '$1==r {print $3}' "$EXPECT" 2>/dev/null) |
| nviol=$(grep -o "[0-9]* of $SEEDS seeds violated an invariant" "$log" | head -1 | awk '{print $1}') |
| @@ -150,7 +160,7 @@ one() { |
| fi |
| } |
| export -f one |
| -export SEEDS BIN SCRATCH WRULES EXPECT ALL |
| +export SEEDS BIN SCRATCH WRULES EXPECT ALL PKG |
| printf '%s\n' $RULES | xargs -P "${RHASIM_PAR:-1}" -I{} bash -c 'one "$@"' _ {} |
| xrc=$? |
| if [ $xrc -ne 0 ]; then |
diff --git a/internal/sim/regionha/rules_test.go b/internal/sim/regionha/rules_test.go| index 5928ad74b..733d4bab1 100644 |
| --- a/internal/sim/regionha/rules_test.go |
| +++ b/internal/sim/regionha/rules_test.go |
| @@ -39,6 +39,15 @@ func on(rule string) bool { |
| // model hands them or does with their answer, the way a regression in a |
| // caller would. |
| var allRules = []string{ |
| + "start-before-client", |
| + "started-waits-for-inventory", |
| + "ack-with-dead-releaser", |
| + "superseded-without-bound-successor", |
| + "reuse-staged-rows-without-manifest-digest", |
| + "null-is-home", |
| + "proof-cache-per-host", |
| + "proof-absence-not-cached", |
| + "proof-positive-not-cached", |
| "ignore-termination-event", |
| "skip-departure-scan", |
| "scan-owners-not-releasers", |
diff --git a/internal/sim/regionha/witness_test.go b/internal/sim/regionha/witness_test.go| index 5125b0aed..345a7362a 100644 |
| --- a/internal/sim/regionha/witness_test.go |
| +++ b/internal/sim/regionha/witness_test.go |
| @@ -40,6 +40,15 @@ type witness struct { |
| } |
| var witnesses = []witness{ |
| + {"start-before-client", "start-before-client", "I6", "production boundary", func(t *testing.T, w *world) { dutyStartupWitness(t, w) }}, |
| + {"started-waits-for-inventory", "started-waits-for-inventory", "I6", "production boundary", func(t *testing.T, w *world) { dutyInventoryStartupWitness(t, w) }}, |
| + {"ack-with-dead-releaser", "ack-with-dead-releaser", "I6", "production boundary", func(t *testing.T, w *world) { dutyRescanWitness(w) }}, |
| + {"superseded-without-bound-successor", "superseded-without-bound-successor", "I6", "production boundary", func(t *testing.T, w *world) { dutySuccessorWitness(w) }}, |
| + {"reuse-staged-rows-without-manifest-digest", "reuse-staged-rows-without-manifest-digest", "I6", "production boundary", func(t *testing.T, w *world) { dutyManifestWitness(w) }}, |
| + {"null-is-home", "null-is-home", "I6", "production boundary", func(t *testing.T, w *world) { dutyNullWitness(w) }}, |
| + {"proof-cache-per-host", "proof-cache-per-host", "I6", "production boundary", func(t *testing.T, w *world) { dutyProofCacheWitness(t, w, "proof-cache-per-host") }}, |
| + {"proof-absence-not-cached", "proof-absence-not-cached", "I6", "production boundary", func(t *testing.T, w *world) { dutyProofCacheWitness(t, w, "proof-absence-not-cached") }}, |
| + {"proof-positive-not-cached", "proof-positive-not-cached", "I6", "production boundary", func(t *testing.T, w *world) { dutyProofCacheWitness(t, w, "proof-positive-not-cached") }}, |
| {"ignore-termination-event", "ignore-termination-event", "I6", "event enrollment", func(t *testing.T, w *world) { runDutyScenario(w, "event", 7) }}, |
| {"skip-departure-scan", "skip-departure-scan", "I6", "held", func(t *testing.T, w *world) { runDutyScenario(w, "held", 7) }}, |
| {"scan-owners-not-releasers", "scan-owners-not-releasers", "I6", "released", func(t *testing.T, w *world) { runDutyScenario(w, "released", 7) }}, |
| @@ -137,7 +146,9 @@ func TestWitnesses(t *testing.T) { |
| for _, s := range properSubsets(x.needs) { |
| check(t, x, s, false, only != "") |
| } |
| - check(t, x, x.needs, true, only != "") |
| + if x.rule != "start-before-client" { |
| + check(t, x, x.needs, true, only != "") |
| + } |
| } |
| if only != "" && ran == 0 { |
| t.Fatalf("no witness for rule %q", only) |
| @@ -156,6 +167,9 @@ func TestWitnesses(t *testing.T) { |
| for _, m := range strings.Split(x.needs, ",") { |
| needs = needs && set[m] |
| } |
| + if x.rule == "start-before-client" && os.Getenv("RHASIM_EXECUTABLE_MUTATION") == "" { |
| + continue |
| + } |
| if needs { |
| check(t, x, mutated, true, only != "") |
| continue |