Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-16420-standby-lane-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Count standby qualification against the same lane-specific dispatchable queue used by standby dispatch.
5 changes: 3 additions & 2 deletions src/docs/design/standby-contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,9 @@ meets the list, and it is where the proposal stops: it is carried for logging
and decides nothing. The no-writer guard that protects the floor was widened to
cover the list's key (`TestStandbyItemTiersHaveNoWriterOutsideConfig`), so no
surface may name it, let alone write it. The tile's "M qualify" counts
contributors who could be offered at least one item queued on the lane, from
the same per-lane split `buildLaneQueueDepths` uses for the N beside it.
contributors who could be offered at least one item from the dispatchable
admission queue routed to the lane; it uses that exact lane assignment rather
than the broader lane-depth split.

### S8 — Automatic dispatch, opt-in per lane

Expand Down
19 changes: 9 additions & 10 deletions src/pkg/dashboard/contribute_ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -3134,22 +3134,21 @@ func standbyProposeItemTier(item standbypkg.Item) standbypkg.Tier {
return standbypkg.NormalizeTier(classify.ProposeStandbyItemTierFromLabels(item.Labels).Tier)
}

// standbyLaneItems projects the hive's actionable queue into the per-lane item
// lists QualifiedStandbyCounts takes. The lane split mirrors
// buildLaneQueueDepths so the M in "N waiting, M qualify" is counted over the
// same items as the N.
func standbyLaneItems(lanes []string, actionable *ghpkg.ActionableResult) map[string][]standbypkg.Item {
if len(lanes) == 0 || actionable == nil {
// standbyLaneItems projects the dispatchable admission queue into the per-lane
// item lists QualifiedStandbyCounts takes. Its lane and held-item filters match
// standbyDispatchItem so the tile counts only work dispatch can offer.
func standbyLaneItems(lanes []string, queue []ReadyQueueItem) map[string][]standbypkg.Item {
if len(lanes) == 0 || queue == nil {
return nil
}
out := make(map[string][]standbypkg.Item, len(lanes))
for _, lane := range lanes {
items := make([]standbypkg.Item, 0, len(actionable.Issues.Items))
for _, issue := range actionable.Issues.Items {
if lane != "scanner" && issue.Lane != lane && issue.Lane != "" {
items := make([]standbypkg.Item, 0, len(queue))
for _, item := range queue {
if item.Held || !strings.EqualFold(strings.TrimSpace(item.Lane), lane) {
continue
}
items = append(items, standbypkg.Item{Repo: issue.Repo, Labels: issue.Labels})
items = append(items, standbypkg.Item{Repo: item.Repo, Labels: item.Labels})
}
out[lane] = items
}
Expand Down
12 changes: 4 additions & 8 deletions src/pkg/dashboard/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2424,16 +2424,12 @@ func (s *Server) UpdateStatusIfFresh(status *StatusPayload, buildEpoch uint64) b
status.ContributorPool = s.BuildContributorPoolStatus()
status.Inception = s.buildFrontendInception()
if s.contributeHub != nil {
// The paused lanes' own queues, so the count honours item tiers
// (RFC #7629 S7). Nil when no enumeration has run yet, which is only
// visible on a hive whose owner has written an item-tier list.
var actionable *github.ActionableResult
if s.deps != nil && s.deps.Scheduler != nil {
actionable = s.deps.Scheduler.GetLastActionable()
}
// Use the admission queue that standby dispatch reads, so qualification
// counts cannot include work assigned to another lane or held from dispatch.
queue := s.contributeHub.admissionQueueSnapshot(readyQueueDefaultLimit, withheldNone).queue
status.Governor.QualifiedStandbys = s.contributeHub.QualifiedStandbyCounts(
status.Governor.SuppressedLanes,
standbyLaneItems(status.Governor.SuppressedLanes, actionable))
standbyLaneItems(status.Governor.SuppressedLanes, queue))
status.Governor.SuspendedStandbys = s.contributeHub.SuspendedStandbyCounts(status.Governor.SuppressedLanes)
}
status.Swarm = s.SwarmSnapshot()
Expand Down
35 changes: 17 additions & 18 deletions src/pkg/dashboard/standby_qualified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/github"
standbypkg "github.com/hivecommons/hive/pkg/standby"
)

Expand Down Expand Up @@ -133,29 +132,29 @@ func TestQualifiedStandbyCountsHonourItemTiers(t *testing.T) {
}
}

// TestStandbyLaneItemsSplitsTheQueueByLane covers what feeds the count on a
// live hub: each lane's share of the hive's actionable queue, split the same
// way buildLaneQueueDepths splits it, so the M and the N beside it are counted
// over the same items.
func TestStandbyLaneItemsSplitsTheQueueByLane(t *testing.T) {
actionable := &github.ActionableResult{}
actionable.Issues.Items = []github.Issue{
{Repo: "my-org/repo-a", Lane: "quality", Labels: []string{"dependencies"}},
// TestStandbyLaneItemsUsesDispatchableQueue verifies the tile counts only
// unheld admission items that standby dispatch can select for each lane.
func TestStandbyLaneItemsUsesDispatchableQueue(t *testing.T) {
queue := []ReadyQueueItem{
{Repo: "my-org/repo-a", Lane: "architect", Labels: []string{"rfc"}},
{Repo: "my-org/repo-b", Lane: "", Labels: []string{"kind/bug"}},
{Repo: "my-org/repo-b", Lane: "guide", Labels: []string{"dependencies"}},
{Repo: "my-org/repo-b", Lane: "scanner", Labels: []string{"kind/security"}, Held: true},
}
items := standbyLaneItems([]string{"quality", "architect"}, actionable)
if len(items["quality"]) != 2 {
t.Errorf("quality items = %v, want its own issue and the unrouted one", items["quality"])
items := standbyLaneItems([]string{"scanner", "guide", "architect"}, queue)
if len(items["scanner"]) != 0 {
t.Errorf("scanner items = %v, want no dispatchable items", items["scanner"])
}
if len(items["architect"]) != 2 {
t.Errorf("architect items = %v, want its own issue and the unrouted one", items["architect"])
if len(items["guide"]) != 1 {
t.Errorf("guide items = %v, want only its dispatchable issue", items["guide"])
}
if got := items["quality"][0].Labels; len(got) != 1 || got[0] != "dependencies" {
if len(items["architect"]) != 1 {
t.Errorf("architect items = %v, want only its dispatchable issue", items["architect"])
}
if got := items["guide"][0].Labels; len(got) != 1 || got[0] != "dependencies" {
t.Errorf("labels were not carried: %v", got)
}
if standbyLaneItems(nil, actionable) != nil || standbyLaneItems([]string{"quality"}, nil) != nil {
t.Error("standbyLaneItems must be nil when there is no lane or no enumeration to project")
if standbyLaneItems(nil, queue) != nil || standbyLaneItems([]string{"guide"}, nil) != nil {
t.Error("standbyLaneItems must be nil when there are no lanes or no queue")
}
}

Expand Down
Loading