diff --git a/submitqueue/orchestrator/controller/build/build.go b/submitqueue/orchestrator/controller/build/build.go index 4a0880d6..ce770ad7 100644 --- a/submitqueue/orchestrator/controller/build/build.go +++ b/submitqueue/orchestrator/controller/build/build.go @@ -260,7 +260,7 @@ func (c *Controller) startPath(ctx context.Context, store storage.Storage, batch return fmt.Errorf("failed to record build %s: %w", buildID.ID, err) } - link := entity.PathBuild{PathID: entry.ID, Attempt: entry.Attempt, BuildID: buildID.ID} + link := entity.PathBuild{Queue: batch.Queue, PathID: entry.ID, Attempt: entry.Attempt, BuildID: buildID.ID} if err := store.GetPathBuildStore().Create(ctx, link); err != nil { if errors.Is(err, storage.ErrAlreadyExists) { // Another dispatch named this attempt first. Its build is the one diff --git a/submitqueue/orchestrator/controller/build/build_test.go b/submitqueue/orchestrator/controller/build/build_test.go index 44d4f4a3..5ade579d 100644 --- a/submitqueue/orchestrator/controller/build/build_test.go +++ b/submitqueue/orchestrator/controller/build/build_test.go @@ -231,7 +231,7 @@ func TestProcess_TriggersWithThePathsBase(t *testing.T) { return nil }), deps.pathBuilds.EXPECT().Create(gomock.Any(), entity.PathBuild{ - PathID: entry.ID, Attempt: 1, BuildID: "build-1", + Queue: "test-queue", PathID: entry.ID, Attempt: 1, BuildID: "build-1", }).Return(nil), deps.publisher.EXPECT().Publish(gomock.Any(), "buildsignal", gomock.Any()). DoAndReturn(func(_ context.Context, _ string, msg entityqueue.Message) error { @@ -270,7 +270,7 @@ func TestProcess_NeverWritesThePathSetAndIgnoresCancelling(t *testing.T) { Return(entity.BuildID{ID: "build-1"}, nil) deps.builds.EXPECT().Create(gomock.Any(), gomock.Any()).Return(nil) deps.pathBuilds.EXPECT().Create(gomock.Any(), entity.PathBuild{ - PathID: pending.ID, Attempt: 1, BuildID: "build-1", + Queue: "test-queue", PathID: pending.ID, Attempt: 1, BuildID: "build-1", }).Return(nil) expectSignal(t, deps, "build-1") @@ -336,7 +336,7 @@ func TestProcess_LostDispatchRaceHandsBothBuildsToThePollLoop(t *testing.T) { deps.pathBuilds.EXPECT().Get(gomock.Any(), entry.ID, 1). Return(entity.PathBuild{}, storage.ErrNotFound), deps.pathBuilds.EXPECT().Create(gomock.Any(), entity.PathBuild{ - PathID: entry.ID, Attempt: 1, BuildID: "build-surplus", + Queue: "test-queue", PathID: entry.ID, Attempt: 1, BuildID: "build-surplus", }).Return(storage.ErrAlreadyExists), deps.pathBuilds.EXPECT().Get(gomock.Any(), entry.ID, 1). Return(entity.PathBuild{PathID: entry.ID, Attempt: 1, BuildID: "build-winner"}, nil), diff --git a/submitqueue/orchestrator/controller/speculate/dispatch.go b/submitqueue/orchestrator/controller/speculate/dispatch.go index 2d061ff7..f802b7ed 100644 --- a/submitqueue/orchestrator/controller/speculate/dispatch.go +++ b/submitqueue/orchestrator/controller/speculate/dispatch.go @@ -46,7 +46,7 @@ func (c *Controller) dispatch(ctx context.Context, store storage.Storage, queue // at all, because nothing marked it changed. set, exists := snap.pathSets[batch.ID] if !exists { - set = entity.SpeculationPathSet{Head: batch.ID} + set = entity.SpeculationPathSet{Queue: queue, Head: batch.ID} } changed := snap.isDirty(batch.ID) diff --git a/submitqueue/orchestrator/controller/speculate/run_test.go b/submitqueue/orchestrator/controller/speculate/run_test.go index d4245b84..ed3f3f8f 100644 --- a/submitqueue/orchestrator/controller/speculate/run_test.go +++ b/submitqueue/orchestrator/controller/speculate/run_test.go @@ -159,6 +159,10 @@ func TestRun_FundsProposedPath(t *testing.T) { h.pathSets.EXPECT().Create(gomock.Any(), gomock.Any()). DoAndReturn(func(_ context.Context, set entity.SpeculationPathSet) error { require.Len(t, set.Paths, 1) + // The set must name the queue it belongs to: the store is bound to + // one queue and refuses a write that disagrees, so an unstamped set + // means no head is ever funded. + assert.Equal(t, "q", set.Queue) assert.Equal(t, path.ID(), set.Paths[0].ID) assert.Equal(t, entity.SpeculationPathStatusPending, set.Paths[0].Status) assert.Equal(t, 1, set.Paths[0].Attempt)