From 2b5c67087b3e9d678c9ec3fe7c37fbd0b9c6f306 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 16 Aug 2026 23:58:25 +1000 Subject: [PATCH] fix(update): stamp install type and bound retry backoff --- install.sh | 4 +++- internal/daemon/daemon.go | 6 +++++- internal/daemon/daemon_test.go | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index b06cd714a..601912dff 100755 --- a/install.sh +++ b/install.sh @@ -168,7 +168,9 @@ echo "==> Building archied and archie-agent..." # refuses to self-update (internal/releaseupdate.ErrUnknownInstallType) # rather than guess whether /update's configured install command is # even the right kind of update for a script-built native binary. - go build -ldflags "-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o "${ARCHIE_BIN_DIR}/archied" ./cmd/archied + GATEWAY_VERSION="$(git describe --tags --match 'archied/v*' 2>/dev/null | sed 's|^archied/v||' || echo dev)" + RUNTIME_VERSION="$(git describe --tags --match 'archie/v*' 2>/dev/null | sed 's|^archie/v||' || echo dev)" + go build -ldflags "-X main.gatewayVersion=${GATEWAY_VERSION} -X main.runtimeVersion=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o "${ARCHIE_BIN_DIR}/archied" ./cmd/archied go build -o "${ARCHIE_BIN_DIR}/archie-agent" ./cmd/archie-agent ) echo " Installed binaries to ${ARCHIE_BIN_DIR}/" diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index adaf95ef9..b57e778f5 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -1096,10 +1096,14 @@ func (d *Daemon) requestTaskRun(ctx context.Context, taskID int64, data []byte) if !errors.Is(err, eventbus.ErrNoResponders) || !time.Now().Before(deadline) { return nil, err } + wait := min(backoff, time.Until(deadline)) + if wait <= 0 { + return nil, err + } select { case <-ctx.Done(): return nil, ctx.Err() - case <-time.After(backoff): + case <-time.After(wait): } } } diff --git a/internal/daemon/daemon_test.go b/internal/daemon/daemon_test.go index 3994155a7..183f5cb7c 100644 --- a/internal/daemon/daemon_test.go +++ b/internal/daemon/daemon_test.go @@ -390,6 +390,22 @@ func daemonWithNATS(t *testing.T) (*Daemon, *store.Store, *arnats.Client) { return d, s, client } +func TestRequestTaskRunDoesNotSleepPastReadyDeadline(t *testing.T) { + d, _, _ := daemonWithNATS(t) + d.TaskRunReadyTimeout = 10 * time.Millisecond + d.TaskRunRetryBackoff = time.Second + + start := time.Now() + _, err := d.requestTaskRun(context.Background(), 1, nil) + elapsed := time.Since(start) + if err == nil { + t.Fatal("requestTaskRun() error = nil, want no responders") + } + if elapsed >= 200*time.Millisecond { + t.Fatalf("requestTaskRun() took %s, want it to stop at the ready deadline", elapsed) + } +} + func TestRunViaAgentParksOnRequestFailure(t *testing.T) { d, s, _ := daemonWithNATS(t) // Bound the no-responders retry window tightly so this test proves @@ -1066,6 +1082,7 @@ func (f *recordingForge) CreateIssue(context.Context, string, string, string, st func (f *recordingForge) React(context.Context, string, string, int, string) error { panic("unexpected call") } + func (f *recordingForge) VerifyPush(context.Context, string, string) error { panic("unexpected call") } func (f *recordingForge) LinkBranch(context.Context, string, string, int, string) error { panic("unexpected call")