Skip to content

Commit 2dd4548

Browse files
committed
cmd/coordinator: consider explicitly requested builders as SlowBots
Previously, a builder was considered to be "SlowBot" whenever it was requested via the TRY= syntax, and it wasn't already a part of the default set of trybot builders. This change makes it so that a builder is considered a SlowBot if it was explicitly requested via the TRY= syntax, even if it was already going to run anyway. The goal behind this change is to improve the experience of using SlowBots, by making them more useful and predictable. The UI currently reports that "SlowBots are starting ..." whenever there is a non-zero amount of SlowBots. So if a user requested TRY=linux-amd64, they'd likely see "TryBots are starting ...", which can be misunderstood to mean that SlowBots are not working. Additionally, if a user requested three builders via TRY= syntax, but one of them happened to be a part of the default try set, then the message at the end would be "Extra slowbot builds that ran:" including only 2 builders. At that point, it's hard to tell whether they got the TRY= syntax wrong for one of the builders, or if it was omitted because it's always run anyway. A future usability improvement in golang.org/issue/38279 is to make SlowBots not skip any tests that normal trybots may skip for faster results. This change is in preparation for that. For golang/go#38279. For golang/go#34501. Change-Id: Idb7f1bcb1694fe72f85237976995a94f273c7c16 Reviewed-on: https://go-review.googlesource.com/c/build/+/227778 Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]>
1 parent b7c61f7 commit 2dd4548

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

cmd/coordinator/coordinator.go

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,9 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
11671167
// TODO(golang.org/issue/38303): compute goBranch value better
11681168
goBranch := key.Branch // assume same as repo's branch for now
11691169

1170-
builders := dashboard.TryBuildersForProject(key.Project, key.Branch, goBranch)
1171-
slowBots := slowBotsFromComments(work, builders)
1172-
builders = append(builders, slowBots...)
1170+
tryBots := dashboard.TryBuildersForProject(key.Project, key.Branch, goBranch)
1171+
slowBots := slowBotsFromComments(work)
1172+
builders := joinBuilders(tryBots, slowBots)
11731173

11741174
log.Printf("Starting new trybot set for %v", key)
11751175
ts := &trySet{
@@ -1342,6 +1342,23 @@ func tryKeyToBuilderRev(builder string, key tryKey, goRev string) buildgo.Builde
13421342
}
13431343
}
13441344

