carlos / platform Public

stateless: release waits for config; retry at copies 1 (#511)

Drill 1, F1 and ruling R20.

A first wake's release read its environment before config sync had
written the instance's config file: nothing made the instance directory
before the release's own env read (ReleaseEnv makes it, then reads), and
config sync skips a row whose directory is not made yet. The release ran
with no app env and failed.

prepareStatelessRelease now asks the backend's releaseConfigWait before
the term and the begin, after durable adoption. A present config file
goes on with no read. Otherwise the instance directory is made (so the
next config tick writes the file) and ConfiguredEnv asks the bucket
whether the configuration renders any environment: if it does, or it
cannot be read, the release waits (releaseConfigWait, ErrFenced to the
classifiers: no attempt, no failure); an always-on copy asks again after
releaseConfigPace. A configuration that renders nothing waits for
nothing. ConfiguredEnv is wired beside ConfiguredKey (configuredRead).

`instances retry` refused a failed stateless release at copies 1 ("not
held back by a failed build"): with no copy assignment the door asked
only the box failure book, which such a failure never enters. The door
now arms the durable RetryOf for any retryable stateless attempt, as for
copies above 1; the box's next begin consumes it.

Witnesses: TestReleaseWaitsForConfigFile (production ExecBackend),
TestFirstWakeReleaseWaitsForConfig, TestReplicaInstanceRetryCopiesOne
(HTTP door), TestReplicaCopiesOneRetryConsumed (real writer).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 340b419868c1cc817a769c177818a4345d089b82 parent 3fdfa55
11 files changed, +338 −10
  • internal/activator/backend_exec.go +7 −0
  • internal/activator/backend_rootfs.go +61 −0
  • internal/activator/backend_unit.go +7 −0
  • internal/activator/replica_drill1_test.go +96 −0
  • internal/activator/rootfs_service.go +3 −0
  • internal/activator/statelessrelease.go +8 −0
  • internal/appconfig/instancekey.go +18 −0
  • internal/console/apiretry.go +8 −4
  • internal/console/replica_drill1_test.go +63 −0
  • internal/host/replicahomekeys.go +26 −6
  • internal/provision/replica_drill1_test.go +41 −0
diff --git a/internal/activator/backend_exec.go b/internal/activator/backend_exec.go
index 0b187ca31..2b52023e0 100644
--- a/internal/activator/backend_exec.go
+++ b/internal/activator/backend_exec.go
@@ -164,6 +164,13 @@ type ExecBackend struct {
// configuration change is in flight (ruling 27); there nil refuses
// every configured key.
ConfiguredKey func(ctx context.Context, rt registry.Route) (sha256 string, err error)
+ // ConfiguredEnv reads rt's configuration from the bucket now and
+ // reports whether it renders any environment (appconfig.ConfiguredEnv).
+ // A stateless release asks it only while rt's config file is absent
+ // here, and waits while the configuration renders one
+ // (releaseConfigWait; #511 drill 1, R20). Nil is a box with no
+ // configuration source: nothing is waited for.
+ ConfiguredEnv func(ctx context.Context, rt registry.Route) (bool, error)
// Cache, when non-nil, adds the purge verb to each spawned instance's
// control socket so it can invalidate its own cached responses right
// after a write. Nil disables that ONE verb, not the socket: the control
diff --git a/internal/activator/backend_rootfs.go b/internal/activator/backend_rootfs.go
index cb360a548..3c0a700ed 100644
--- a/internal/activator/backend_rootfs.go
+++ b/internal/activator/backend_rootfs.go
@@ -12,6 +12,7 @@ import (
"path/filepath"
"strings"
"sync"
+ "time"
"github.com/carlosframework/platform/internal/applog"
"github.com/carlosframework/platform/internal/instancectl"
@@ -170,6 +171,66 @@ func (b *ExecBackend) ReleaseEnv(ctx context.Context, rt registry.Route) (map[st
return b.rootfsReleaseVars(rt, env, p.dbPath), nil
}
+// releaseConfigGate is the optional backend half of R20 (#511 drill 1):
+// whether a stateless release of rt must wait for its config file.
+type releaseConfigGate interface {
+ releaseConfigWait(ctx context.Context, rt registry.Route) error
+}
+
+// errReleaseConfigWait is a stateless release that waits for its
+// instance's config file (#511 drill 1, R20): the configuration renders an
+// environment and this box has not written it yet, so a release now would
+// run without it. Nothing ran and no attempt began. It is a refusal
+// (ErrFenced to every classifier), never the build's failure; an always-on
+// copy asks again after releaseConfigPace (residentOwnerWait).
+type releaseConfigWait struct{ err error }
+
+// copy SR-4-C84
+func (e *releaseConfigWait) Error() string {
+ text := "the release waits until this instance's configuration is written on this box. nothing ran yet"
+ if e.err != nil {
+ text += ": " + e.err.Error()
+ }
+ return text
+}
+func (e *releaseConfigWait) Unwrap() error { return e.err }
+func (e *releaseConfigWait) Is(target error) bool { return target == ErrFenced }
+
+// releaseConfigPace is how long an always-on copy waits before it asks
+// again: a few config sync ticks, so the wait costs few bucket reads.
+const releaseConfigPace = 5 * time.Second
+
+// releaseConfigWait implements releaseConfigGate. A rootfs row whose
+// config file is present goes on with no read. Otherwise the instance
+// directory is made, as the release's own environment read makes it, so
+// config sync's next tick writes the file (it skips a row whose directory
+// is not made yet), and the bucket is asked whether the configuration
+// renders anything: if it does, the release waits; if it renders nothing,
+// there is no file to wait for. A configuration that cannot be read waits.
+func (b *ExecBackend) releaseConfigWait(ctx context.Context, rt registry.Route) error {
+ if !rt.Rootfs() || b.ConfiguredEnv == nil {
+ return nil
+ }
+ p := b.pathsFor(rt)
+ if p.layout != LayoutNested {
+ return nil // ReleaseEnv refuses it with its own reason
+ }
+ if fi, err := os.Lstat(p.configEnv); err == nil && fi.Mode().IsRegular() {
+ return nil
+ }
+ if err := os.MkdirAll(p.dataDir, 0o700); err != nil {
+ return err
+ }
+ expected, err := b.ConfiguredEnv(ctx, rt)
+ switch {
+ case err != nil:
+ return &releaseConfigWait{err: err}
+ case expected:
+ return &releaseConfigWait{}
+ }
+ return nil
+}
+
// StartRelease implements ReleaseBackend: startRootfsCmd naming id's
// release process in the cmd unit, both streams written into out through
// one capped line writer (releaseOutput) [pf R1.5].
diff --git a/internal/activator/backend_unit.go b/internal/activator/backend_unit.go
index 7f2151505..7da200c49 100644
--- a/internal/activator/backend_unit.go
+++ b/internal/activator/backend_unit.go
@@ -384,6 +384,13 @@ func (b *SplitBackend) Processes(rt registry.Route, id release.StagedIdentity) (
// ReleaseEnv forwards a release's environment (Group R) to the exec side.
// A unit-backed row, or an exec side without the release, is refused as
// Processes refuses it.
+func (b *SplitBackend) releaseConfigWait(ctx context.Context, rt registry.Route) error {
+ if g, ok := b.pick(rt).(releaseConfigGate); ok {
+ return g.releaseConfigWait(ctx, rt)
+ }
+ return nil
+}
+
func (b *SplitBackend) ReleaseEnv(ctx context.Context, rt registry.Route) (map[string]string, error) {
if rt.Backing != registry.BackingUnit {
if r, ok := b.Exec.(ReleaseBackend); ok {
diff --git a/internal/activator/replica_drill1_test.go b/internal/activator/replica_drill1_test.go
index 8791e45e9..77638f7d8 100644
--- a/internal/activator/replica_drill1_test.go
+++ b/internal/activator/replica_drill1_test.go
@@ -4,7 +4,9 @@ import (
"context"
"errors"
"fmt"
+ "os"
"slices"
+ "sync/atomic"
"testing"
"time"
@@ -139,3 +141,97 @@ func TestReplicaJoinWithoutSecretsHalts(t *testing.T) {
t.Fatalf("the join did not halt with b off the target: %v %+v", err, next.Swap)
}
}
+
+// TestReleaseWaitsForConfigFile (#511 drill 1, R20): on the production
+// backend, a stateless release whose configuration renders an
+// environment waits while this box has not written the instance's config
+// file; the wait makes the instance directory, so config sync's next tick
+// can write it (it skipped the row: "instance directory not made yet").
+// Once the file is there the release goes on with no read, and the
+// environment it launches with carries the configuration. A
+// configuration that renders nothing waits for nothing; one that cannot
+// be read waits.
+func TestReleaseWaitsForConfigFile(t *testing.T) {
+ eb, _ := nestedBackend(t, &fakeControl{}, &fakeUnit{})
+ rt := rootfsRoute(eb)
+ p := eb.pathsFor(rt)
+ reads, renders, readErr := 0, true, error(nil)
+ eb.ConfiguredEnv = func(context.Context, registry.Route) (bool, error) { reads++; return renders, readErr }
+ var wait *releaseConfigWait
+ if err := eb.releaseConfigWait(t.Context(), rt); !errors.As(err, &wait) || !errors.Is(err, ErrFenced) || reads != 1 {
+ t.Fatalf("a release before its config file: %v (reads %d)", err, reads)
+ }
+ if fi, err := os.Stat(p.dataDir); err != nil || !fi.IsDir() {
+ t.Fatalf("the wait did not make the instance directory: %v", err)
+ }
+ readErr = errors.New("bucket unreachable")
+ if err := eb.releaseConfigWait(t.Context(), rt); !errors.As(err, &wait) {
+ t.Fatalf("an unreadable configuration did not wait: %v", err)
+ }
+ readErr, renders = nil, false
+ if err := eb.releaseConfigWait(t.Context(), rt); err != nil {
+ t.Fatalf("a configuration that renders nothing waited: %v", err)
+ }
+ renders = true
+ if err := os.WriteFile(p.configEnv, []byte("DRILL_KEY=from-config\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ before := reads
+ if err := eb.releaseConfigWait(t.Context(), rt); err != nil || reads != before {
+ t.Fatalf("the written config file did not end the wait with no read: %v (reads %d)", err, reads-before)
+ }
+ env, err := eb.ReleaseEnv(t.Context(), rt)
+ if err != nil || env["DRILL_KEY"] != "from-config" {
+ t.Fatalf("the release environment lacks the configuration: %v %q", err, env["DRILL_KEY"])
+ }
+}
+
+// configWaitBackend is the rig's backend with R20's wait: the config file
+// is written once written is set.
+type configWaitBackend struct {
+ *wakeRelBackend
+ written atomic.Bool
+}
+
+func (b *configWaitBackend) releaseConfigWait(context.Context, registry.Route) error {
+ if b.written.Load() {
+ return nil
+ }
+ return &releaseConfigWait{}
+}
+
+// TestFirstWakeReleaseWaitsForConfig (#511 drill 1, F1/R20): a first wake
+// of an always-on stateless instance whose configuration was set before
+// it existed. Its release waits, a deferral: no attempt begins, nothing
+// runs, no failure is counted, and the tick asks again after
+// releaseConfigPace, not every poll. Once the config is written the
+// release runs once and passes, and the copy serves. In the drill it ran
+// at once without the config and failed.
+func TestFirstWakeReleaseWaitsForConfig(t *testing.T) {
+ r := newWakeRelRig(t)
+ store := wireStatelessRig(r)
+ cw := &configWaitBackend{wakeRelBackend: r.b}
+ r.a.backend = cw
+ r.rt.Hibernate, r.rt.Stateless = false, true
+ r.routes.set(r.rt)
+ r.setPlan(WakePlan{Boot: r.next, Mode: ModeOverlap, Token: 1})
+ r.a.residentLister, r.a.residentJitter = residentRows{rows: r.routes}, func() float64 { return 0 }
+ tickSettled(t, r.a)
+ if r.a.hasEntry(r.rt.Host) || store.snapshot() != nil || len(r.b.releaseStarts()) != 0 {
+ t.Fatalf("the release did not wait for the config: entry %t, record %+v, releases %d", r.a.hasEntry(r.rt.Host), store.snapshot(), len(r.b.releaseStarts()))
+ }
+ r.a.mu.Lock()
+ st := *r.a.residents[r.rt.Host]
+ r.a.mu.Unlock()
+ if st.failures != 0 || st.waitUntil.Sub(r.clk.now()) != releaseConfigPace {
+ t.Fatalf("the wait was not a paced deferral: %+v", st)
+ }
+ cw.written.Store(true)
+ r.clk.advance(releaseConfigPace)
+ r.a.rootfsTick()
+ r.nextUnit(t).done("exited", "0", "success")
+ waitFor(t, "the copy serving after its release", func() bool { _, ok := r.a.Current(r.rt.Host); return ok })
+ if d := store.snapshot(); d == nil || d.Phase != "released" || len(r.b.releaseStarts()) != 1 {
+ t.Fatalf("the release did not run once and pass: %+v, releases %d", d, len(r.b.releaseStarts()))
+ }
+}
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go
index 96d5191c6..d319eb273 100644
--- a/internal/activator/rootfs_service.go
+++ b/internal/activator/rootfs_service.go
@@ -521,7 +521,10 @@ func markOwnershipRefusal(rt registry.Route, err error) error {
func residentOwnerWait(err error) time.Duration {
var held *errLeaseHeld
var refused *errConfigRefused
+ var config *releaseConfigWait
switch {
+ case errors.As(err, &config):
+ return releaseConfigPace
case errors.As(err, &held):
return held.retryAfter
case errors.As(err, &refused):
diff --git a/internal/activator/statelessrelease.go b/internal/activator/statelessrelease.go
index e756e6f4c..0bc9da0c9 100644
--- a/internal/activator/statelessrelease.go
+++ b/internal/activator/statelessrelease.go
@@ -180,6 +180,14 @@ func (a *Service) prepareStatelessRelease(ctx context.Context, rt registry.Route
if a.releaseOpen(rt.Host) {
return "", ErrReplicaReleaseUnknown
}
+ // R20 (#511 drill 1): a release never runs before its instance's
+ // config is written here. It waits, before any term or attempt, so no
+ // attempt is consumed and nothing is recorded as failed.
+ if g, ok := a.backend.(releaseConfigGate); ok && rt.Rootfs() {
+ if err := g.releaseConfigWait(ctx, rt); err != nil {
+ return "", err
+ }
+ }
if a.Coordinator == nil {
return "", replicas.ErrFenced
}
diff --git a/internal/appconfig/instancekey.go b/internal/appconfig/instancekey.go
index c60051498..f42c45496 100644
--- a/internal/appconfig/instancekey.go
+++ b/internal/appconfig/instancekey.go
@@ -32,3 +32,21 @@ func ConfiguredKeyDigest(ctx context.Context, s release.Store, priv *ecdh.Privat
}
return instancekey.Digest(key), nil
}
+
+// ConfiguredEnv reports whether rt's configuration in the bucket renders
+// any environment now: the same merge and renderer SyncExec writes
+// <host>.config.env with. A configuration that renders nothing leaves no
+// file to wait for (SyncExec keeps an absent file absent), so false is
+// "no config to wait for". A stateless release waits for the file
+// otherwise (#511 drill 1, R20). The values never leave this function.
+func ConfiguredEnv(ctx context.Context, s release.Store, priv *ecdh.PrivateKey, rt registry.Route) (bool, error) {
+ m, _, err := LoadMergedHostVersions(ctx, s, release.RouteAccount(rt), rt.App, rt.Environment, rt.Host)
+ if err != nil || m == nil {
+ return false, err
+ }
+ rendered, err := RenderEnv(m, priv, routeBinding(rt))
+ if err != nil {
+ return false, err
+ }
+ return len(rendered) != 0, nil
+}
diff --git a/internal/console/apiretry.go b/internal/console/apiretry.go
index 50d64edc1..753549f2f 100644
--- a/internal/console/apiretry.go
+++ b/internal/console/apiretry.go
@@ -83,9 +83,11 @@ var (
// book owes a save, and no grant clears anything until it lands
// (errRetryUnsaved).
//
-// A replicated host (a record with a copy assignment) whose deploy attempt
-// can be retried is held by its record, not by any one box's report
-// (#511 final wave, item 8; Fable I3): its retry is the durable RetryOf
+// A stateless host whose deploy attempt can be retried, with a copy
+// assignment or at copies 1 (#511 drill 1, R20), is held by its record,
+// not by any one box's report (#511 final wave, item 8; Fable I3): a failed
+// stateless release never enters a box's failure book. Its retry is the
+// durable RetryOf
// the coordinator consumes once (requestHostRetry), whichever box's
// failure book the report joined for the host names. A box grant is
// still signed when that report holds the same build, and is otherwise
@@ -100,7 +102,9 @@ func (s *Server) retryHostBuild(ctx context.Context, acct *Account, app, host st
}
join, _ := s.loadRolloutJoin(ctx, acct.Sqid, time.Now(), nil)
ro := join.rollout(host, acct.Sqid, app)
- if d := rec.ReplicaDeploy; rec.ReplicaAssignment != nil && replicas.Retryable(d) {
+ // One copy too (#511 drill 1, R20): a failed stateless release at
+ // copies 1 is never in a box's failure book, so its record holds it.
+ if d := rec.ReplicaDeploy; replicas.Retryable(d) {
held := heldRestriction{build: d.Target.Version, replicated: true}
if ro.retryable() && ro.retryRefusal() == nil && ro.HeldBy == held.build {
held.book, held.epoch, held.declined = ro.heldBook, ro.heldEpoch, ro.Unavailable != ""
diff --git a/internal/console/replica_drill1_test.go b/internal/console/replica_drill1_test.go
new file mode 100644
index 000000000..8ae8e2f34
--- /dev/null
+++ b/internal/console/replica_drill1_test.go
@@ -0,0 +1,63 @@
+package console
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/replicas"
+)
+
+// TestReplicaInstanceRetryCopiesOne (#511 drill 1, R20): `carlos instances
+// retry` on an instance at copies 1 whose stateless release failed arms
+// the durable RetryOf on its record, as for copies above 1. It refused
+// ("not held back by a failed build, as far as its box last reported"):
+// with no copy assignment the door asked only the box's failure book,
+// which a failed stateless release never enters.
+func TestReplicaInstanceRetryCopiesOne(t *testing.T) {
+ fx := newIxFx(t, "replica-retry-one")
+ b1, _, _ := ixFleetWorld(t, fx, fx.acct)
+ rec, _ := ixRecord(t, fx, ixHost)
+ if err := provision.SetRecordFleetBox(context.Background(), fx.rel, fx.acct, "shop", ixHost, provision.FleetBoxExpect{Region: rec.Region, CreatedAt: rec.CreatedAt}, "b1", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ inc, err := provision.Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt)
+ if err != nil {
+ t.Fatal(err)
+ }
+ base := "/api/fleet/replicas/" + fx.acct + "/shop/" + ixHost
+ code, raw := replicaPost(t, fx, base+"/coordinator", "home/b1", b1, map[string]any{"incarnation": inc, "op": "acquire", "boot_id": "boot"})
+ if code != 200 {
+ t.Fatalf("acquire %d %s", code, raw)
+ }
+ var reply replicas.CoordinatorReply
+ if err := json.Unmarshal(raw, &reply); err != nil {
+ t.Fatal(err)
+ }
+ var d replicas.Deploy
+ for _, op := range []string{"begin", "releasing", "failed"} {
+ code, raw = replicaPost(t, fx, base+"/release", "home/b1", b1, map[string]any{"incarnation": inc, "op": op, "id": "deploy-1", "term": reply.Lease.Term, "revision": d.Revision, "target": replicas.Build{Version: "v1", Digest: "digest"}})
+ if code != 200 {
+ t.Fatalf("%s %d %s", op, code, raw)
+ }
+ if err := json.Unmarshal(raw, &d); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if got, _ := ixRecord(t, fx, ixHost); got.ReplicaAssignment != nil || got.ReplicaDeploy.Phase != "failed" {
+ t.Fatalf("not a failed release at copies 1: %+v", got)
+ }
+ u := fx.ts.URL + "/api/cli/apps/" + fx.acct + "/shop/instances/" + ixHost + "/retry"
+ code, _, body := rawReq(t, http.MethodPost, u, fx.owner, `{}`)
+ if code != http.StatusOK {
+ t.Fatalf("retry of a failed stateless release at copies 1 = %d %s", code, body)
+ }
+ got, _ := ixRecord(t, fx, ixHost)
+ if d := got.ReplicaDeploy; !replicas.RetryRequested(d) || !strings.HasPrefix(d.RetryRequest, "retry:") {
+ t.Fatalf("the record's retry was not armed: %+v", d)
+ }
+}
diff --git a/internal/host/replicahomekeys.go b/internal/host/replicahomekeys.go
index faffa9f39..c6cb4ed35 100644
--- a/internal/host/replicahomekeys.go
+++ b/internal/host/replicahomekeys.go
@@ -32,13 +32,17 @@ const replicaHomeKeysPath = "/etc/carlos/replica-home-keys"
type instanceKeyReaders struct {
HomeKeys func(host string) (sha256 string, ok bool)
Configured func(context.Context, registry.Route) (sha256 string, err error)
+ // Env reads, from the same configuration, whether it renders any
+ // environment: a stateless release waits for that file (#511 drill 1,
+ // R20; ExecBackend.ConfiguredEnv).
+ Env func(context.Context, registry.Route) (bool, error)
}
// newInstanceKeyReaders builds the pair from a box: getenv for the secrets
// key and the flags, open for the deploy store, list for the home-keys
// file.
func newInstanceKeyReaders(getenv func(string) string, open func(context.Context) (release.Store, error), list func() ([]byte, error)) instanceKeyReaders {
- return instanceKeyReaders{HomeKeys: replicaHomeKeys(list), Configured: configuredKey(getenv, open)}
+ return instanceKeyReaders{HomeKeys: replicaHomeKeys(list), Configured: configuredKey(getenv, open), Env: configuredEnv(getenv, open)}
}
// productionInstanceKeyReaders reads this box: its environment, its deploy
@@ -51,6 +55,7 @@ func productionInstanceKeyReaders() instanceKeyReaders {
func (k instanceKeyReaders) wire(eb *activator.ExecBackend) {
eb.ReplicaHomeKeys = k.HomeKeys
eb.ConfiguredKey = k.Configured
+ eb.ConfiguredEnv = k.Env
}
// replicaHomeKeys is ExecBackend.ReplicaHomeKeys (instance-key plan rulings
@@ -96,12 +101,27 @@ func replicaHomeKeys(read func() ([]byte, error)) func(host string) (string, boo
// the mint is deferred or the replica refused, and is tried again at the
// next launch.
func configuredKey(getenv func(string) string, open func(context.Context) (release.Store, error)) func(context.Context, registry.Route) (string, error) {
+ return configuredRead(getenv, open, appconfig.ConfiguredKeyDigest)
+}
+
+// configuredEnv is ExecBackend.ConfiguredEnv: whether rt's configuration
+// in the bucket renders any environment now (appconfig.ConfiguredEnv),
+// read as configuredKey reads; a box with no configuration source renders
+// none, so nothing is waited for (#511 drill 1, R20).
+func configuredEnv(getenv func(string) string, open func(context.Context) (release.Store, error)) func(context.Context, registry.Route) (bool, error) {
+ return configuredRead(getenv, open, appconfig.ConfiguredEnv)
+}
+
+// configuredRead is configuredKey's store and key handling around one
+// read of rt's configuration.
+func configuredRead[T any](getenv func(string) string, open func(context.Context) (release.Store, error), read func(context.Context, release.Store, *ecdh.PrivateKey, registry.Route) (T, error)) func(context.Context, registry.Route) (T, error) {
var (
mu sync.Mutex
store release.Store
priv *ecdh.PrivateKey
)
- return func(ctx context.Context, rt registry.Route) (string, error) {
+ return func(ctx context.Context, rt registry.Route) (T, error) {
+ var none T
mu.Lock()
if store == nil {
var k *ecdh.PrivateKey
@@ -110,22 +130,22 @@ func configuredKey(getenv func(string) string, open func(context.Context) (relea
k, err = appconfig.ParsePrivateKey(raw, "CARLOS_SECRETS_KEY")
if err != nil {
mu.Unlock()
- return "", err
+ return none, err
}
}
st, err := open(ctx)
if errors.Is(err, errNoDeployStore) && noSealedConfigFlag(getenv) {
mu.Unlock()
- return "", nil // no configuration source: nothing is on its way
+ return none, nil // no configuration source: nothing is on its way
}
if err != nil {
mu.Unlock()
- return "", err
+ return none, err
}
store, priv = st, k
}
st, k := store, priv
mu.Unlock()
- return appconfig.ConfiguredKeyDigest(ctx, st, k, rt)
+ return read(ctx, st, k, rt)
}
}
diff --git a/internal/provision/replica_drill1_test.go b/internal/provision/replica_drill1_test.go
index 6e0456fff..9d22999e3 100644
--- a/internal/provision/replica_drill1_test.go
+++ b/internal/provision/replica_drill1_test.go
@@ -118,3 +118,44 @@ func TestReplicaBindingAfterConversion(t *testing.T) {
t.Fatalf("the converting pass bound %q, want the converted row", bound)
}
}
+
+// TestReplicaCopiesOneRetryConsumed (#511 drill 1, R20): at copies 1 the
+// durable retry the instance retry door arms is consumed by the box's next
+// begin, as above copies 1: a new attempt that names the failed one runs
+// its release once and passes, and the box that ran it is recorded.
+func TestReplicaCopiesOneRetryConsumed(t *testing.T) {
+ ctx, s, rec, id, _ := assignmentFixture(t)
+ if err := SetRecordFleetBox(ctx, s, id.Account, id.App, id.Host, FleetBoxExpect{Region: rec.Region, CreatedAt: rec.CreatedAt}, "a", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ r, err := SetRecordCoordinator(ctx, s, id, replicas.CoordinatorChange{Op: "acquire", Box: "a", BootID: "boot"}, time.Now())
+ if err != nil {
+ t.Fatal(err)
+ }
+ term := r.Coordinator.Term
+ d1 := replicas.Build{Version: "d1", Digest: "canonical-d1"}
+ step := func(id_, retryOf, phase string) {
+ t.Helper()
+ var revision uint64
+ if r.ReplicaDeploy != nil {
+ revision = r.ReplicaDeploy.Revision
+ }
+ next, err := SetRecordReplicaRelease(ctx, s, id, revision, replicas.Deploy{ID: id_, Incarnation: id.Incarnation, Term: term, Target: d1, Phase: phase, RetryOf: retryOf})
+ if err != nil {
+ t.Fatalf("%s %s: %v", id_, phase, err)
+ }
+ r = next
+ }
+ for _, phase := range []string{"pending", "releasing", "failed"} {
+ step("deploy-1", "", phase)
+ }
+ if r, err = RequestRecordReplicaRetry(ctx, s, id, "deploy-1", "retry:x"); err != nil || !replicas.RetryRequested(r.ReplicaDeploy) {
+ t.Fatalf("arm: %v %+v", err, r)
+ }
+ step("deploy-1r", "deploy-1", "pending")
+ step("deploy-1r", "", "releasing")
+ step("deploy-1r", "", "released")
+ if d := r.ReplicaDeploy; d.RetryOf != "deploy-1" || d.RetryRequest != "retry:x" || d.LastGood != d1 || !slices.Equal(d.Swap.Completed, []string{"a"}) {
+ t.Fatalf("the retry was not consumed once: %+v", d)
+ }
+}