1345+
// joinBuilders joins sets of builders into one set.
1346+
// The resulting set contains unique builders sorted by name.
1347+
func joinBuilders(sets ...[]*dashboard.BuildConfig) []*dashboard.BuildConfig {
1348+
byName := make(map[string]*dashboard.BuildConfig)
1349+
for _, set := range sets {
1350+
for _, bc := range set {
1351+
byName[bc.Name] = bc
1352+
}
1353+
}
1354+
var all []*dashboard.BuildConfig
1355+
for _, bc := range byName {
1356+
all = append(all, bc)
1357+
}
1358+
sort.Slice(all, func(i, j int) bool { return all[i].Name < all[j].Name })
1359+
return all
1360+
}
1361+
13451362
// state returns a copy of the trySet's state.
13461363
func (ts *trySet) state() trySetState {
13471364
ts.mu.Lock()
@@ -1541,7 +1558,7 @@ func (ts *trySet) noteBuildComplete(bs *buildStatus) {
15411558
numFail, len(ts.builds), name, errMsg)
15421559
}
15431560
if len(ts.slowBots) > 0 {
1544-
fmt.Fprintf(&buf, "Extra slowbot builds that ran:\n")
1561+
fmt.Fprintf(&buf, "SlowBot builds that ran:\n")
15451562
for _, c := range ts.slowBots {
15461563
fmt.Fprintf(&buf, "* %s\n", c.Name)
15471564
}
@@ -2073,8 +2090,11 @@ func (st *buildStatus) useKeepGoingFlag() bool {
20732090
return !st.isTry() && strings.HasPrefix(st.branch, "release-branch.go")
20742091
}
20752092

2093+
// isTry reports whether the build is a part of a TryBot (pre-submit) run.
2094+
// It may be a normal TryBot (part of the default try set) or a SlowBot.
20762095
func (st *buildStatus) isTry() bool { return st.trySet != nil }
20772096

2097+
// isSlowBot reports whether the build is an explicitly requested SlowBot.
20782098
func (st *buildStatus) isSlowBot() bool {
20792099
if st.trySet == nil {
20802100
return false
@@ -2093,7 +2113,7 @@ func (st *buildStatus) buildRecord() *types.BuildRecord {
20932113
ProcessID: processID,
20942114
StartTime: st.startTime,
20952115
IsTry: st.isTry(),
2096-
IsExtra: st.isSlowBot(),
2116+
IsSlowBot: st.isSlowBot(),
20972117
GoRev: st.Rev,
20982118
Rev: st.SubRevOrGoRev(),
20992119
Repo: st.RepoOrGo(),
@@ -3942,33 +3962,23 @@ func importPathOfRepo(repo string) string {
39423962
return r.ImportPath
39433963
}
39443964

3945-
// slowBotsFromComments looks at the TRY= comments from Gerrit (in
3946-
// work) and returns any addition slow trybot build configuration that
3947-
// should be tested in addition to the ones provided in the existing
3948-
// slice.
3949-
func slowBotsFromComments(work *apipb.GerritTryWorkItem, existing []*dashboard.BuildConfig) (extraBuilders []*dashboard.BuildConfig) {
3950-
have := map[string]bool{}
3951-
for _, bc := range existing {
3952-
have[bc.Name] = true
3953-
}
3954-
3965+
// slowBotsFromComments looks at the Gerrit comments in work,
3966+
// and returns all build configurations that were explicitly
3967+
// requested to be tested as SlowBots via the TRY= syntax.
3968+
func slowBotsFromComments(work *apipb.GerritTryWorkItem) (builders []*dashboard.BuildConfig) {
39553969
tryTerms := latestTryTerms(work)
3956-
39573970
for _, bc := range dashboard.Builders {
3958-
if have[bc.Name] {
3959-
continue
3960-
}
39613971
for _, term := range tryTerms {
39623972
if bc.MatchesSlowBotTerm(term) {
3963-
extraBuilders = append(extraBuilders, bc)
3973+
builders = append(builders, bc)
39643974
break
39653975
}
39663976
}
39673977
}
3968-
sort.Slice(extraBuilders, func(i, j int) bool {
3969-
return extraBuilders[i].Name < extraBuilders[j].Name
3978+
sort.Slice(builders, func(i, j int) bool {
3979+
return builders[i].Name < builders[j].Name
39703980
})
3971-
return
3981+
return builders
39723982
}
39733983

39743984
// xReposFromComments looks at the TRY= comments from Gerrit (in

cmd/coordinator/coordinator_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ func mustConf(t *testing.T, name string) *dashboard.BuildConfig {
271271
}
272272

273273
func TestSlowBotsFromComments(t *testing.T) {
274-
existing := []*dashboard.BuildConfig{mustConf(t, "linux-amd64")}
275274
work := &apipb.GerritTryWorkItem{
276275
Version: 2,
277276
TryMessage: []*apipb.TryVoteMessage{
@@ -289,9 +288,9 @@ func TestSlowBotsFromComments(t *testing.T) {
289288
},
290289
},
291290
}
292-
extra := slowBotsFromComments(work, existing)
291+
slowBots := slowBotsFromComments(work)
293292
var got []string
294-
for _, bc := range extra {
293+
for _, bc := range slowBots {
295294
got = append(got, bc.Name)
296295
}
297296
want := []string{"aix-ppc64", "darwin-amd64-10_14", "linux-arm64-packet"}

types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type BuildRecord struct {
8787
ProcessID string
8888
StartTime time.Time
8989
IsTry bool // is trybot run
90-
IsExtra bool // is an extra opt-in "slowbot" builder, not on by default
90+
IsSlowBot bool // is an explicitly requested "slowbot" builder
9191
GoRev string
9292
Rev string // same as GoRev for repo "go"
9393
Repo string // "go", "net", etc.

0 commit comments

Comments
 (0)